5

I am familiar with convert -resize % for decreasing a size by percentage but what is the command to increase an image from say 700 pixels to 800 pixels? Horizontal width should resize, too. I need to preserve the overall quality and look of the image as best as possible.

EDIT:

mogrify -resize geometry

that appears to be what I need to resize the images. Link to article for the next person trying to figure out how to resize.

2 Answers2

2

The of the The ImageMagic convert option -resize has a geometry argument with powerful syntax (see below) to express the desired relation of old and new image dimensions.

To resize one dimension to an explicit value, and resize the other dimension by the same factor, keeping the aspect ratio, you can leave out one of the values in the normal format 950x700 specification like this: 950 for specifying width, or x700 for height.

convert in.jpg -resize x700 out.jpg

should do what you need.

Regarding getting best possible output, the biggest factor should be recompressing the image. If you output an JPEG image, it is compressed in a slightly different way than before, even with the same compression options and the same software (otherwise, it can be a bigger difference).

The defaults for -resize are really good, unlike in much other software. You should best just leave them alone.

For fine tuning options affecting the filter step of the resize, I disagree with the answer of @peterph, I do not think it would help experimenting with the options -filter and -define filter:support=...:

You can break lots of things, while it's hard to tell what changed.
Resizing and filtering in an optimal way involves a lot more math than one could expect, so unless you have a Masters degree in Math, I'd advise not to tweak the resize options. (But note that it may be a good idea elsewhere: I've seen Adobe getting it wrong.)

I assumed that we are talking about photographic pictures, shots taken with a physical camera from the real world.
If it's something else, like line drawing or a 3D graphics scene, the "correct" resizing may not be what you need; There could be special ways to resize for some situations.



Syntax of argument for -resize geometry, from www.imagemagick.org:

size               General description (actual behavior can vary for different options and settings)

scale%             Height and width both scaled by specified percentage.
scale-x%xscale-y%  Height and width individually scaled by specified percentages. (Only one % symbol needed.)
width              Width given, height automagically selected to preserve aspect ratio.
xheight            Height given, width automagically selected to preserve aspect ratio.
widthxheight       Maximum values of height and width given, aspect ratio preserved.
widthxheight^      Minimum values of width and height given, aspect ratio preserved.
widthxheight!      Width and height emphatically given, original aspect ratio ignored.
widthxheight>      Shrinks an image with dimension(s) larger than the corresponding width and/or height argument(s).
widthxheight<      Enlarges an image with dimension(s) smaller than the corresponding width and/or height argument(s).
area@              Resize image to have specified area in pixels. Aspect ratio is preserved.
Volker Siegel
  • 17,283
1
convert -resize $((800/7))%

or

convert -resize 114.28571%

would do the resizing. As for controlling the image quality, you might want to check the -filter and -support options.

peterph
  • 30,838