Revision: 29593
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 1, 2010 06:47 by abhiomkar
Initial Code
<?php $SQUARESIZE = 108; // the size in pixels for your square images $convertPath = "/usr/local/bin/convert"; // full path to ImageMagick's convert tool $path = getcwd()."/"; // path to folder full of jpg files to convert $n = 0; if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && strpos($file,"jpg") !== false) { echo $file."\n"; $originalname = $file; $filenamePart = $n++; $squarename = $filenamePart."_sq.jpg"; $squareCommand = $convertPath." \"".$path.$originalname."\" -thumbnail x".($SQUARESIZE*2)." -resize '".($SQUARESIZE*2)."x<' -resize 50% -gravity center -crop ".$SQUARESIZE."x".$SQUARESIZE."+0+0 +repage -format jpg -quality 91 \"".$path."sq/".$squarename."\""; system($squareCommand); } } closedir($handle); } ?>
Initial URL
http://www.randomsequence.com/articles/making-square-thumbnails-with-imagemagick/
Initial Description
Initial Title
PHP Code to generate thumbnails of all images in current directory
Initial Tags
Initial Language
PHP