Jackson
Jackson

Reputation: 820

PHP: resize all the images in a directory using imagick?

I have a folder with 100's of images in it. I need to resize all the images using imagick.

for a single image I can run:

exec("/usr/bin/convert images/image-name.jpg -resize 550x413  images/image-name.jpg");

But how would i go about doing the same thing with all the images?

is there any foreach loop function that I could use?

Any help would be appreciated.

Thanks in advance.

Upvotes: 1

Views: 664

Answers (1)

BSeitkazin
BSeitkazin

Reputation: 3059

You can load all images in array then execute your method in foreach loop. To load all images in specific array you can use the following command:

$images_array = glob($dir.'*.jpg');
foreach ($images_array as $item) {
    //your code goes here 
}

Upvotes: 2

Related Questions