How to center an image in a fixed canvas?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Rule

How to center an image in a fixed canvas?

Post by Rule »

Hello,

Can somebody tell me how I can resize from an image to a smaller version, but really have the actual given size?
This illustrates my problem:
image 800*600
resize 400*400 --> image 400*300
--> I would like to place the image 50 pixels lower


Regards,
Roel
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How to center an image in a fixed canvas?

Post by fmw42 »

Please post questions of this nature next time to the Users forum not the Developers forum.


Unfortunately, I do not understand what you are trying to do.

What do you mean by "really have the actual given size"?

The syntax for resizing is:

If you have an 800x600 image and want it to be 400x300, then
convert image_800_400.png -resize 400x300 image_400_300.png
or
convert image_800_400.png -resize 50% image_400_300.png

If you want it to be 400x400, then

convert image_800_400.png -resize 400x400! image_400_400.png


I am not sure what you mean by "place it 50 pixels lower"? What is it relative to ? What background?

You can pad it with a border. See http://www.imagemagick.org/Usage/crop/#border
You can extend it. See http://www.imagemagick.org/Usage/crop/#extent
You can splice in rows. See http://www.imagemagick.org/Usage/crop/#splice

If you can clarify these two points for me, then perhaps I can help your further.
Rule

Re: How to center an image in a fixed canvas?

Post by Rule »

Thx for all help!

I solved the problem with -repage 400*400+0+50...


Friendly regards,
Roel
Post Reply