Hello,
I have a customer that request an ImageMagick command that convert an image to a jpeg. He told me :
"We want JPG files with 2000 pixels at least for the smallest side and 3000 pixels at least for the bigger side."
I thought I could do it with something like widthxheight^ (found : http://www.imagemagick.org/script/comma ... p#geometry) if I knew the image orientation first, but unfortunately they want to provide both landscape and portait image to the same command.
Did someone have an idea on how to match the customer need?
Many thanks in advance,
Regards,
MisterJpa
Resize Image with restrictions
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resize Image with restrictions
So, you can make all your images 5000 by 5000 pixels and your customer will be happy? Maybe not.
I would do this in three steps:
1. Find the current size.
2. Do some processing to calculate the new size.
3. Resize, or crop, or whatever is wanted, to the new size.
I would do this in three steps:
1. Find the current size.
2. Do some processing to calculate the new size.
3. Resize, or crop, or whatever is wanted, to the new size.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Resize Image with restrictions
What is your Imagemagick version? Calculations can be done inline with Imagemagick 7.
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Resize Image with restrictions
Using ImageMagick 6 it can be done with a command like this...
Code: Select all
convert input.jpg \
-set option:distort:scale "%[fx:max((w>h?3000:2000)/w,(w>h?2000:3000)/h)]" \
-distort SRT 0 output6.jpg
Code: Select all
magick input.jpg -resize "%[fx:w>h?3000:2000]x%[fx:w>h?2000:3000]^" output7.jpg
Re: Resize Image with restrictions
Hello,
I'm using ImageMagick 7.
I will try this on Friday at work and keep you updated
Many many thanks !
Regards,
MisterJpa
I'm using ImageMagick 7.
I will try this on Friday at work and keep you updated
Many many thanks !
Regards,
MisterJpa