From 6ab95c99fcc11584bd8119ce73c7081eb70d7af7 Mon Sep 17 00:00:00 2001 From: Brielle Date: Fri, 10 Jan 2020 12:53:32 -0700 Subject: [PATCH] Update to new 2.0 version based on PHP --- .gitignore | 4 +++- Convert Images.lnk | Bin 1078 -> 1183 bytes bin/config.inc.php | 11 ++++++++++ bin/config.txt | 42 -------------------------------------- bin/functions.inc.php | 37 +++++++++++++++++++++++++++++++++ bin/process-images.php | 45 +++++++++++++++++++++++++++++++++++++++++ bin/process-images.sh | 22 -------------------- bin/run-conversion.cmd | 4 ++-- 8 files changed, 98 insertions(+), 67 deletions(-) create mode 100644 bin/config.inc.php delete mode 100644 bin/config.txt create mode 100644 bin/functions.inc.php create mode 100644 bin/process-images.php delete mode 100644 bin/process-images.sh diff --git a/.gitignore b/.gitignore index 31af859..92b314a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ bin/GraphicsMagick-1.3.25-Q8/ +bin/ext/ bin/*.exe -bin/*.dll \ No newline at end of file +bin/*.dll +bin/php.ini diff --git a/Convert Images.lnk b/Convert Images.lnk index ec24cb018a5bc8ecb1ad1c838d93cce154ec688c..66aba4782e4d8e97e445bfe6051bb1fdfda50e18 100644 GIT binary patch literal 1183 zcmb7DUr1A76#vZ(G$QZR@(-3P2$pi^W)GDhO=dbn-Dqe%EYSVQP2An>F144mB+9}b z6(I}>O$vJm3G<<_!g>i@f~EbzC1Fy68X}J zyBJ(}fpe_ifMa#FqRr7^G1+R$f%-L^WBtr|c{funuu71_pMMckD{+dHX_#yqWv(DX z_wdd{-Vl6rB9BlXx7=vniv*TBf}XI6Amlv>sLi1!2Sbfbepv~7ML8h5sam(vDv92( z)aF+r!LVfVhKM?wZgIyeb8jdc0XCG-nSb}XA(qXcHX0r!=x=H9i?WwKkX$YNUeq;H zT-!T!`cCd!YtBpiRPMX|OZxMjJ~XGbUs&(^PijFbFnE%>XdO%oT=Lk{Wt$d>uVR{w*BASeK7AD5&zqO@;|pJ2|9Nn+i~XAX1-#7pb^rhX literal 1078 zcmah{TS${(7=C7w7MWWbOp#niEZN*dh!(|c>mP->wIMCoh3PuT5@ zwzmP8nPU^Ka4_s#-u-OJ-)g?MTr+g}*5acBjBk_<+sRGj|Cf#N`OZo@d@;Hw@)`n}vYUhIT8^34Ff&c&j diff --git a/bin/config.inc.php b/bin/config.inc.php new file mode 100644 index 0000000..90fcb12 --- /dev/null +++ b/bin/config.inc.php @@ -0,0 +1,11 @@ + diff --git a/bin/config.txt b/bin/config.txt deleted file mode 100644 index 49f3e77..0000000 --- a/bin/config.txt +++ /dev/null @@ -1,42 +0,0 @@ -#=-=-=-= DON'T MESS WITH THIS SECTION =-=-=-= -# These are locations of where stuff is located on disk. -# Normally, you don't need to change this UNLESS you move the -# directory outside of C:\ -MAINPREFIX="/C/imageproc" - -BINLOC="${MAINPREFIX}/bin" -RAWLOC="${MAINPREFIX}/raw" -RENAMELOC="${MAINPREFIX}/renamed" -RESIZELOC="${MAINPREFIX}/resized" - -# Path prefix. Best not to change this -# unless you know what your doing. -PATH="${BINLOC}:." - -# Program Version -PROG_VERSION="1.2-04052017" - -# Version of graphicsmagick to use -GM_VERSION="GraphicsMagick-1.3.34-Q8" -#=-=-=-= END SECTION =-=-=-= - -# Here is the commonly changed preferences - -# The end resulting image size. Can be specified -# as just the long length (1600x) or as the desired -# max dimensions (1600x1050). -IMG_RESIZE="1600x" - -# Quality setting. Lower number reduces image size -# at the expense of quality. 0 is lowest, 100 highest -# and 75 is the default. -IMG_QUALITY="75" - -# Custom image options, normally this is blank, but we -# can specify things like sharpness masks if we want. -#IMG_OPTIONS="-unsharp 2x0.5+0.7+0" -IMG_OPTIONS="+profile \"*\"" - -# Number to start the name at. Commonly -# set to "1" -STARTNUM="1" \ No newline at end of file diff --git a/bin/functions.inc.php b/bin/functions.inc.php new file mode 100644 index 0000000..296561b --- /dev/null +++ b/bin/functions.inc.php @@ -0,0 +1,37 @@ +getImageOrientation()) { + case Imagick::ORIENTATION_TOPLEFT: + break; + case Imagick::ORIENTATION_TOPRIGHT: + $image->flopImage(); + break; + case Imagick::ORIENTATION_BOTTOMRIGHT: + $image->rotateImage("#000", 180); + break; + case Imagick::ORIENTATION_BOTTOMLEFT: + $image->flopImage(); + $image->rotateImage("#000", 180); + break; + case Imagick::ORIENTATION_LEFTTOP: + $image->flopImage(); + $image->rotateImage("#000", -90); + break; + case Imagick::ORIENTATION_RIGHTTOP: + $image->rotateImage("#000", 90); + break; + case Imagick::ORIENTATION_RIGHTBOTTOM: + $image->flopImage(); + $image->rotateImage("#000", 90); + break; + case Imagick::ORIENTATION_LEFTBOTTOM: + $image->rotateImage("#000", -90); + break; + default: // Invalid orientation + break; + } + $image->setImageOrientation(Imagick::ORIENTATION_TOPLEFT); + return $image; +} +?> diff --git a/bin/process-images.php b/bin/process-images.php new file mode 100644 index 0000000..de11e0b --- /dev/null +++ b/bin/process-images.php @@ -0,0 +1,45 @@ +stripImage(); // if you want to get rid of all EXIF data +//$img->writeImage(); +$progVersion="v2.0-PHP"; +$phpVersion=phpversion(); +$rawDir="raw/"; +$outDir="resized/"; + +echo "ImageProc ".$progVersion." - PHP ".$phpVersion."\n\n\n"; + +$dateInput=readline("Current Date (press enter for ".date('mdy')."): "); +$startNumInput=readline("Starting Number: "); + +if (empty($dateInput)) { + $dateInput=date('mdy'); +} +if (empty($startNumInput)) { + $startNumInput="1"; +} +echo "\n"; +foreach(glob($rawDir.'*.{jpg,JPG,jpeg,JPEG}',GLOB_BRACE) as $filename){ + $outputName=basename($filename); + $outImgFile=sprintf("%s/%s-%04d.jpg",$outDir, $dateInput, $startNumInput); + echo "#"; + $img=new Imagick($filename); + autorotate($img); + $img->stripImage(); + // This is kinda slow sometimes, so we'll try using scaleImage instead + //$img->resizeImage($imgWidth, $imgHeight, imagick::FILTER_CATROM, 1); + $img->scaleImage($imgWidth, $imgHeight, FALSE); + $img->setImageCompressionQuality($imgQuality); + $img->writeImage($outImgFile); + $img->destroy(); + $startNumInput++; +} +echo "\n\nTotal Runtime: ".ceil((microtime(true) - $time_start))." seconds"; +echo "\n"; +readline(""); +?> \ No newline at end of file diff --git a/bin/process-images.sh b/bin/process-images.sh deleted file mode 100644 index b59b35f..0000000 --- a/bin/process-images.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -. ./config.txt - -echo -e "eBay Image Processor - Version ${PROG_VERSION}\n\n" -echo -n "Please enter current date: " -read CURRDATE -#CURRDATE="030413" - -echo "Beginning rename..." -${BINLOC}/find ${RAWLOC} -iname '*.jpg' |\ - ${BINLOC}/gawk -v resizeloc=${RESIZELOC} -v currdate=${CURRDATE} -v startnum=${STARTNUM} -v binloc=${BINLOC} 'BEGIN{ a=startnum }{ printf "%s/cp -f \"%s\" \"%s/%s_%04d.jpg\"\n", binloc,$0,resizeloc,currdate,a++ }' \ - | ${BINLOC}/bash - -#echo "Copying..." -#${BINLOC}/cp -f ${RENAMELOC}/* ${RESIZELOC}/ -echo "Resizing..." -time ${BINLOC}/${GM_VERSION}/gm mogrify -resize ${IMG_RESIZE} -quality ${IMG_QUALITY} ${IMG_OPTIONS} ${RESIZELOC}/*.jpg - -echo "Done!" -echo "Press enter to close." -read DUMMYVAR \ No newline at end of file diff --git a/bin/run-conversion.cmd b/bin/run-conversion.cmd index 7c996ba..167d8fb 100644 --- a/bin/run-conversion.cmd +++ b/bin/run-conversion.cmd @@ -1,3 +1,3 @@ @ECHO OFF -set PATH=C:\imageproc\bin;%PATH%;%CD% -bash.exe process-images.sh \ No newline at end of file +set PATH=C:\imageproc-php\bin;%PATH%;%CD% +bin\php.exe bin\process-images.php \ No newline at end of file