writeImage() in different folder with the same name
Posted: 2013-10-14T11:08:58-07:00
Hi Guys, I have a problem and spend all day to solve it, but without any results.
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.
What should i do to save files in new folder?
All permisions sets to 777, folder is exist, and imagick can save images to this folder.
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.