Page MenuHomePhabricator

Inline rendering/thumbnailing for Gimp XCF images
Closed, ResolvedPublic

Description

Some images on Wikipedia/Commons/etc have been uploaded in Gimp's XCF format; as a work format this is pretty good since it supports multiple layers, editable text, various effects etc -- and Gimp is free software, so anyone can download it and edit the source file.

However, we don't currently support in-wiki rendering of the XCF files, so you need to separately upload a flattened PNG or JPEG file.

To save this extra manual step and simplify the workflow, XCF images could be rendered by shelling out to Gimp, or with alternate loaders such as this GdkPixBuf loader: http://blog.reblochon.org/2009/03/gift-to-competition.html


Version: unspecified
Severity: enhancement
URL: http://commons.wikimedia.org/wiki/File:Wikiball.xcf

Details

Reference
bz17959

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:31 PM
bzimport set Reference to bz17959.
bzimport added a subscriber: Unknown Object (MLST).

ahmad.m.sherif wrote:

proposed patch

This patch may help. It uses one of xcftools software, xcf2png, which works only on linux and unix-like systems.

attachment xcf.patch ignored as obsolete

Looks like this package:
http://henning.makholm.net/xcftools/

Good news:

  • xcftools package is included in Debian and Ubuntu -- would be easy to deploy to image scaler boxes!

Bad news:

  • Site's down and last release seems to be in 2006; unmaintained software? :(
  • xcf2png does not appear to do scaling itself. The attached patch does post-scaling with GD, which will fail when GD is not available; it also seems to be rendering to stdout and buffering the whole thing into PHP-managed memory, making it more likely to fail on large images.

If we can't skip the step on scaling, might be safer to output to a temporary file and then scale that, potentially with ImageMagick or whatever the default for rasters is.

I haven't done any testing yet to confirm compatibility on xcf2png.

ahmad.m.sherif wrote:

another patch and a python script

Bad news:

  • Site's down and last release seems to be in 2006; unmaintained software? :(
  • xcf2png does not appear to do scaling itself. The attached patch does

post-scaling with GD, which will fail when GD is not available; it also seems
to be rendering to stdout and buffering the whole thing into PHP-managed
memory, making it more likely to fail on large images.

So we can use the Pixbuf loader mentioned above in association with a simple script (e.g. python with gdk bindings) to eliminate this problem.

Good news:

  • xcftools package is included in Debian and Ubuntu -- would be easy to deploy

to image scaler boxes!

It's easy to deploy this loader but not as easy as xcftools :). i think that this loader may help doing the work under windows too.

attachment xcf.zip ignored as obsolete

mike.lifeguard+bugs wrote:

Could you please attach the patch separately from anything else? Otherwise, we cannot view it on bugzilla.

ahmad.m.sherif wrote:

the patch

attachment xcf2.patch ignored as obsolete

ahmad.m.sherif wrote:

python script to interact with pixbuf loader

Attached:

ahmad.m.sherif wrote:

adding a missing line

Adding a missing line wasn't in the first patch.

Attached:

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Ahmad, thank you for your patches, and my apologies on the late response. I've added the "need-review" keyword to indicate that developers should review your code.

Comment on attachment 5946
python script to interact with pixbuf loader

To start with, an XCFHandler, should probably be an extension and not in core (but that's really a trivial change, and not a major issue with the patch).

(also changing mime type on python file so that hopefully it is not forced-download)

Check out https://en.wikipedia.org/wiki/File:%22What_a_Brilliant_Idea!%22_Barnstar.xcf for an example file. (Found this while investigating another bug.)

ImageMagick will work with this. I have a bit of work done that will work with convert.

Sounds like we need two things:

  • a PHP-native 'getimagesize' implementation for XcfHandler to extract the width/height of the contained image from the file header
  • wrappers for calling ImageMagick's convert and/or the gdkpixbuf loader to generate scaled PNGs

Mark, can you post what you have on the bug or check in an initial XcfHandler extension? This'd be handy to have. :)

Created attachment 9764
Rendering of File:%22What_a_Brilliant_Idea!%22_Barnstar.xcf with ImageMagick vs GIMP

(In reply to comment #11)

Check out
https://en.wikipedia.org/wiki/File:%22What_a_Brilliant_Idea!%22_Barnstar.xcf
for an example file. (Found this while investigating another bug.)

ImageMagick will work with this. I have a bit of work done that will work with
convert.

Perhaps my version of ImageMagick is outdatated, but it seems not to support lots of the features of GIMP. See screenshot. OTOH, arguably it might be better to have crappy thumbnailing than no thumbnailing.

Relevant versions:

bawolff@Bawolff-L:~$ gimp --version
GNU Image Manipulation Program version 2.6.10

bawolff@Bawolff-L:~$ display --version
Version: ImageMagick 6.6.0-4 2010-11-16 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Attached:

image_magick_vs_gimp.png (324×864 px, 75 KB)

r107351

(In reply to comment #12)

  • a PHP-native 'getimagesize' implementation for XcfHandler to extract the

width/height of the contained image from the file header

I leave that to someone else. I was lazy and use ImageMagick's identify :P

  • wrappers for calling ImageMagick's convert and/or the gdkpixbuf loader to

generate scaled PNGs

Bawolff is right. ImageMagick's support for XCF is buggy. Still what I committed is a start. Maybe use gimp and the stdin script from

http://stackoverflow.com/questions/5794640/how-to-convert-xcf-to-png-using-gimp-from-the-command-line

identify was replaced with a 100% PHP implementation with r108141.

Should we consider this bug as fixed ? :)

After talking to people on Commons, doing some sort of thumbnailing for XCF is a start, even with the buggy ImageMagick implementation. Since hashar replaced identify in r108141, we should now start working with the ImageMagick community to improve the thumbnailing.

http://commons.wikimedia.beta.wmflabs.org/wiki/File:Tmp4.xcf -- reopening since the main image on the page should have some sort of displayable version like the pdf thumbnails do.

File history is fine, though.

(In reply to comment #18)

Looks fine to me?

Oh nevermind, i see this was fixed in r107351 by the time i looked at link.

(In reply to comment #17)

the main image on the page should have some sort of displayable version like
the pdf thumbnails do.

Had to force rendering since browsers can not render XCF :-)
r108862

Thanks Bawolff for cross checking.

(In reply to comment #16)

After talking to people on Commons, doing some sort of thumbnailing for XCF is
a start, even with the buggy ImageMagick implementation. Since hashar replaced
identify in r108141, we should now start working with the ImageMagick community
to improve the thumbnailing.

Thumbnailing should really be improved. There are some major flaws:
*Grey scale XCF-files become green ( http://commons.wikimedia.org/wiki/File:Australian_English_IPA_vowel_chart.xcf )
*XCF-files with layers get screwed up generally ( http://commons.wikimedia.org/wiki/File:Gimp_layer_mode_test.xcf )

(In reply to comment #21)

Thumbnailing should really be improved.

This issue is tracked on Bug 35622