Skip to content Skip to sidebar Skip to footer

How Can I Generate A Thumbnails From A Directory Of Images Using Php?

I have full high quality images and in a specific directly on my website. Using PHP I would like to generate thumbnails from this directory to another directory called 'thumbs'. I

Solution 1:

The input directory would be $images_dir in get_files.

You'll need to loop over the results of this method and call make_thumb where $dest will be the final name of that particular file.

Something like this (haven't tested this):

//Set up variables we need$image_directory = "/some/directory/with/images/";
$thumbs_directory = "/some/directory/for/thumbs/";
$desired_width = 100;

//Get the name of files in $image_directoryforeach(get_files($image_directory) as$image){
    //Call make thumb with the given image location and put it into the thumbs directory.
    make_thumb($image_directory . $image, $thumbs_directory . $image, $desired_width)
}

Post a Comment for "How Can I Generate A Thumbnails From A Directory Of Images Using Php?"