Usage Tip: Specify a Canvas as a Single Argument

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Usage Tip: Specify a Canvas as a Single Argument

Post by anthony »

Many times you have a script (be it Fred's, or Snibgo's) that takes a base image as an argument.

For example a script that takes a input and output image and processes it in some magical way :-)

Code: Select all

   do_some_magick  input.png  output.png
Many times I ask it to display the result on screen without saving to a file

Code: Select all

   do_some_magick  input.png show:
But it has always been harder to just give a 'blank' input image to the script, requiring you to do things like...

Code: Select all

   convert -size 400x300 xc:Salmon miff:- | do_some_magick  miff:- show:
Or modify the script to generate a blank starting image.

Well here is a tip for you... Supply a blank canvas image of any size or color as a single argument....

Code: Select all

   do_some_magick  'xc:Salmon[400x300!]' show:
NOTE the '!' is important as you are basically resizing a base xc: image, and without it the input will be a square 300x300 pixels (or something else if -size is set where it gets inserted into the IM command in the script).

I added the canvas generation technique to IM Examples, Canvas page.

Enjoy :-)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply