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.
Resize and image!
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resize and image!
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.
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.
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
Re: Resize and image!
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resize and image!
If you use "^", the output is 1280x853. You can then crop to 1280x720. Does that do what you want?
snibgo's IM pages: im.snibgo.com
-
- Posts: 6
- Joined: 2018-05-02T06:18:59-07:00
- Authentication code: 1152
Re: Resize and image!
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
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