Command-line image manipulation

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
sect0id

Command-line image manipulation

Post by sect0id »

I currently use this for shrinking image.png to a smaller dimension of 110x120.
convert -resize '110x120!' image.png test2.png

How would I overlay test2.png onto the center of a transparent 128x128 image or increase test2.png's dimensions to 128x128, while keeping its original dimensions and having it centered, with a transparent background?

Not necessary to have this integrated into the command above but would be preferable. :D
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Command-line image manipulation

Post by el_supremo »

This should do it.

Code: Select all

convert image.png -resize "110x120!" -size 128x128 xc:none +swap -gravity center -composite test2.png
Pete
sect0id

Re: Command-line image manipulation

Post by sect0id »

Aside from having to swap " for ' that works great, thanks :D
sect0id

Re: Command-line image manipulation

Post by sect0id »

Does ImageMagick support file piping to/from the convert command? (to eliminate the need for a temp file)
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Command-line image manipulation

Post by magick »

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Command-line image manipulation

Post by anthony »

More specifically the second section on "File Handling" Reading and saving.

Code: Select all

    type:-
will read or write to stdin/stdout an image of the type given. When reading the type can usally be skipped as IM can usally figure it out on the fly.

Code: Select all

   convert .....  miff:- | display - 
is actually quite a common command to display rather than save the results of a command.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply