Page 1 of 1

Resize and image!

Posted: 2018-06-04T06:11:18-07:00
by bekalariak
Hi everyone!!

I am trying to resize (in a perl script) an image that has these dimensions 4272x2848 to other one that has 1280x720. Of course, while the aspect ratios are different, the image has to be 1) cuted above/right and below/left or 2) expanded.
Well, I cant find the solution to get the first option. Using the code below I reach an image expanded but I do not want that.

------>$iamge->Resize(geometry=>'1280x720!');
or
------>$iamge->Resize(width=>$width, height=>$height);

I try every thing, Scale, Extent, Resize, Gravity... But I do not get it. :shock: :shock:

Re: Resize and image!

Posted: 2018-06-04T06:31:14-07:00
by snibgo
I don't understand the question. The aspect ratios are different. 4272:2848 = 1.5:1, and 1280:720 is 1.778:1.

If you want to stretch the image to be exactly 1280x720, use "!". If you want to resize but keep the same aspect ratio and fit within 1280x720, don't use "!". The result will be 1080x720.

Re: Resize and image!

Posted: 2018-06-04T07:02:31-07:00
by bekalariak
Sorry for my explanation. Yes, I want to stretch the image to be exactly 1280x720. But when I do that, the image looks extended. So to avoid that i want to "cut" the image above/below or left/right.

Re: Resize and image!

Posted: 2018-06-04T07:19:39-07:00
by snibgo
If you use "^", the output is 1280x853. You can then crop to 1280x720. Does that do what you want?

Re: Resize and image!

Posted: 2018-06-06T03:42:39-07:00
by bekalariak
Yes, that was exactly that I wanted! The simplest idea are the easiest.
Only a note, for future people, when we Crop the image the part of the botton is the croped. So, I use "gravity=>'Center'" to crop equaly.

------>$image->Resize(geometry=>'1280x720^');
------>$image->Crop(geometry=>'1280x720', gravity=>'Center');

Thanks