[gimp] plug-ins: assume RGB/RGBA for JPEG2000 without declared color space.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: assume RGB/RGBA for JPEG2000 without declared color space.
- Date: Fri, 9 Mar 2018 23:31:31 +0000 (UTC)
commit 6f5c20eef1f944063445e1f265ffd3ad6395676c
Author: Jehan <jehan girinstud io>
Date: Fri Mar 9 21:59:04 2018 +0100
plug-ins: assume RGB/RGBA for JPEG2000 without declared color space.
It seems that the color space is not necessarily declared for a JPEG2000
image. From tests, it looks like it especially happens with JPEG2000
codestream (.j2c or .j2k). This variant is apparently mostly designed to
be embedded (from what I read), which may explain why the color space is
not always set (I assume the embedding format would have the color space
information). Mostly a guess.
plug-ins/common/file-jp2-load.c | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/common/file-jp2-load.c b/plug-ins/common/file-jp2-load.c
index 4a4f654..dad1941 100644
--- a/plug-ins/common/file-jp2-load.c
+++ b/plug-ins/common/file-jp2-load.c
@@ -933,10 +933,33 @@ load_image (const gchar *filename,
}
else
{
- g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
- _("Unsupported color space in JP2 image '%s'."),
- gimp_filename_to_utf8 (filename));
- goto out;
+ /* Sometimes the color space is not set at this point, which
+ * sucks. It seems to happen in particular with codestream images
+ * (.j2c or .j2k) which, if I understand well, are meant to be
+ * embedded by other files. So maybe that means that the color
+ * space information is in this container file?
+ * For now, let's just assume RGB/RGBA space when this happens,
+ * but this is not ideal. We should instead pop-up a dialog asking
+ * one to specify the color space in interactive mode (and add a
+ * parameter for the API.
+ * TODO!
+ */
+ base_type = GIMP_RGB;
+ if (num_components == 3)
+ {
+ image_type = GIMP_RGB_IMAGE;
+ }
+ else if (num_components == 4)
+ {
+ image_type = GIMP_RGBA_IMAGE;
+ }
+ else
+ {
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Unsupported color space in JP2 image '%s'."),
+ gimp_filename_to_utf8 (filename));
+ goto out;
+ }
}
/* FIXME */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]