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 138495 - Allow to open multi-page images as either Layers or Images (TIFF, PS, PDF, ...)
Allow to open multi-page images as either Layers or Images (TIFF, PS, PDF, ...)
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
2.0.x
Other All
: Normal enhancement
: Future
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-03-30 10:05 UTC by Sampson Fung
Modified: 2007-04-24 19:49 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
first try in patching the postscript plugin (6.74 KB, patch)
2005-07-13 17:17 UTC, Felix Riemann
none Details | Review
corrected patch (6.75 KB, patch)
2005-07-14 11:54 UTC, Felix Riemann
needs-work Details | Review
cleaned-up postscript patch (7.29 KB, patch)
2005-07-21 12:09 UTC, Felix Riemann
needs-work Details | Review
newly updated postscript patch (8.43 KB, patch)
2005-08-14 12:31 UTC, Felix Riemann
none Details | Review
correct patch (8.32 KB, patch)
2005-08-14 12:33 UTC, Felix Riemann
committed Details | Review

Description Sampson Fung 2004-03-30 10:05:24 UTC
Load a multi-page tiff file.  GIMP shown a multi-layer image instead.

From the status bar, pressing page-up/down, the status does change accordingly.

But only the topmost layer is displayed.

When printing, only the "merged" image is printed.
Comment 1 Michael Schumacher 2004-03-30 10:30:32 UTC
This sounds like several enhancement requests instead of a bug:

1) switching (visibilty) of layers with hotkeys
2) printing layers one by one

2) might already be covered by the gimp-print plug-in, but I've never used it yet.

Or is the tiff plug-in already supposed to have these functions?
Comment 2 Simon Budig 2004-03-30 12:13:24 UTC
Gimp does not have the concept of multiple pages in an image. Instead of
throwing away all image data except for the first page (which was the earlier
behaviour of the tiff-plugin) the pages get load into multiple layers. The print
plugin of course prints the image the way it is currently visible.

I don't know what to do about this, but it is definitely an enhancement request
and not a blocker.
Comment 3 Joao S. O. Bueno 2004-03-30 12:42:27 UTC
The postscript plugin however does load multi-page documents as multiple images.  
 
In this TIFF case, The GIMP would not be able to save the TIFF back, if it would be loaded into  
multiple images, but changing the plug-in to make it optional to load multiple pages as layers 
or separate images should not be hard. 
Comment 4 Michael Natterer 2004-03-30 22:40:06 UTC
Actually, each plug-in which can load multi-page documents should
have an option to load the pages either as layers or as images.

Changing summary accordingly. Please file a separate report for
the unrelated issue of printing the opened image(s).
Comment 5 Sven Neumann 2005-07-06 12:45:35 UTC
This is now addressed by the new GimpPageSelector widget. The new PDF export
plug-in will provide this functionality. What remains to be done is to change
the TIFF and Postscript plug-ins to use the new widget.
Comment 6 Michael Schumacher 2005-07-06 12:47:43 UTC
PDF export?
Comment 7 Sven Neumann 2005-07-06 12:50:42 UTC
Import, I meant to write PDF import. Sorry for the confusion.

Adding the gnome-love keyword since this is an overseeable job that doesn't
require much knowledge about GIMP. It's just a matter of porting two plug-ins to
a new widget, based on example code from a third plug-in. A nice way to get into
hacking the GIMP...
Comment 8 Felix Riemann 2005-07-13 17:17:49 UTC
Created attachment 49109 [details] [review]
first try in patching the postscript plugin

This is a first try of mine to change the postscript plugin to use the
PageSelector. I kept the old behavoir for PDF files, because I'm unable to get
the number of pages in such a file. The PageSelector widget is hidden if the
file only has one page. Support for layering postscript pages is included as
well (not sure if it's done correctly)
Comment 9 Felix Riemann 2005-07-14 11:54:23 UTC
Created attachment 49161 [details] [review]
corrected patch

I uploaded the wrong patch yesterday. PDF loading did not work. Thats fixed in
this one.
Comment 10 Sven Neumann 2005-07-19 15:20:06 UTC
Is countPSPages() really the only way to get to the number of pages in a
postscript file? The use of g_utf8_strup() is wrong here, btw. The filename
isn't necessarily in UTF-8 encoding. g_ascii_toupper() is probably a better
choice since it won't barf on other charsets.

Also, if the patch would adhere to the GIMP coding style, that would make it
easier to get it into CVS.
Comment 11 Simon Budig 2005-07-19 15:50:30 UTC
Counting the pages of a postscript file will be very hard, except you interpret
it and count the invocations of the "showpage" operator. Since this can be quite
disguised in a postscript file it does not help to just count the occurances of
"showpage".

The patch seems to rely on the Adobe DSC's (Document Structuring Comments) which
were invented to tackle exactly this problem. Note that Comments are just
postscript comments and not every postscript file is DSC-conformant.
Comment 12 Felix Riemann 2005-07-21 12:09:47 UTC
Created attachment 49508 [details] [review]
cleaned-up postscript patch

I hope I got the formatting right this time. I changed g_utf8_strup to its
ascii pendant, too. count_ps_pages() now counts the occurance of the "showpage"
operator when it passes by, since it walks the whole file until it finds a
"%%Pages" comment anyway.
Comment 13 Michael Schumacher 2005-07-24 15:27:07 UTC
If I'm not mistaken, there are still some formatting issues (the indentation of
some ifs).

I didn't investigate the code into full depth, but something makes me
suspicious: when pages should be added as layers, these are taken from the
images that are created by the existing code. Shouldn't these images be deleted
afterwards, or is this done automatically?

And finally, opening pages as layers should be made the default.
Comment 14 Michael Natterer 2005-07-24 15:42:06 UTC
This is even totally wrong. You can't take layers of one image and
add them to a second image. The layers need to be created for
the destination image in the first place.
Comment 15 Michael Natterer 2005-07-24 15:50:20 UTC
Um, sorry, I was commention on the previous patch.

The current one will work for "open as layers", however it will
waste tons of memory and is not committable as-is.

Some comments:

- the layers should be added to the final image in the first place.
- the final image's undo should be disabled.
- the g_file_test() in count_ps_pages() is redundant.
- the error message if opening fails in count_ps_pages() should
  use the standard translatable message "opening foo failed".
- i have now idea how correct count_ps_pages().
- GIMP should still be able to open all pages of all postscript documents,
  no matter if whey were countable before or not.
Comment 16 Michael Natterer 2005-07-24 15:52:26 UTC
Gah, I should have a coffee before commenting in bugzilla:

s/commention/commenting/

and

- i have no idea how correct count_ps_pages() is.

:-)
Comment 17 Felix Riemann 2005-08-14 12:31:03 UTC
Created attachment 50679 [details] [review]
newly updated postscript patch

This should change the following:
- the last indentation faults are hopefully eliminated
- images are deleted after layering pages
- final images undo stack is disabled while putting layers together
- removed g_file_test and fixed error message in count_ps_pages()
- if the pages cannot be counted the dialog falls back to the old behaviour
  with an GtkEntry for page selection plus an additional GtkComboBox
  for selecting the page mode

But there is one thing I'm not sure with. What do you mean by "the layers
should be added to the final image in the first place"? I'm adding the layer to
the image before adding the alpha channel now, but I'm not sure if it's what
you meant.
Comment 18 Felix Riemann 2005-08-14 12:33:11 UTC
Created attachment 50680 [details] [review]
correct patch

Doh!
Last one was the wrong one.
Comment 19 Michael Natterer 2005-08-14 22:01:12 UTC
I meant that it would be nicer (less temp memory used) if it didn't create
a new image for each page and then duplicated each image's single layer
in order to construct the final image.

Anyway, the patch looks fine now and should go into CVS, it can always
be improved after that.
Comment 20 Michael Natterer 2005-08-15 08:49:44 UTC
Hacked the patch a bit and appliged it to CVS HEAD:

2005-08-15  Michael Natterer  <mitch@gimp.org>

	* plug-ins/common/postscript.c: applied patch from Felix Riemann
	that adds page counting and a page selector widget to the load
	dialog.  Fixed some minor issues in the patch and added code that
	names layers and images after the document's pages. Disable undo
	on all created images and set them clean before returning them.
	Addresses bug #138495.
Comment 21 Michael Natterer 2005-08-15 16:31:16 UTC
Oops, didn't mean to set to NEEDINFO.
Comment 22 Michael Natterer 2005-08-22 23:14:31 UTC
Done for poppler:

2005-08-23  Michael Natterer  <mitch@gimp.org>

	* plug-ins/common/poppler.c: added loading of pages as images.
	Addresses bug #138495.
Comment 23 Sven Neumann 2005-10-19 10:08:37 UTC
What needs to be done to close this report? As far as I can see, the TIFF
plug-in should be using the page selector UI in case that the TIFF file being
opened contains an image directory. Would that make sense? Are there other file
plug-ins that need similar changes?
Comment 24 weskaggs 2006-05-21 22:48:11 UTC
It seemed that this is solved well enough for 2.4, and I will bump the target for the remaining parts to Future.
Comment 25 Sven Neumann 2006-06-06 11:55:50 UTC
IMO we should still try to get this into the TIFF plug-in for 2.4. With the availability of the GimpPageSelector widget, this should be a small change. 
Comment 26 Sven Neumann 2007-04-24 14:00:20 UTC
Removing from Postscript tracker bug as the requested changes to the Postscript plug-in are done.
Comment 27 Mukund Sivaraman 2007-04-24 18:42:21 UTC
Added this functionality for TIFF in Subversion changeset 22314:

2007-04-24  Mukund Sivaraman  <muks@mukund.org>

        * plug-ins/common/tiff.c: added support to load multi-page TIFF
        images as single layered image or multiple individual per-page
        images, after prompting the user for choice using a
        GimpPageSelector widget. Fixes the rest of bug #138495.

Comment 28 Mukund Sivaraman 2007-04-24 19:49:08 UTC
Closing as it's all done now.