I try to get all images from the folder and save it to another folder with the same name.
Variable $filename store the path to file with the name, so I try to merge variables to add new path, but its not working. If I use $filename in $im->writeImageFile($newPath); original images replace with new one.
Code: Select all
foreach (glob("images/*.jpg") as $filename) {
echo "$filename size " . filesize($filename) . "<br>";
/* Create new imagick object */
$im = new imagick($filename);
/* real size */
$size = $im->getImageWidth();
echo "$size <br>";
/* size after resizing */
$im->thumbnailImage(120,0);
$sizeNew = $im->getImageWidth();
echo "$sizeNew <br>";
/* make and see new path */
$newF= "new/" ;
$newPath = $newF.$filename;
echo $newPath;
/* write image to new path */
$im->writeImageFile($newPath);
}
All permisions sets to 777, folder is exist, and imagick can save images to this folder.