qubodup
qubodup

Reputation: 9603

Create blank image in Imagemagick

How to create a blank new image in Imagemagick via command line?

Using -background doesn't work:

$ convert -size 800x800 -background white x.png
convert: no images defined `x.png' @ error/convert.c/ConvertImageCommand/3257.

Upvotes: 59

Views: 42196

Answers (2)

cjonasw
cjonasw

Reputation: 538

You need to supply PNG24, PNG8 or PNG32 prefix if planning to use this canvas to layer colour images over. Without it, it creates a Grey colour space. I used 32, as I need "varying degrees of transparency for each pixel" (pixel art)

convert -size 800x800 canvas:transparent PNG32:canvas.png

For more about PNG types see this link.

Upvotes: 13

qubodup
qubodup

Reputation: 9603

White background

convert -size 800x800 xc:white white.png

xc: used to mean "X Constant Image" but now is just a shorthand for canvas:. This means you can also use:

convert -size 800x800 canvas:white white.png

and because "white" is the default value if no color is provided, you can also use:

convert -size 800x800 xc: white.png
convert -size 800x800 canvas: white.png

Transparent background

If by "blank" you mean "transparent", just use that word as the color:

convert -size 800x800 xc:transparent transparent.png

Answer made possible by ImageMagick v6 Examples and How to create a new image?

Upvotes: 89

Related Questions