how to convert height and width by percentage separately

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
incendie22
Posts: 3
Joined: 2017-01-11T17:54:54-07:00
Authentication code: 1151

how to convert height and width by percentage separately

Post by incendie22 »

So I have an a lot of images with different height and width. I want to resize the image by percentage, with height at a different percentage and width at a different percentage.

So an image of 200 x 100 pixel i want to convert it by 50% height and 30% width. how would I do that with imagemagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to convert height and width by percentage separately

Post by fmw42 »

I have moved this message here from Fred's Scripts, since it has nothing to do with my script.

Please always provide your IM version and platform, since syntax may vary.

Code: Select all

convert image -resize 50%x30% resultimage
If on IM 7 use "magick" rather than "convert"

If you want to process multiple images in one folder all at one time, then use mogrify or magick mogrify. See http://www.imagemagick.org/Usage/basics/#mogrify
incendie22
Posts: 3
Joined: 2017-01-11T17:54:54-07:00
Authentication code: 1151

Re: how to convert height and width by percentage separately

Post by incendie22 »

doesn't work. the result image is 50x25. it didn't even register the 30% width.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to convert height and width by percentage separately

Post by snibgo »

You should tell us the IM version you are using, and the platform.

For example, if your code is in a Windows BAT file, "%" has a special meaning (about script parameters). When you don't want that special meaning, you need to double them:

Code: Select all

50%%x30%%
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: how to convert height and width by percentage separately

Post by fmw42 »

What was your exact command line and your IM version and platform? As I said above, syntax may differ. Did you enter your image in the command as imagename.suffix?

What do you get from

Code: Select all

convert -version
That will tell us your IM version and your delegates.
incendie22
Posts: 3
Joined: 2017-01-11T17:54:54-07:00
Authentication code: 1151

Re: how to convert height and width by percentage separately

Post by incendie22 »

Double %% works. Thank you very much.
Post Reply