After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 121871 - Saving large PSD's make the psd plugin crash.
Saving large PSD's make the psd plugin crash.
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
1.x
Other All
: Low normal
: Future
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2003-09-10 00:20 UTC by cam
Modified: 2005-03-02 07:36 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description cam 2003-09-10 00:20:08 UTC
To reproduce the bug-
make an image that is over 500meg & white canvas
Save the image as a PSD

Will think for ages and create a large file foobar.psd but the plugin
crashes just at the end.

gives message 

"Plugin crashed... mesed up internal state. etc."

This does not happen when saving in other formats- XCF/PNG I have used instead.

Photoshop loads 90% of the PSD then complains about invalid on of  file.
Comment 1 Sven Neumann 2003-09-10 00:44:11 UTC
I tried this and, not surprisingly, the PSD plug-in dies out-of-memory:

 failed to allocate 78643200 bytes

The GIMP core can handle a large image like this but the PSD plug-in
seems to attempt to load the complete image into memory once more and
dies.
Comment 2 Maurits Rijk 2003-09-11 07:40:20 UTC
There are a few more plug-ins that get a complete copy of the image
instead of working for example tile-based. These are all likely to
fail on large images. I will make a list of these plug-ins.
Comment 3 Sven Neumann 2003-09-11 17:06:44 UTC
Such plug-ins should at least make use of g_try_malloc() and quit more
gracefully after informing the user what went wrong
Comment 4 Maurits Rijk 2003-09-16 14:25:56 UTC
Following plug-ins are likely to fail on large images:

./bmp/bmpwrite.c
./common/animationplay.c
./common/apply_lens.c
./common/gif.c
./common/hot.c
./common/jigsaw.c
./common/papertile.c
./common/pcx.c
./common/psd_save.c
./common/waves.c
./flame/flame.c

From this list only psd_save.c and gif.c have some priority to fix.
It's unlikely that anyone will ever try to save a huge image in bmp
format. For these plug-ins g_try_malloc, like Sven suggests, should be
sufficient.
Comment 5 Adam D. Moss 2003-09-16 14:42:11 UTC
Wow, I'd forgotten that the GIF plugin slurps an image layer into a
flat array.  That was probably done to make catering for the
interlaced access pattern a no-brainer.  Could still just grab a
line at a time though.

Not scary to fix, just obtrusive and dull.  (Still, GIF is totally
designed for images meant for on-screen viewing on generic consumer
devices, unlike, say, XCF or TIFF.  That is to say that anyone saving
an image which is big enough when non-tiled to upset a desktop system
powerful enough to run GIMP, is going to have interoperability trouble
for that image size anyway.)
Comment 6 Dave Neary 2003-09-16 15:30:42 UTC
Maurits said:
> It's unlikely that anyone will ever try to save a huge image in 
> bmp format.

Actually, someone reported this in the newsgroup recently
(news:comp.graphics.apps.gimp). I asked him to report it here, he
hasn't yet. 

A reference to google groups: 
http://groups.google.fr/groups?dq=&hl=fr&lr=&ie=UTF-8&threadm=slrnblsfkq.4nb.real.addressinthesig%40bolsh.free.fr&prev=/groups%3Fhl%3Dfr%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.graphics.apps.gimp

Funnily enough, this is the same person who recently said he was
prepared to fund certain feature additions to the GIMP. I wrote asking
for more details, and received no reply yet.

Cheers,
Dave.
Comment 7 Maurits Rijk 2003-09-17 10:25:33 UTC
Two things about the PSD save plug-in:

1) It would probably already help if the data that is allocated
(inside a loop for each channel) would also be freed. This plug-in is
full of mem leaks.

2) It's easy to rewrite the plug-in in such a way that it saves on a
row per row basis. Only catch is that it first calculates the total
size of the compressed data. Based on this size it decides to write
either compressed or raw data. One possible solution is to iterate
over the image data (row per row), calculate it's compressed size, and
iterate once more over the data to write it. Another possible solution
would be to start assuming that data can always be compressed. Based
on this assumption the data is written and the compression table is
written thereafter. In the unlikely case that the image couldn't be
compressed we write it again, this time as raw data.
Comment 8 Dave Neary 2003-09-17 12:54:02 UTC
Another possible solution (my favoured solution, I think) is to write
an imagemagick plug-in, and delegate file loading & saving for a
number of formats to them. They already have routines to load & save
xcfs - so I assume their internal image structures are complete enough
to handle a psd load. They seem to be pretty feature complete in this
department last time I looked.

Of course, it's unlikely this will get in for 2.0, but I would like to
see this done for 2.2

Dave.
Comment 9 Maurits Rijk 2003-09-18 10:03:11 UTC
I like the idea of using Imagemagick for some file formats, but I'm
not sure this would work for writing psd files. Afaik you can only
write flattened images via the Imagemagick API. You will lose info
about layers, etc. Same problem the other way around: you can use
Imagemagick to import a psd file, but you get a flat image without the
layers. I could be wrong of course, but this is what I remember from
having looked at the API couple of years ago.

We could use this delegation idea for example to export/import WBMP
files or WMF (ImageMagick uses libwmf. This is far superior to the WMF
plug-in we have in Gimp).
Comment 10 Henrik Brix Andersen 2003-09-18 10:09:43 UTC
Wouldn't it be better to adopt our own WBMP/WMF plug-ins to use libwmf?
Comment 11 Sven Neumann 2003-09-18 11:03:08 UTC
The wmf import plug-in that comes with libwmf2 is scheduled for
inclusion before 2.0. Someone just needs to add the configure check
and replace the current plug-in with it.
Comment 12 Dave Neary 2003-09-18 14:01:45 UTC
Of course, something that Works Now is better than nothing (or better
that the existing plug-in). It would be nice to avoid duplication of
effort with ImageMagick for a number of plug-ins, and perhaps get some
closer co-operation between the teams on supporting new formats. 

As I recall, ImageMagick handles loading of layered images, including
layer modes, so perhaps we could get a generic Image to GimpImage
conversion routine, and vice versa, included in either the GIMP or
ImageMagick to allow us to access their internal image structure natively.

Cheers,
Dave.
Comment 13 Raphaël Quinet 2003-09-18 14:28:57 UTC
I disagree: although ImageMagick is nice, I do not install it on most
of the systems that I maintain.  I would not like to be forced to
install yet another set of programs (and their dependencies) in order
to be able to perform some operations that could be done by a
self-contained plug-in.  Code duplication is a bad, but too many
dependencies is also bad.  I would prefer to avoid any dependencies on
ImageMagick.  In fact, I hope that the GUI-less version of the GIMP
would be able to replace it for most common tasks.
Comment 14 Dave Neary 2003-09-18 15:46:29 UTC
It is of course possible to have ImageMagick stuff build optionally. 
It would also be reasonable to keep the older standalone plug-ins 
alive. But if IM is more actively maintained than our plug-ins, and 
of a higher quality to boot, I think that the old plug-ins would 
naturally go away. At the very least, I don't think they will evolve. 

It makes a lot of sense to me to integrate a third party program 
which does parts of what we do, only better.

Cheers,
Dave.
Comment 15 Maurits Rijk 2003-09-23 07:17:10 UTC
In my opinion IM should be used as a fallback option for loading
images, since it supports more formats (like for example WBMP) than
Gimp does. Of course the important formats will always be supported by
the native gimp plug-ins. As Dave states, the big advantage of IM is
that it's very well maintained. It also comes standard with all
distros, afaik.

I propose to make this (provide an IM loader plug-in) a separate
enhcancement request and concentrate on solving the orinal bug first.
Comment 16 Dave Neary 2004-03-10 10:48:39 UTC
Bumping a bunch of bugs which won't block the 2.0 release to 2.0.1.

Dave.
Comment 17 Michael Natterer 2004-04-06 21:56:53 UTC
Doesn't block 2.0.1 either.
Comment 18 Adam D. Moss 2004-04-06 22:09:08 UTC
Un-CC:ing myself, if anything specific to me turns up then feel free to CC: me
again...
Comment 19 Sven Neumann 2004-06-15 15:39:13 UTC
Bumping to milestone 2.2.
Comment 20 Sven Neumann 2004-10-06 13:03:19 UTC
Bumping off the 2.2 milestone since noone seems to be working on this.
Comment 21 Jay Cox 2005-02-13 22:33:47 UTC
I just checked a fix for this bug (and 167139) into CVS.  Should it be
backported to the 2.2 stable version?
Comment 22 Jay Cox 2005-03-02 07:35:50 UTC
Back ported to the 2.2 stable branch.  Closing bug.