How can I add a Background Tile to a transparent Image?

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
chris-at
Posts: 2
Joined: 2013-11-12T00:50:07-07:00
Authentication code: 6789

How can I add a Background Tile to a transparent Image?

Post by chris-at »

I want to add a tiled background to a transparent image.

According to the docs this should do it:

Code: Select all

convert test.png -texture paper.png result.png
I also tried other variations (with -composite, -flatten, -tile, etc.) but result.png is either still transparent or just gets a white background.

ImageMagick-6.8.7-5 on Windows.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can I add a Background Tile to a transparent Image?

Post by snibgo »

I think texture is just for the display program.

To make an image say 600x400 pixels containing paper.png tiled:

Code: Select all

convert -size 600x400 tile:paper.png result.png
See http://www.imagemagick.org/Usage/canvas/#tile
snibgo's IM pages: im.snibgo.com
chris-at
Posts: 2
Joined: 2013-11-12T00:50:07-07:00
Authentication code: 6789

Re: How can I add a Background Tile to a transparent Image?

Post by chris-at »

Thank you, I got it working with:

Code: Select all

convert -size 4096x4096 tile:paper.png test.png -flatten result.png 
But is it possible to take the size from test.png instead?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can I add a Background Tile to a transparent Image?

Post by snibgo »

Code: Select all

convert test.png -tile paper.png -draw "color 0,0 reset" result.png
snibgo's IM pages: im.snibgo.com
Post Reply