Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert fails to allocate memory when opening a gimp 2.10 xcf image #1133

Closed
3 tasks done
mfinelli opened this issue May 18, 2018 · 12 comments
Closed
3 tasks done

convert fails to allocate memory when opening a gimp 2.10 xcf image #1133

mfinelli opened this issue May 18, 2018 · 12 comments

Comments

@mfinelli
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

It seems that either recent imagemagick or recent gimp updates leave the former unable to convert images from the latter. When trying to convert an xcf image to png or jpeg imagemagick crashes with a cannot allocate memory error.

Steps to Reproduce

  1. Create a new xcf image with GIMP 2.10 (I can provide one if needed)
  2. magick test.xcf test.png

Provides the following stacktrace

magick: memory allocation failed `test.xcf' @ error/xcf.c/ReadXCFImage/1336.
magick: no images for write '-write' 'test.png' at CLI arg 2 @ error/operation.c/CLINoImageOperator/4752.

System Configuration

$ magick -version
Version: ImageMagick 7.0.7-33 Q16 x86_64 2018-05-17 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP 
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
$ gimp -v
GNU Image Manipulation Program version 2.10.0
git-describe: GIMP_2_10_0
C compiler:
	Using built-in specs.
	COLLECT_GCC=gcc
	COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/8.1.0/lto-wrapper
	Target: x86_64-pc-linux-gnu
	Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp
	Thread model: posix
	gcc version 8.1.0 (GCC) 
	
using GEGL version 0.4.0 (compiled against version 0.4.0)
using GLib version 2.56.1 (compiled against version 2.56.1)
using GdkPixbuf version 2.36.12 (compiled against version 2.36.12)
using GTK+ version 2.24.32 (compiled against version 2.24.32)
using Pango version 1.42.1 (compiled against version 1.42.1)
using Fontconfig version 2.13.0 (compiled against version 2.13.0)
using Cairo version 1.15.12 (compiled against version 1.15.12)
$ uname -a
Linux stig 4.16.8-1-ARCH #1 SMP PREEMPT Wed May 9 11:25:02 UTC 2018 x86_64 GNU/Linux
@fmw42
Copy link

fmw42 commented May 18, 2018

I did the following. Took the lena.png image and opened in GIMP 2.8.20 and saved to lena.xcf.

I then tested with IM 7.0.7.32 Q16 HDRI Mac OSX Sierra and it works fine.

magick lena.xcf lena2.png

But it fails in IM 6.9.9.44 Q16 Mac OSX Sierra

convert lena.xcf lena2.png

convert: NotEnoughPixelData lena.xcf' @ error/xcf.c/ReadXCFImage/1395. convert: no images defined lena2.png' @ error/convert.c/ConvertImageCommand/3258.

I get the same results as above using IM 7.0.7.33 Q16 HDRI Mac OSX Sierra and IM 6.9.9.45 Q16 Mac OSX Sierra.

@mfinelli
Copy link
Author

I believe the issue results from xcf images saved with the new version of GIMP (2.10). I have converted images using imagemagick made with GIMP 2.8.x in the past without issue. I can provide a test image made with GIMP 2.10 if that would be helpful.

@fmw42
Copy link

fmw42 commented May 18, 2018

@mfinelli

That does not explain the fact that the conversion fails for me on IM 6, but works for IM 7. Your issue may be a completely different one and also valid.

Your issue sounds like it could be an xcf format change.

urban-warrior pushed a commit to ImageMagick/ImageMagick6 that referenced this issue May 19, 2018
@urban-warrior
Copy link
Member

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

Post a URL to a XCF image file from Gimp 2.10. We're still running 2.8.

@urban-warrior
Copy link
Member

It looks like the XCF format has changed for Gimp 2.10. If this is documented somewhere (version 11), post the link here. We'll need to patch the XCF coder to account for these changes. Even Gimp 2.8 cannot read test.xcf.

@mfinelli
Copy link
Author

I believe that this is what you're looking for: https://git.gnome.org/browse/gimp/tree/devel-docs/xcf.txt though afaict it doesn't spell out the differences between versions. If this isn't helpful, please let me know and I will keeping digging for more information.

@bors-ltd
Copy link

Hello,
I think I may be hit by the same bug, using this file: https://gist.github.com/bors-ltd/06e3990618be1fc6a6a888e9ddc478da/raw/1555195ea1d6fa02a49e249f2e8d2eb209f3924d/201712.xcf

$ convert -compress JPEG 201712.xcf 201712.pdf
convert: memory allocation failed `201712.xcf' @ error/xcf.c/ReadXCFImage/1341.
convert: no images defined `201712.pdf' @ error/convert.c/ConvertImageCommand/3275.
make: *** [Makefile:4: 201712.pdf] Error 1

I also thought about some difference with Gimp 2.10, so I opened a file produced by Gimp 2.8, and save it again. But convert could process it just fine.

Do you confirm it's the same bug or should I open another issue?

$ convert -version
Version: ImageMagick 7.0.7-39 Q16 x86_64 2018-06-11 https://www.imagemagick.org
Copyright: © 1999-2018 ImageMagick Studio LLC
License: https://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP 
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib

@ChrisJAllan
Copy link
Contributor

ChrisJAllan commented Jul 5, 2018

A relevant change might be the pointer size changing from 4 bytes to 8 in XCF 11.

From https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt

Since GIMP 2.10.0, released on 2018-04-27.
Adds many layer modes, layer group masks, high-bit depth (precisions
other than 8-bit gamma), zlib compression and 64-bit offsets for XCF
files bigger than 4GB.

A POINTER is stored as a 32-bit integer (4 bytes) in big-endian order
for XCF up to 10, and 64-bit (8 bytes), still big-endian, for XCF 11
and over, allowing higher than 4GB XCF files since GIMP 2.10.0.

@emanuelserpa
Copy link

emanuelserpa commented Jul 21, 2018

It's incredible how this work of you guys is important. I was trying to convert my XCF files to PNG yesterday in a random site and an error ocurred, and now I'm here.

Thank you for this project, and I hope this get fixed soon.

@v1993
Copy link

v1993 commented Nov 1, 2018

Is there any progress on it? On ubuntu 18.10:

v@v-xubuntu:~$ convert icon.xcf i.png
convert-im6.q16: memory allocation failed `icon.xcf' @ error/xcf.c/ReadXCFImage/1352.
convert-im6.q16: no images defined `i.png' @ error/convert.c/ConvertImageCommand/3258.

@dlemstra
Copy link
Member

dlemstra commented Nov 1, 2018

@v1993 I added the up for grabs label so someone can help us add support for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

8 participants