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 448181 - New PSD load plug-in
New PSD load plug-in
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal enhancement
: 2.6
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 72344 102910 151686 158234 303339 309141 336440
 
 
Reported: 2007-06-16 11:53 UTC by John Marshall
Modified: 2008-04-07 13:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Psd plug-in source (43.96 KB, application/octet-stream)
2007-06-16 11:55 UTC, John Marshall
  Details
Psd plug-in source (51.71 KB, application/octet-stream)
2007-08-29 21:34 UTC, John Marshall
  Details
Psd plug-in source (47.07 KB, application/octet-stream)
2007-12-13 22:10 UTC, John Marshall
  Details
Psd plug-in makefile patch (657 bytes, patch)
2007-12-13 22:12 UTC, John Marshall
committed Details | Review
bzipped tar of psd source, slightly modified (110.03 KB, application/x-bzip)
2007-12-14 00:17 UTC, weskaggs
  Details
bzipped tar of psd source, slightly modified some more (30.42 KB, application/x-bzip2)
2007-12-14 17:47 UTC, John Marshall
  Details
psd plug-in error handling clean-up. (155.65 KB, patch)
2008-01-07 14:14 UTC, John Marshall
committed Details | Review

Description John Marshall 2007-06-16 11:53:42 UTC
I have created a new plug-in to load photoshop PSD files. It should do all that the current plug-in does plus:

Support for ICC colour profiles.
Load 16 bit data files (down-sampled to 8 bits).
Load image data from duotone files (toning information not loaded).
Load saved paths.
Load XMP data as XMP parasite (as TIFF load).
Load exif data as parasite (as JPEG load).
Improved layer mask handling.
Load Unicode alpha-channel names where they exist.
Comment 1 John Marshall 2007-06-16 11:55:50 UTC
Created attachment 90059 [details]
Psd plug-in source
Comment 2 Sven Neumann 2007-06-16 13:00:18 UTC
What is the reason for writing a new plug-in instead of improving the existing one? Is this based on the old plug-in or is it really a rewrite from scratch? Does it incorporate the many bug-fixes and improvements that have gone into the PSD plug-in lately?
Comment 3 John Marshall 2007-06-16 13:15:16 UTC
My original intention was to improve the existing one but after looking at for some time I considered that it had become unmanageable and would be extremely difficult to work on (for me at least).  The new plug-in really is written from scratch using the latest publicly available version of the file specs (V6). The style was in fact initially loosly based on the PSP plug-in. I have followed the changes that have been made to the current plug-in and the only one that has not been applied is the Unicode layer name patch that went in a couple of days ago (which does not work on windows by the way).  I believe that the new plug-in has all of the features of the existing one in addition to the new ones and the code is now much clearer and will be easier to extend and to port to GEGL when that is incorporated into GIMP.
Comment 4 Sven Neumann 2007-06-16 14:02:50 UTC
It is a lot more work to review a complete rewrite. We can't accept this code without review, in particular not now as we are close to a stable release. So let's confirm this bug and hope that someone finds the time to review it for GIMP 2.6.
Comment 5 Eric Ross 2007-06-17 01:47:30 UTC
What about the unicode layer name patch doesn't work on Windows? Please post more details about the problem and a sample psd that exhibits the problem to bug #445316 so that I can fix it.
Comment 6 Sven Neumann 2007-07-13 07:12:53 UTC
A few comments on the code:

- Please make sure that you incorporate the recent changes that validate the input to avoid buffer overflows and other vulnerabilities.

- Please do only use g_warning() for programming errors, not to warn about invalid input. In most cases you will want to use g_message() here to bring up a user-visible message dialog.

- Please rename your files to use hyphens instead of underscores.
Comment 7 John Marshall 2007-08-29 21:34:50 UTC
Created attachment 94575 [details]
Psd plug-in source

An updated version of the PSD plug-in source including:

- Buffer overflow checks as requested.
- g_warning() has been replaced with g_message() throughout.
- source file names use hyphens instead of underscores.
- Better EXIF and XMP handling.
- Initial thumbnail loading code.
- Various memory leaks and bugs fixed.
Comment 8 Michael Schumacher 2007-09-05 15:50:02 UTC
IMO we should mark some (all?) of the other PSD-related bugs as depending on this one.
Comment 9 weskaggs 2007-12-05 01:27:20 UTC
Hi John,

  Given that PSD is one of the most important formats (in the sense that
many users have PSD files that they would like to be able to open), can you
give us a sense of the extent to which you'll be able to maintain this
plug-in?  That is, how vigorously will you be able to respond to bug
reports and/or changes in the format?  It would be a huge gain over
the current situation to have a PSD plug-in that works for current 
PSD files and is actively maintained for some reasonable period of
time.  If you can give a satisfactory answer to this question, I'll
push strongly for getting your plug-in into svn -- and now would be
the time to do it.
Comment 10 John Marshall 2007-12-05 23:15:13 UTC
Hi,

I would hope to be able to at least look at bugs within the week and it is my intention to maintain this plug-in for the forseable future. 
My intention is to add support for PSD features as they become available in GIMP and to add support for new PSD functionality as we figure out how it works!
I would like to hold off on getting the plug-in into svn for a week or two until I finish testing my current version after that I would be delighted to see it get a wider airing.
Comment 11 John Marshall 2007-12-13 22:09:51 UTC
I have created the updated version of the plug-in source and a patch for the configure/make files.  In addition the psd-load.c source file would need to be removed from plug-ins/common.
Comment 12 John Marshall 2007-12-13 22:10:27 UTC
Created attachment 100909 [details]
Psd plug-in source
Comment 13 John Marshall 2007-12-13 22:12:17 UTC
Created attachment 100910 [details] [review]
Psd plug-in makefile patch
Comment 14 weskaggs 2007-12-14 00:16:35 UTC
With a couple of minor tweaks (a couple of unused argument warnings, and a warning about an uninitialized variable that was caused by an obvious typo in the code), I built this without much difficulty.  I tested it on a couple of rather complex PSD files, and it loaded them successfully.  It tends to generate a lot of warnings about things that aren't fully supported, which will probably have to be tidied up a bit.  I also renamed two of the files.  The code style looks basically good except for a couple of minor violations, mainly a lot of trailing white space and some differently formatted function argument blocks.

I'm going to attach a bzipped tar file containing the psd directory with my minor modifications.
Comment 15 weskaggs 2007-12-14 00:17:59 UTC
Created attachment 100923 [details]
bzipped tar of psd source, slightly modified
Comment 16 John Marshall 2007-12-14 17:45:41 UTC
Hi Bill,

Thanks for looking at the code.  I have updated the source from your version to remove the remaining trailing spaces and reformating the rest of the function argument blocks.  I also converted a few rogue tabs to spaces.

The file conversion warnings are controlled by the value of the define CONVERSION_WARNINGS in psd.h.  I have set this to FALSE to suppress the "information will be lost" messages. Setting it to TRUE will re-enable.

In addition I made one small change to fix the unused variable warnings and will attach the resulting directory as a bzipped tar.
Comment 17 John Marshall 2007-12-14 17:47:17 UTC
Created attachment 100965 [details]
bzipped tar of psd source, slightly modified some more
Comment 18 weskaggs 2007-12-14 18:42:36 UTC
Sven and I both think that this should be committed.  As a final preliminary, I have sent an email to the gimp-developer list asking for comments.  Assuming there are no strong objections, one of us will commit this to the development branch in a few days.
Comment 19 Sven Neumann 2007-12-20 11:41:54 UTC
I have committed this plug-in to trunk after some minor coding style cleanups.

2007-12-20  Sven Neumann  <sven@gimp.org>

        * configure.in
        * plug-ins/Makefile.am
        * plug-ins/psd: added new PSD load plug-in written by John Marshall.
        This plug-in adds a couple of features. See bug #448181 for details.

        * plug-ins/common/Makefile.am
        * plug-ins/common/plugin-defs.pl
        * plug-ins/common/psd-load.c: removed old psd-load plug-in.

We definitely need to review error handling. It is unacceptable to pass errors such as "Error writing pascal string" to the user. There are tons of messages that are clearly not meant to be seen by the user ever and these are even marked for translation. This needs to be changed before we add the new plug-in to POTFILES.in so that it is seen by the translators.
Comment 20 John Marshall 2007-12-20 11:47:46 UTC
I'm sorry about the error handling, I took the style from the psp plug in.  Could you please suggest where I could look to see an example of how to handle such errors in an appropriate way and I will work on cleaning up the code.

Thanks
John
Comment 21 Sven Neumann 2007-12-20 12:12:09 UTC
There are two things here. One is handling of general file I/O problems. This is quite unlikely to ever happen and it can probably be handled better by showing a more general message like "Error loading PSD file: %s" using the standard file error strings. This is best done using by using adding a GError parameter to the file utility functions and creating this error using g_file_error_from_errno().

The other thing is conversion warnings. I would suggest that these stay compiled in. But instead of using g_message(), the warnings could be collected and shown in a dialog raised by the PSD plug-in. Such a dialog could have a "Don't show me such warnings again." check-box.
Comment 22 John Marshall 2008-01-07 14:12:08 UTC
I am including a patch below that uses GError to manage the file I/O errors and to report any file corruption errors (I hope that I have used GEror in an appropriate manner). I have significantly reduced the number of messages displayed and the number marked for translation.  I have also used messages that already exist in po-plug-ins wherever possible.

In this patch I have removed the translation macros from all of the conversion warnings but left them as not being compiled in at present.  I will work on the conversion warnings as a seperate patch.

The patch also includes fixes for a couple of memory leaks that were identified during testing.
Comment 23 John Marshall 2008-01-07 14:14:20 UTC
Created attachment 102326 [details] [review]
psd plug-in error handling clean-up.
Comment 24 Sven Neumann 2008-01-08 21:03:22 UTC
Thanks. I have committed this to trunk:

2008-01-08  Sven Neumann  <sven@gimp.org>

	* plug-ins/psd/psd-image-res-load.[ch]
	* plug-ins/psd/psd-layer-res-load.[ch]
	* plug-ins/psd/psd-load.c
	* plug-ins/psd/psd-thumb-load.c
	* plug-ins/psd/psd-util.[ch]
	* plug-ins/psd/psd.[ch]: applied a patch from John Marshall that
	improves error handling of the new PSD load plug-in (bug #448181).
Comment 25 Sven Neumann 2008-04-07 13:40:38 UTC
I am closing this as FIXED now. If there are further improvements to the plug-in, please open a new bug report for it.