Page 1 of 1

Thumbnailing of XCF files

Posted: 2012-03-30T13:45:33-07:00
by hexmode
We (Wikimedia) use ImageMagick to convert images to smaller sizes for thumbnails on Commons. We recently added support for Gimp's XCF format and have been relying on convert to take care of the thumbnailing. See https://bugzilla.wikimedia.org/17959 for a bit of that saga.

I've now filed https://bugzilla.wikimedia.org/35622 to request that thumbnailing of XCF be improved. Could you guys take charge of that?

Re: Thumbnailing of XCF files

Posted: 2012-03-30T15:43:02-07:00
by fmw42
Pardon me for sticking my nose it, but as an interested viewer and for the benefit of the IM developers, could you post a link to the original xcf and good and bad versions of the thumbnail conversion to png with your command line and with the IM version and platform used. That way others can test and this will help the IM developers to understand the issue better. I am also confused, as the title of one of your links in the referenced document says XCF, but the image shown is really png and it does not even match the image shown in the other document.

Re: Thumbnailing of XCF files

Posted: 2012-03-30T18:42:35-07:00
by hexmode
fmw42 wrote:could you post a link to the original xcf and good and bad versions of the thumbnail conversion to png with your command line and with the IM version and platform used?
  • File page (contains the following links and images)
  • Direct link to XCF file
  • How ImageMagick converts the XCF file to PNG: Image
  • How Gimp saves the XCF file as a PNG: Image
We'd like to get closer to what Gimp does.

Debug log on my local machine (which produces identical thumbnails) shows MediaWiki is calling convert like this:

/usr/bin/convert -background white file.xcf'' -thumbnail '111x107!' -set comment 'File source: url_to_xcf' -depth 8 -rotate -0 -layers merge transform.png

output from "convert --version" on my local machine:

Version: ImageMagick 6.6.0-4 2011-06-15 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

But I'm running Ubuntu Oneric and the Wikimedia servers are running Lucid, so they're probably running a different version. The WMF Labs servers (which use the same packages as production have the following output:

Version: ImageMagick 6.6.2-6 2011-03-09 Q8 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features:

Re: Thumbnailing of XCF files

Posted: 2012-03-30T19:12:12-07:00
by fmw42
When I examine your image in IM and flatten it,

convert 1test.xcf -background transparent -flatten 1test.png

(For simplicity I renamed your image to 1test.xcf)

Note you should be using -background transparent and not white. Your -layers merge and my -flatten should be doing about the same, so it should not matter which you use in your case. Also your -rotate 0 is not doing anything, but should not hurt. I presume you have an option to rotate the image and this happens to be one case where you are not.

Image

I get an image similar to what you have for your version of IM, but the lightbulb is the same size as the one in the GIMP png. I am not sure why your lightbulb gets enlarged. I think that is perhaps due to your version of IM, which is over 140 versions old.

More importantly, though I know little about gimp xcf format, this gimp image is rather strange. First, it seems to have two layers each with its own transparency. However, when I look at the channels, I see it has red, green and blue and alpha. However, the red and green appear to have the star and circle around it (with transparency outside the circle showing as black), and the blue has just the lightbulb (with transparency around it showing as black). The alpha channel has the cutout for removing the circle and leaving the star shape with the bottom of the lightbulb. But it appears that IM is just seeing the two layers with their transparency and not the overall alpha channel. This is likely due to the fact that currently IM can only handle one alpha channel per image/layer.

In this case, if IM were to extract this as one layer, from the r,g,b channels and the overall alpha channel, it might be converted to png properly. But that is only my assessment and certainly would require a code change and probably would not be compatible with the standard kinds of xcf images that do not have such odd structure.


Perhaps the IM developers can analyze the xcf image better than I. So I will defer to them.

Re: Thumbnailing of XCF files

Posted: 2012-04-01T08:39:43-07:00
by magick
We can reproduce the problem you reported and have a patch. Look for it in the ImageMagick-6.7.6-4 release within a day or two. Thanks.

Re: Thumbnailing of XCF files

Posted: 2012-04-02T14:10:36-07:00
by hexmode
Some more tests for the patch.

This file, for example, which turns into Image should look like Image.

This map is interesting since it just becomes a white image, but should have the black lines of the map: Image. It is interesting because the XCF source has one layer with color.

Re: Thumbnailing of XCF files

Posted: 2012-04-02T16:48:21-07:00
by magick
We can reproduce the problem you reported and have a patch. Look for it in the ImageMagick-6.7.6-4 release within a day or two. Thanks.

Note, the correct conversion is:
  • convert Blason_Saint-Malo.xcf -background transparent -flatten x:

Re: Thumbnailing of XCF files

Posted: 2012-04-03T14:50:32-07:00
by hexmode
magick wrote:Note, the correct conversion is:
  • convert Blason_Saint-Malo.xcf -background transparent -flatten x:
Thanks, I'll try to get that committed.

Re: Thumbnailing of XCF files

Posted: 2012-04-03T18:43:16-07:00
by anthony
I can confirm that that specific XCF file is now 'flattening' correctly.

Just be sure that you do not set a global -compose setting before the -flatten operation, as this will likely override individual layer image compose settings.