diff --git a/libvips/foreign/jpeg2vips.c b/libvips/foreign/jpeg2vips.c index 609604eb..52853ad6 100644 --- a/libvips/foreign/jpeg2vips.c +++ b/libvips/foreign/jpeg2vips.c @@ -317,7 +317,6 @@ show_values( ExifData *data ) #endif /*HAVE_EXIF*/ #ifdef HAVE_EXIF - static int vips_exif_get_int( ExifData *ed, ExifEntry *entry, unsigned long component, int *out ) @@ -499,7 +498,7 @@ get_entry_int( ExifData *ed, int ifd, ExifTag tag, int *out ) } static void -set_vips_resolution( VipsImage *im, ExifData *ed ) +res_from_exif( VipsImage *im, ExifData *ed ) { double xres, yres; int unit; @@ -516,7 +515,7 @@ set_vips_resolution( VipsImage *im, ExifData *ed ) } #ifdef DEBUG - printf( "set_vips_resolution: seen exif tags " + printf( "res_from_exif: seen exif tags " "xres = %g, yres = %g, unit = %d\n", xres, yres, unit ); #endif /*DEBUG*/ @@ -546,7 +545,7 @@ set_vips_resolution( VipsImage *im, ExifData *ed ) } #ifdef DEBUG - printf( "set_vips_resolution: seen exif resolution %g, %g p/mm\n", + printf( "res_from_exif: seen exif resolution %g, %g p/mm\n", xres, yres ); #endif /*DEBUG*/ @@ -572,32 +571,8 @@ attach_thumbnail( VipsImage *im, ExifData *ed ) #endif /*HAVE_EXIF*/ static int -read_exif( VipsImage *im, void *data, int data_length ) +parse_exif( VipsImage *im, void *data, int data_length ) { - char *data_copy; - - /* Only use the first one. - */ - if( vips_image_get_typeof( im, VIPS_META_EXIF_NAME ) ) { -#ifdef DEBUG - printf( "read_exif: second EXIF block, ignoring\n" ); -#endif /*DEBUG*/ - - return( 0 ); - } - -#ifdef DEBUG - printf( "read_exif: attaching %d bytes of exif\n", data_length ); -#endif /*DEBUG*/ - - /* Always attach a copy of the unparsed exif data. - */ - if( !(data_copy = vips_malloc( NULL, data_length )) ) - return( -1 ); - memcpy( data_copy, data, data_length ); - vips_image_set_blob( im, VIPS_META_EXIF_NAME, - (VipsCallbackFn) vips_free, data_copy, data_length ); - #ifdef HAVE_EXIF { ExifData *ed; @@ -628,7 +603,7 @@ read_exif( VipsImage *im, void *data, int data_length ) /* Look for resolution fields and use them to set the VIPS * xres/yres fields. */ - set_vips_resolution( im, ed ); + res_from_exif( im, ed ); attach_thumbnail( im, ed ); @@ -640,22 +615,22 @@ read_exif( VipsImage *im, void *data, int data_length ) } static int -read_xmp( VipsImage *im, void *data, size_t data_length ) +attach_blob( VipsImage *im, const char *field, void *data, int data_length ) { char *data_copy; - /* XMP sections start "http". Only use the first one. + /* Only use the first one. */ - if( vips_image_get_typeof( im, VIPS_META_XMP_NAME ) ) { + if( vips_image_get_typeof( im, field ) ) { #ifdef DEBUG - printf( "read_xmp: second XMP block, ignoring\n" ); + printf( "attach_blob: second %s block, ignoring\n", field ); #endif /*DEBUG*/ return( 0 ); } #ifdef DEBUG - printf( "read_xmp: attaching %zd bytes of XMP\n", data_length ); + printf( "attach_blob: attaching %d bytes of %s\n", data_length, field ); #endif /*DEBUG*/ /* Always attach a copy of the unparsed exif data. @@ -663,35 +638,7 @@ read_xmp( VipsImage *im, void *data, size_t data_length ) if( !(data_copy = vips_malloc( NULL, data_length )) ) return( -1 ); memcpy( data_copy, data, data_length ); - vips_image_set_blob( im, VIPS_META_XMP_NAME, - (VipsCallbackFn) vips_free, data_copy, data_length ); - - return( 0 ); -} - -static int -read_ipct( VipsImage *im, void *data, size_t data_length ) -{ - char *data_copy; - - /* Only use the first one. - */ - if( vips_image_get_typeof( im, VIPS_META_IPCT_NAME ) ) { -#ifdef DEBUG - printf( "read_ipct: second IPCT block, ignoring\n" ); -#endif /*DEBUG*/ - - return( 0 ); - } - -#ifdef DEBUG - printf( "read_ipct: attaching %zd bytes of IPCT\n", data_length ); -#endif /*DEBUG*/ - - if( !(data_copy = vips_malloc( NULL, data_length )) ) - return( -1 ); - memcpy( data_copy, data, data_length ); - vips_image_set_blob( im, VIPS_META_IPCT_NAME, + vips_image_set_blob( im, field, (VipsCallbackFn) vips_free, data_copy, data_length ); return( 0 ); @@ -826,19 +773,24 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out ) /* Possible EXIF or XMP data. */ if( p->data_length > 4 && - vips_isprefix( "Exif", (char *) p->data ) && - read_exif( out, p->data, p->data_length ) ) + vips_isprefix( "Exif", (char *) p->data ) ) { + if( parse_exif( out, + p->data, p->data_length ) || + attach_blob( out, VIPS_META_EXIF_NAME, + p->data, p->data_length ) ) return( -1 ); + } if( p->data_length > 4 && vips_isprefix( "http", (char *) p->data ) && - read_xmp( out, p->data, p->data_length ) ) + attach_blob( out, VIPS_META_XMP_NAME, + p->data, p->data_length ) ) return( -1 ); break; case JPEG_APP0 + 2: - /* ICC profile. + /* Possible ICC profile. */ if( p->data_length > 14 && vips_isprefix( "ICC_PROFILE", @@ -862,7 +814,8 @@ read_jpeg_header( ReadJpeg *jpeg, VipsImage *out ) */ if( p->data_length > 5 && vips_isprefix( "Photo", (char *) p->data ) && - read_ipct( out, p->data, p->data_length ) ) + attach_blob( out, VIPS_META_IPCT_NAME, + p->data, p->data_length ) ) return( -1 ); break; diff --git a/libvips/foreign/vips2jpeg.c b/libvips/foreign/vips2jpeg.c index f8576972..21146c77 100644 --- a/libvips/foreign/vips2jpeg.c +++ b/libvips/foreign/vips2jpeg.c @@ -607,17 +607,37 @@ vips_exif_update( ExifData *ed, VipsImage *image ) exif_data_foreach_content( ed, (ExifDataForeachContentFunc) vips_exif_update_content, &ve ); } - - #endif /*HAVE_EXIF*/ +static int +write_blob( Write *write, const char *field, int app ) +{ + unsigned char *data; + size_t data_length; + + if( vips_image_get_typeof( write->in, field ) ) { + if( vips_image_get_blob( write->in, field, + (void *) &data, &data_length ) ) + return( -1 ); + +#ifdef DEBUG + printf( "write_blob: attaching %zd bytes of %s\n", + data_length, field ); +#endif /*DEBUG*/ + + jpeg_write_marker( &write->cinfo, app, data, data_length ); + } + + return( 0 ); +} + static int write_exif( Write *write ) { +#ifdef HAVE_EXIF unsigned char *data; size_t data_length; unsigned int idl; -#ifdef HAVE_EXIF ExifData *ed; /* Either parse from the embedded EXIF, or if there's none, make @@ -683,70 +703,13 @@ write_exif( Write *write ) #else /*!HAVE_EXIF*/ /* No libexif ... just copy the embedded EXIF over. */ - if( vips_image_get_typeof( write->in, VIPS_META_EXIF_NAME ) ) { - if( vips_image_get_blob( write->in, VIPS_META_EXIF_NAME, - (void *) &data, &data_length ) ) - return( -1 ); - -#ifdef DEBUG - printf( "write_exif: attaching %zd bytes of EXIF\n", - data_length ); -#endif /*DEBUG*/ - - jpeg_write_marker( &write->cinfo, JPEG_APP0 + 1, - data, data_length ); - } + if( write_blob( write, VIPS_META_EXIF_NAME, JPEG_APP0 + 1 ) ) + return( -1 ); #endif /*!HAVE_EXIF*/ return( 0 ); } -static int -write_xmp( Write *write ) -{ - unsigned char *data; - size_t data_length; - - if( vips_image_get_typeof( write->in, VIPS_META_XMP_NAME ) ) { - if( vips_image_get_blob( write->in, VIPS_META_XMP_NAME, - (void *) &data, &data_length ) ) - return( -1 ); - -#ifdef DEBUG - printf( "write_xmp: attaching %zd bytes of XMP\n", - data_length ); -#endif /*DEBUG*/ - - jpeg_write_marker( &write->cinfo, JPEG_APP0 + 1, - data, data_length ); - } - - return( 0 ); -} - -static int -write_ipct( Write *write ) -{ - unsigned char *data; - size_t data_length; - - if( vips_image_get_typeof( write->in, VIPS_META_IPCT_NAME ) ) { - if( vips_image_get_blob( write->in, VIPS_META_IPCT_NAME, - (void *) &data, &data_length ) ) - return( -1 ); - -#ifdef DEBUG - printf( "write_ipct: attaching %zd bytes of IPCT\n", - data_length ); -#endif /*DEBUG*/ - - jpeg_write_marker( &write->cinfo, JPEG_APP0 + 13, - data, data_length ); - } - - return( 0 ); -} - /* ICC writer from lcms, slight tweaks. */ @@ -943,8 +906,8 @@ write_vips( Write *write, int qfac, const char *profile ) /* Write any APP markers we need. */ if( write_exif( write ) || - write_xmp( write ) || - write_ipct( write ) ) + write_blob( write, VIPS_META_XMP_NAME, JPEG_APP0 + 1 ) || + write_blob( write, VIPS_META_IPCT_NAME, JPEG_APP0 + 13 ) ) return( -1 ); /* A profile supplied as an argument overrides an embedded profile. diff --git a/po/vips7.pot b/po/vips7.pot index 7d76960a..df05d736 100644 --- a/po/vips7.pot +++ b/po/vips7.pot @@ -7,8 +7,9 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-11-16 21:34+0000\n" +"Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?" +"product=glib&keywords=I18N+L10N&component=general\n" +"POT-Creation-Date: 2012-11-21 21:39+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -628,117 +629,117 @@ msgstr "" msgid "calculate dE00" msgstr "" -#: ../libvips/colour/icc_transform.c:194 ../libvips/colour/XYZ2sRGB.c:160 +#: ../libvips/colour/icc_transform.c:193 ../libvips/colour/XYZ2sRGB.c:160 msgid "depth must be 8 or 16" msgstr "" -#: ../libvips/colour/icc_transform.c:229 +#: ../libvips/colour/icc_transform.c:228 #, c-format msgid "unimplemented input color space 0x%x" msgstr "" -#: ../libvips/colour/icc_transform.c:271 +#: ../libvips/colour/icc_transform.c:270 #, c-format msgid "unimplemented output color space 0x%x" msgstr "" -#: ../libvips/colour/icc_transform.c:283 +#: ../libvips/colour/icc_transform.c:282 msgid "no device profile" msgstr "" -#: ../libvips/colour/icc_transform.c:314 +#: ../libvips/colour/icc_transform.c:313 msgid "transform using ICC profiles" msgstr "" -#: ../libvips/colour/icc_transform.c:318 +#: ../libvips/colour/icc_transform.c:317 msgid "Intent" msgstr "" -#: ../libvips/colour/icc_transform.c:319 +#: ../libvips/colour/icc_transform.c:318 msgid "Rendering intent" msgstr "" -#: ../libvips/colour/icc_transform.c:362 +#: ../libvips/colour/icc_transform.c:361 #, c-format msgid "" "intent %d (%s) not supported by %s profile; falling back to default intent" msgstr "" -#: ../libvips/colour/icc_transform.c:366 ../libvips/iofuncs/operation.c:98 +#: ../libvips/colour/icc_transform.c:365 ../libvips/iofuncs/operation.c:98 msgid "input" msgstr "" -#: ../libvips/colour/icc_transform.c:366 ../libvips/iofuncs/operation.c:98 +#: ../libvips/colour/icc_transform.c:365 ../libvips/iofuncs/operation.c:98 msgid "output" msgstr "" -#: ../libvips/colour/icc_transform.c:400 ../libvips/colour/icc_transform.c:601 -#: ../libvips/colour/icc_transform.c:812 +#: ../libvips/colour/icc_transform.c:399 ../libvips/colour/icc_transform.c:600 +#: ../libvips/colour/icc_transform.c:811 msgid "unable to load embedded profile" msgstr "" -#: ../libvips/colour/icc_transform.c:408 ../libvips/colour/icc_transform.c:609 -#: ../libvips/colour/icc_transform.c:820 ../libvips/colour/icc_transform.c:834 +#: ../libvips/colour/icc_transform.c:407 ../libvips/colour/icc_transform.c:608 +#: ../libvips/colour/icc_transform.c:819 ../libvips/colour/icc_transform.c:833 #, c-format msgid "unable to open profile \"%s\"" msgstr "" -#: ../libvips/colour/icc_transform.c:414 ../libvips/colour/icc_transform.c:826 +#: ../libvips/colour/icc_transform.c:413 ../libvips/colour/icc_transform.c:825 msgid "no input profile" msgstr "" -#: ../libvips/colour/icc_transform.c:498 +#: ../libvips/colour/icc_transform.c:497 msgid "import from device with ICC profile" msgstr "" -#: ../libvips/colour/icc_transform.c:504 ../libvips/colour/icc_transform.c:896 +#: ../libvips/colour/icc_transform.c:503 ../libvips/colour/icc_transform.c:895 msgid "Embedded" msgstr "" -#: ../libvips/colour/icc_transform.c:505 ../libvips/colour/icc_transform.c:897 +#: ../libvips/colour/icc_transform.c:504 ../libvips/colour/icc_transform.c:896 msgid "Use embedded input profile, if available" msgstr "" -#: ../libvips/colour/icc_transform.c:511 ../libvips/colour/icc_transform.c:903 +#: ../libvips/colour/icc_transform.c:510 ../libvips/colour/icc_transform.c:902 msgid "Input profile" msgstr "" -#: ../libvips/colour/icc_transform.c:512 ../libvips/colour/icc_transform.c:904 +#: ../libvips/colour/icc_transform.c:511 ../libvips/colour/icc_transform.c:903 msgid "Filename to load input profile from" msgstr "" -#: ../libvips/colour/icc_transform.c:617 +#: ../libvips/colour/icc_transform.c:616 msgid "no output profile" msgstr "" -#: ../libvips/colour/icc_transform.c:711 +#: ../libvips/colour/icc_transform.c:710 msgid "output to device with ICC profile" msgstr "" -#: ../libvips/colour/icc_transform.c:717 ../libvips/colour/icc_transform.c:889 +#: ../libvips/colour/icc_transform.c:716 ../libvips/colour/icc_transform.c:888 msgid "Output profile" msgstr "" -#: ../libvips/colour/icc_transform.c:718 ../libvips/colour/icc_transform.c:890 +#: ../libvips/colour/icc_transform.c:717 ../libvips/colour/icc_transform.c:889 msgid "Filename to load output profile from" msgstr "" -#: ../libvips/colour/icc_transform.c:724 ../libvips/colour/icc_transform.c:910 +#: ../libvips/colour/icc_transform.c:723 ../libvips/colour/icc_transform.c:909 #: ../libvips/colour/XYZ2sRGB.c:187 ../libvips/foreign/dzsave.c:1193 msgid "Depth" msgstr "" -#: ../libvips/colour/icc_transform.c:725 ../libvips/colour/icc_transform.c:911 +#: ../libvips/colour/icc_transform.c:724 ../libvips/colour/icc_transform.c:910 #: ../libvips/colour/XYZ2sRGB.c:188 msgid "Output device space depth in bits" msgstr "" -#: ../libvips/colour/icc_transform.c:883 +#: ../libvips/colour/icc_transform.c:882 msgid "transform between devices with ICC profiles" msgstr "" -#: ../libvips/colour/icc_transform.c:999 -#: ../libvips/colour/icc_transform.c:1013 +#: ../libvips/colour/icc_transform.c:998 +#: ../libvips/colour/icc_transform.c:1012 msgid "unable to get media white point" msgstr "" @@ -1409,20 +1410,20 @@ msgstr "" msgid "parameters would result in zero size output image" msgstr "" -#: ../libvips/foreign/jpeg2vips.c:171 +#: ../libvips/foreign/jpeg2vips.c:174 #, c-format msgid "read gave %ld warnings" msgstr "" -#: ../libvips/foreign/jpeg2vips.c:511 +#: ../libvips/foreign/jpeg2vips.c:514 msgid "error reading resolution" msgstr "" -#: ../libvips/foreign/jpeg2vips.c:541 ../libvips/foreign/vips2jpeg.c:479 +#: ../libvips/foreign/jpeg2vips.c:544 ../libvips/foreign/vips2jpeg.c:481 msgid "unknown EXIF resolution unit" msgstr "" -#: ../libvips/foreign/jpeg2vips.c:754 +#: ../libvips/foreign/jpeg2vips.c:782 msgid "unknown JFIF resolution unit" msgstr "" @@ -1434,20 +1435,20 @@ msgstr "" msgid "read error" msgstr "" -#: ../libvips/foreign/vips2jpeg.c:139 +#: ../libvips/foreign/vips2jpeg.c:141 #, c-format msgid "%s" msgstr "" -#: ../libvips/foreign/vips2jpeg.c:493 +#: ../libvips/foreign/vips2jpeg.c:495 msgid "error setting JPEG resolution" msgstr "" -#: ../libvips/foreign/vips2jpeg.c:513 +#: ../libvips/foreign/vips2jpeg.c:515 msgid "error setting JPEG dimensions" msgstr "" -#: ../libvips/foreign/vips2jpeg.c:668 +#: ../libvips/foreign/vips2jpeg.c:670 msgid "error saving EXIF" msgstr "" @@ -2184,21 +2185,21 @@ msgstr "" msgid "unable to read pixels" msgstr "" -#: ../libvips/foreign/magick2vips.c:658 +#: ../libvips/foreign/magick2vips.c:662 #, c-format msgid "" "unable to read file \"%s\"\n" "libMagick error: %s %s" msgstr "" -#: ../libvips/foreign/magick2vips.c:692 +#: ../libvips/foreign/magick2vips.c:700 #, c-format msgid "" "unable to ping file \"%s\"\n" "libMagick error: %s %s" msgstr "" -#: ../libvips/foreign/magick2vips.c:703 +#: ../libvips/foreign/magick2vips.c:711 msgid "bad image size" msgstr ""