Using meio upload to programmatically crop photos

157 Views Asked by At

I want to use CAKE PHP MEIO upload to generate thumbnails of 50 photos programmatically taking from a directory and not by uploading individually.

May Be by calling some meio upload library function.

$meio->crop('/path/to/image/')->saveTo('/path/to/target/dir/filename.jpg');

Is there any possible way to upload files like this.

1

There are 1 best solutions below

1
On

ImageTool is great for this kind of thing.

Use a combination of cake's Folder and File utilities to open the directory, loop through the files and apply the necessary resizing.

e.g.:

$dir = new Folder('/path/to/my/images');
$files = $dir->find('.*\.jpg'); // find all jpg
foreach($files as $file) {
    $this->ImageTool->resize(...);
    // etc
}