Thumbnailing of XCF files

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

Thumbnailing of XCF files

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnailing of XCF files

Post 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.
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

Re: Thumbnailing of XCF files

Post 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:
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Thumbnailing of XCF files

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Thumbnailing of XCF files

Post 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.
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

Re: Thumbnailing of XCF files

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Thumbnailing of XCF files

Post 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:
hexmode
Posts: 13
Joined: 2012-03-30T13:01:12-07:00
Authentication code: 8675308

Re: Thumbnailing of XCF files

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

Re: Thumbnailing of XCF files

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply