GNOME Bugzilla – Bug 559725
Allow to set image-type and image-num-layers for thumbnail [patch]
Last modified: 2008-11-10 23:15:57 UTC
We cannot set the image type("RGA-alpha", etc...) and the number of layers of the thumbnail shown in "Open Image" dialog for now. With this patch, we can specify these two values in addition to width and height which is available even now. The alignment sequence of the return array of a thumbnail loader should be the following. element the type of value value ====================================== 0 GIMP_PDB_STATUS status 1 GIMP_PDB_IMAGE image_ID 2 GIMP_PDB_INT32 width 3 GIMP_PDB_INT32 height 4 GIMP_PDB_STRING type 5 GIMP_PDB_INT32 num-layers cf. http://lists.xcf.berkeley.edu/lists/gimp-developer/2008-October/021004.html
Created attachment 122176 [details] [review] First patch to allow to specify image-type and image-num-layers for thumbnail
For the image type we should rather use the GimpImageType enum. It can be converted to a string in the core then. See gimp_thumbnail_set_info_from_image() in app/core/gimpimagefile.c.
Created attachment 122227 [details] [review] second patch using GimpImageType enum The alignment sequence of the return array of a thumbnail loader should be the following. element the type of value value ====================================== 0 GIMP_PDB_STATUS status 1 GIMP_PDB_IMAGE image_ID 2 GIMP_PDB_INT32 width 3 GIMP_PDB_INT32 height 4 GIMP_PDB_INT32 type 5 GIMP_PDB_INT32 num-layers "type" showed be GimpImageType. If width (or height) is 0, the message, "W x H pixels" is not shown under thumbnail. //////////////// Is there any good place where the explanation of thumb_return_args like mentioned above is written? Is the type of "type"(=enum) "GIMP_PDB_INT32"? or GIMP_PDB_INT16 is suitable?
Created attachment 122265 [details] [review] cleaned up version of this patch This is a slightly cleaned up version of your patch. It is still not suited for inclusion though as it does not deal with the possibility that a thumb-loader does not specify the image-type and number of layers. The code needs to take this into account and should not set this information on the thumbnail object then.
Created attachment 122275 [details] [review] improved patch This updated patch should work, but I haven't found time yet to test it. We should probably also change some plug-ins to include this information in the thumbnail load procedure.
Created attachment 122304 [details] [review] another proposal patch Thanks Sven. Very informative patch for me. I think that the 156'th line of your patch should be + *type = -1; About "num_layers", using 0 is enough not to specify it as long as reading gimp_imagefile_get_desc_string() instead of -1. Do I overlook something? I attached another patch to modify about mentioned above.
0 is perfectly valid for "number of layers", so we need to use -1 here. I have now committed my changes with some further cleanups. It would be nice though to also update some plug-ins to make use of this feature. Keeping this bug report open until at least one plug-in has been changed... 2008-11-10 Sven Neumann <sven@gimp.org> Bug 559725 – Allow to set image-type and image-num-layers for thumbnail * app/file/file-open.[ch] (file_open_thumbnail): added parameters for image-type and number of layers. Try to get these from the procedure return values. Changes based on a patch from "tks". * app/core/gimpimagefile.c (gimp_imagefile_create_thumbnail) (gimp_thumbnail_set_info): set image-type and number of layers if specified.
2008-11-11 Sven Neumann <sven@gimp.org> * plug-ins/common/file-pdf.c: also return image type and number of pages. Followup to bug #559725.