Page 1 of 1

Using convert with -tile on transparent images

Posted: 2015-12-30T07:42:16-07:00
by fig
I am using this command:

Code: Select all

convert -size 585x559 tile:file -fill transparent -crop 585x559 ../finals/file.png
I am trying to tile smaller textures into a specific size. This is one of the texutres ill be using:
Image
And this is the output:
Image
Note the fact the first image has a slight blue tinge due to the backgroundof the forum post cause it's transparent. I tried both -background transparent and -fill transparent (which is there now) and had the same results.

What should i do?

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T09:26:29-07:00
by snibgo
What version of IM are you using? The image is grayscale, and grayscale changing tone suggest you are using an old version of IM, eg 6.7.7. This works fine on 6.9.2-5:

Code: Select all

convert -size 585x559 tile:JRagTr4.png x.png

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T10:22:16-07:00
by fig

Code: Select all

$ convert -version
Version: ImageMagick 6.9.2-10 Q16 x86_64 2015-12-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
I tried your code and got an identical result to the image posted before. The original was grayscale (it appears blue due to semitransparency blending in the background of the forum post).

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T10:32:33-07:00
by fmw42
convert -size 585x559 tile:file -fill transparent -crop 585x559 ../finals/file.png
What is tile:file? Is "file" to represent a specific filename (with suffix) that you fill in?

Why do you need the crop if the tiling is already the same size?

Perhaps you should provide the smaller tile that you are trying to tile to a larger size? Or have I misunderstood what you want to do?

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T10:43:22-07:00
by fmw42
Your image meta data (identify -verbose) shows a grayscalealpha image, but the PNG colortype says RGBA. I tried to reproduce that using IM 6.9.2.10 Q16 Mac OSX by

Code: Select all

convert -size 585x559 tile:JRagTr4.png -define png:color-type=6 -depth 8 x.png
But the result still looks lighter in color than the input image. I am not a PNG expert, so you may have to wait until the PNG developer checks this out.

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T11:06:24-07:00
by snibgo
I don't think it is a PNG problem. I suspect the "tile:" code doesn't handle alpha correctly.

Code: Select all

convert JRagTr4.png x1.tiff
convert -size 585x559 tile:x1.tiff x2.tiff
"identify" then tells me that x1.tiff has varying transparency but x2.tiff is fully opaque. It is also lighter.

A workaround would be to extract the alpha into a grayscale image, and make the input opaque. Then tile both the image and extracted alpha. Then "copy-opacity" the alpha back in.

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T13:58:48-07:00
by magick
The tile: coder composites the image tiles on a background. Use the -compose operator to affect the results, e.g. -compose copy.

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T14:27:41-07:00
by snibgo
Ah, yes, that's it, thanks. "identify" and Gimp confirm correct values.

@fig: So this should work:

Code: Select all

convert -size 585x559 -compose Copy tile:file -fill transparent -crop 585x559 ../finals/file.png

Re: Using convert with -tile on transparent images

Posted: 2015-12-30T15:24:20-07:00
by fmw42
magick wrote:The tile: coder composites the image tiles on a background. Use the -compose operator to affect the results, e.g. -compose copy.
OK, this work for me. Note, It needs to go before tile:, since it is a setting for tile:.

Code: Select all

convert -compose copy -size 512x512 tile:JRagTr4.png -define png:color-type=6 -depth 8 x.png
compare -metric rmse JRagTr4.png x.png null:
0 (0)

Re: Using convert with -tile on transparent images

Posted: 2015-12-31T01:38:14-07:00
by fig
Thank you! -compose copy worked like a charm and produces the right image!