[gimp/muks/openjpeg] plug-ins: test for image types in a more robust way.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/muks/openjpeg] plug-ins: test for image types in a more robust way.
- Date: Sun, 4 Mar 2018 15:42:22 +0000 (UTC)
commit c51fc6e2680f55d9f31ddbf5e4e8fe0147c653d5
Author: Jehan <jehan girinstud io>
Date: Sun Mar 4 16:25:39 2018 +0100
plug-ins: test for image types in a more robust way.
Rather than just assuming all non-gray images are RGB, do a bit more
robust check and reject unknown formats. Indeed even though I see we
took care of YUV, e-YCC and CMYK images above (and normally either
converted them to RGB or already exited with an error), I can see that
the OpenJPEG library could still return OPJ_CLRSPC_UNKNOWN or
OPJ_CLRSPC_UNSPECIFIED. Let's be thorough and not assume we got a SRGB
here.
Also add the alpha-variant tests inside their parent image type
respective test. This should not change anything by any logics, but
let's not leave anything for chance to strike us.
plug-ins/common/file-jp2-load.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/plug-ins/common/file-jp2-load.c b/plug-ins/common/file-jp2-load.c
index 05cc38d..6bf172a 100644
--- a/plug-ins/common/file-jp2-load.c
+++ b/plug-ins/common/file-jp2-load.c
@@ -913,27 +913,30 @@ load_image (const gchar *filename,
}
}
+ num_components = image->numcomps;
+
if (image->color_space == OPJ_CLRSPC_GRAY)
{
base_type = GIMP_GRAY;
image_type = GIMP_GRAY_IMAGE;
+
+ if (num_components == 2)
+ image_type = GIMP_GRAYA_IMAGE;
}
- else
+ else if (image->color_space == OPJ_CLRSPC_SRGB)
{
base_type = GIMP_RGB;
image_type = GIMP_RGB_IMAGE;
+ if (num_components == 4)
+ image_type = GIMP_RGBA_IMAGE;
}
-
- num_components = image->numcomps;
-
- if (num_components == 2)
- {
- image_type = GIMP_GRAYA_IMAGE;
- }
- else if (num_components == 4)
+ else
{
- image_type = GIMP_RGBA_IMAGE;
+ g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
+ _("Couldn't decode JP2 image in '%s'."),
+ gimp_filename_to_utf8 (filename));
+ goto out;
}
/* FIXME */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]