Commit 01e1c604 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

load embedded ICC profiles and attach them as "icc-profile" parasite.

2005-07-01  Sven Neumann  <sven@gimp.org>

	* plug-ins/jpeg/jpeg-load.c: load embedded ICC profiles and attach
	them as "icc-profile" parasite.

	* plug-ins/jpeg/jpeg-save.c: look for the "icc-profile" parasite
	and embed the profile in the JPEG file if it is available.
parent 11def584
2005-07-01 Sven Neumann <sven@gimp.org>
* plug-ins/jpeg/jpeg-load.c: load embedded ICC profiles and attach
them as "icc-profile" parasite.
* plug-ins/jpeg/jpeg-save.c: look for the "icc-profile" parasite
and embed the profile in the JPEG file if it is available.
2005-07-01 Manish Singh <yosh@gimp.org>
* plug-ins/jpeg/jpeg-save.c: Initialize restart markers check button
......@@ -13,8 +21,8 @@
2005-06-30 Sven Neumann <sven@gimp.org>
* plug-ins/jpeg/Makefile.am
* plug-ins/jpeg/jpeg-icc.[ch]: copied from lcms that reads and
writes ICC profiles from/to JPEG files. Not yet used at all.
* plug-ins/jpeg/jpeg-icc.[ch]: copied code from lcms that reads
and writes ICC profiles from/to JPEG files. Not yet used at all.
2005-06-29 Sven Neumann <sven@gimp.org>
......
......@@ -37,6 +37,7 @@
#include "libgimp/stdplugins-intl.h"
#include "jpeg.h"
#include "jpeg-icc.h"
#include "jpeg-load.h"
......@@ -55,6 +56,8 @@ load_image (const gchar *filename,
guchar *buf;
guchar * volatile padded_buf = NULL;
guchar **rowbuf;
guchar *profile;
guint profile_size;
gint image_type;
gint layer_type;
gint tile_height;
......@@ -92,6 +95,7 @@ load_image (const gchar *filename,
}
image_ID = -1;
/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp (jerr.setjmp_buffer))
{
......@@ -101,10 +105,13 @@ load_image (const gchar *filename,
jpeg_destroy_decompress (&cinfo);
if (infile)
fclose (infile);
if (image_ID != -1 && !preview)
gimp_image_delete (image_ID);
if (preview)
destroy_preview();
gimp_quit ();
}
......@@ -115,11 +122,19 @@ load_image (const gchar *filename,
jpeg_stdio_src (&cinfo, infile);
/* - step 2.1: tell the lib to save the comments */
jpeg_save_markers (&cinfo, JPEG_COM, 0xffff);
if (! preview)
{
/* - step 2.1: tell the lib to save the comments */
jpeg_save_markers (&cinfo, JPEG_COM, 0xffff);
/* - step 2.2: tell the lib to save APP1 markers
* (may contain EXIF or XMP)
*/
jpeg_save_markers (&cinfo, JPEG_APP0 + 1, 0xffff);
/* - step 2.2: tell the lib to save APP1 markers (may contain EXIF or XMP) */
jpeg_save_markers (&cinfo, JPEG_APP0 + 1, 0xffff);
/* - step 2.3: tell the lib to keep any APP2 data it may find */
jpeg_icc_setup_read_profile (&cinfo);
}
/* Step 3: read file parameters with jpeg_read_header() */
......@@ -322,11 +337,23 @@ load_image (const gchar *filename,
{
g_warning ("JPEG - unable to decode XMP metadata packet");
}
gimp_destroy_params (return_vals, nreturn_vals);
g_free (xmp_packet);
}
}
/* Step 5.3: check for an embedded ICC profile */
if (!preview && jpeg_icc_read_profile (&cinfo, &profile, &profile_size))
{
GimpParasite *parasite = gimp_parasite_new ("icc-profile",
0, profile_size, profile);
gimp_image_parasite_attach (image_ID, parasite);
gimp_parasite_free (parasite);
g_free (profile);
}
if (!preview)
{
/* if we had any comments then make a parasite for them */
......@@ -347,8 +374,8 @@ load_image (const gchar *filename,
}
/* Do not attach the "jpeg-save-options" parasite to the image
* because this conflics with the global defaults. See bug #75398:
* http://bugzilla.gnome.org/show_bug.cgi?id=75398 */
* because this conflicts with the global defaults (bug #75398).
*/
}
/* Step 6: while (scan lines remain to be read) */
......
......@@ -44,6 +44,7 @@
#include "libgimp/stdplugins-intl.h"
#include "jpeg.h"
#include "jpeg-icc.h"
#include "jpeg-save.h"
......@@ -189,6 +190,7 @@ save_image (const gchar *filename,
GimpPixelRgn pixel_rgn;
GimpDrawable *drawable;
GimpImageType drawable_type;
GimpParasite *parasite;
struct jpeg_compress_struct cinfo;
struct my_error_mgr jerr;
FILE * volatile outfile;
......@@ -273,21 +275,16 @@ save_image (const gchar *filename,
case GIMP_RGBA_IMAGE:
case GIMP_GRAYA_IMAGE:
/*gimp_message ("jpeg: image contains a-channel info which will be lost");*/
/* # of color components per pixel (minus the GIMP alpha channel) */
cinfo.input_components = drawable->bpp - 1;
has_alpha = TRUE;
break;
case GIMP_INDEXED_IMAGE:
/*gimp_message ("jpeg: cannot operate on indexed color images");*/
return FALSE;
break;
default:
/*gimp_message ("jpeg: cannot operate on unknown image types");*/
return FALSE;
break;
}
/* Step 3: set parameters for compression */
......@@ -485,8 +482,6 @@ save_image (const gchar *filename,
/* Step 4.2: Write the XMP packet in an APP1 marker */
if (jsvals.save_xmp)
{
GimpParasite *parasite;
/* FIXME: temporary hack until the right thing is done by a library */
parasite = gimp_image_parasite_find (orig_image_ID, "gimp-metadata");
if (parasite)
......@@ -495,7 +490,7 @@ save_image (const gchar *filename,
glong xmp_data_size;
gchar *app_block;
xmp_data = ((const gchar *)gimp_parasite_data (parasite)) + 10;
xmp_data = ((const gchar *) gimp_parasite_data (parasite)) + 10;
xmp_data_size = gimp_parasite_data_size (parasite) - 10;
g_print ("jpeg-save: saving XMP packet (%d bytes)\n",
(int) xmp_data_size);
......@@ -510,6 +505,16 @@ save_image (const gchar *filename,
}
}
/* Step 4.3: store the color profile if there is one */
parasite = gimp_image_parasite_find (orig_image_ID, "icc-profile");
if (parasite)
{
jpeg_icc_write_profile (&cinfo,
gimp_parasite_data (parasite),
gimp_parasite_data_size (parasite));
gimp_parasite_free (parasite);
}
/* Step 5: while (scan lines remain to be written) */
/* jpeg_write_scanlines(...); */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment