I am trying to loop through all the images in a subdirectory and change thier size with ImageMagick. It's not quite working.
I look through the files, output the file names, but no image changing is taking place. If someone would help me with my code, I'd greatly appreacite it. 🙂
// open directory
$dir = opendir("/var/www/html/home/images/imagick");
$thumb = "thumb";
$mid = "mid";
// loop through the directory while reading it's contents
while ($file = readdir($dir)) {
// if the current file in the loop is a JPEG then do stuff
if (ereg("jp[e|eg|g]$", $file)) {
$newfile = $thumb.$file;
$create_thumb = "convert -size 120x120 $file -resize 120x120 $newfile";
system($create_thumb);
echo "<br>file: $file, <br>thumb: $thumb, <br>newfile: $newfile<br>";
}
}
I've taken snippets from other posts, if this looks familiar.
Thanks.