WriteImages in another folder to put the name change?

Friends, tell me how to use writeImages save the cropped image to a folder? All cuts, but cuts the original image, and how to change the name or to a new folder to put? Don't understand, tried everything :(

Here's a piece, looking for the image in the folder and cut it, it works, but only with the original image and spoils it, and you need to make a copy of the less next, where to dig?

$dir = $modx->getOption('base_path') . 'uploads/'.$id_user.'/'; //original images
$files = glob($dir . "*.jpg"); 

foreach($files as $images) {

 $image = new Imagick ($images);
 $imageprops = $image->getImageGeometry();
 $image->resizeImage(534,280, imagick::FILTER_BOX, 0.9, true);
 $image->writeImages($images, true);
}
return;
June 27th 19 at 15:29
1 answer
June 27th 19 at 15:31
Solution
$path_parts = pathinfo($images);
$newname = $path_parts['dirname'].DIRECTORY_SEPARATOR.$path_parts['filename'].'_thumb.'.$path_parts['extension'];
$image->writeImages($newname, true);
Thank you! Worked finally :) I'd such a design has not. How to change the path of the new drawing? Name now added _thumb.jpg and how to put it in a folder with the name new for example? - jordan_Schmi commented on June 27th 19 at 15:34
:
$newname = 'path/to/new/direcotry/'.$path_parts['filename'].'_thumb.'.$path_parts['extension'];
// or
$newname = $path_parts['dirname'].DIRECTORY_SEPARATOR.'new'.DIRECTORY_SEPARATOR.$path_parts['filename'].'_thumb.'.$path_parts['extension'];
- Violet_Wiso commented on June 27th 19 at 15:37
: THANK you! Don't know what I would have done without you :) and last please tell me why only the height of the cuts? If you specify 1200 630 will do it for 895 630 or 534 280 that will make 398 280 as mocks :) - jordan_Schmi commented on June 27th 19 at 15:40
Compresses with saving of proportions. - Violet_Wiso commented on June 27th 19 at 15:43
to unleash the proportions it does not work? Or at least width that would cut you? - jordan_Schmi commented on June 27th 19 at 15:46
: Well, read the documentation php.net/manual/ru/book.imagick.php - Violet_Wiso commented on June 27th 19 at 15:49
: THANK YOU ANDREW! Found examples, with dimensions clearly, it is easier than way :) - jordan_Schmi commented on June 27th 19 at 15:52

Find more questions by tags PHP