add --strip option to jpegsave
drops all metadata
This commit is contained in:
parent
53e86e71f4
commit
847332a77e
@ -20,6 +20,7 @@
|
|||||||
- vips_gamma() works for any format
|
- vips_gamma() works for any format
|
||||||
- add --linear mode to vipsthumbnail
|
- add --linear mode to vipsthumbnail
|
||||||
- support XYZ as a PCS for vips_icc_import() and vips_icc_export()
|
- support XYZ as a PCS for vips_icc_import() and vips_icc_export()
|
||||||
|
- add --strip option to jpegsave
|
||||||
|
|
||||||
18/10/13 started 7.36.3
|
18/10/13 started 7.36.3
|
||||||
- fix compiler warnings in ubuntu 13.10
|
- fix compiler warnings in ubuntu 13.10
|
||||||
|
@ -1994,6 +1994,7 @@ vips_jpegload( const char *filename, VipsImage **out, ... )
|
|||||||
* @profile: attach this ICC profile
|
* @profile: attach this ICC profile
|
||||||
* @optimize_coding: compute optimal Huffman coding tables
|
* @optimize_coding: compute optimal Huffman coding tables
|
||||||
* @interlace: write an interlaced (progressive) jpeg
|
* @interlace: write an interlaced (progressive) jpeg
|
||||||
|
* @strip: remove all metadata from image
|
||||||
*
|
*
|
||||||
* Write a VIPS image to a file as JPEG.
|
* Write a VIPS image to a file as JPEG.
|
||||||
*
|
*
|
||||||
@ -2025,6 +2026,9 @@ vips_jpegload( const char *filename, VipsImage **out, ... )
|
|||||||
* in jpg parlance). These files may be better for display over a slow network
|
* in jpg parlance). These files may be better for display over a slow network
|
||||||
* conection, but need much more memory to encode and decode.
|
* conection, but need much more memory to encode and decode.
|
||||||
*
|
*
|
||||||
|
* If @strip is set, no EXIF data, IPCT data, ICC profile or XMP metadata is
|
||||||
|
* written into the output file.
|
||||||
|
*
|
||||||
* See also: vips_jpegsave_buffer(), vips_image_write_file().
|
* See also: vips_jpegsave_buffer(), vips_image_write_file().
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, -1 on error.
|
* Returns: 0 on success, -1 on error.
|
||||||
@ -2055,6 +2059,7 @@ vips_jpegsave( VipsImage *in, const char *filename, ... )
|
|||||||
* @profile: attach this ICC profile
|
* @profile: attach this ICC profile
|
||||||
* @optimize_coding: compute optimal Huffman coding tables
|
* @optimize_coding: compute optimal Huffman coding tables
|
||||||
* @interlace: write an interlaced (progressive) jpeg
|
* @interlace: write an interlaced (progressive) jpeg
|
||||||
|
* @strip: remove all metadata from image
|
||||||
*
|
*
|
||||||
* As vips_jpegsave(), but save to a memory buffer.
|
* As vips_jpegsave(), but save to a memory buffer.
|
||||||
*
|
*
|
||||||
@ -2104,6 +2109,7 @@ vips_jpegsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
|
|||||||
* @Q: JPEG quality factor
|
* @Q: JPEG quality factor
|
||||||
* @profile: attach this ICC profile
|
* @profile: attach this ICC profile
|
||||||
* @optimize_coding: compute optimal Huffman coding tables
|
* @optimize_coding: compute optimal Huffman coding tables
|
||||||
|
* @strip: remove all metadata from image
|
||||||
*
|
*
|
||||||
* As vips_jpegsave(), but save as a mime jpeg on stdout.
|
* As vips_jpegsave(), but save as a mime jpeg on stdout.
|
||||||
*
|
*
|
||||||
|
@ -87,6 +87,10 @@ typedef struct _VipsForeignSaveJpeg {
|
|||||||
*/
|
*/
|
||||||
gboolean interlace;
|
gboolean interlace;
|
||||||
|
|
||||||
|
/* Remove all metadata from the image.
|
||||||
|
*/
|
||||||
|
gboolean strip;
|
||||||
|
|
||||||
} VipsForeignSaveJpeg;
|
} VipsForeignSaveJpeg;
|
||||||
|
|
||||||
typedef VipsForeignSaveClass VipsForeignSaveJpegClass;
|
typedef VipsForeignSaveClass VipsForeignSaveJpegClass;
|
||||||
@ -146,6 +150,13 @@ vips_foreign_save_jpeg_class_init( VipsForeignSaveJpegClass *class )
|
|||||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsForeignSaveJpeg, interlace ),
|
G_STRUCT_OFFSET( VipsForeignSaveJpeg, interlace ),
|
||||||
FALSE );
|
FALSE );
|
||||||
|
|
||||||
|
VIPS_ARG_BOOL( class, "strip", 14,
|
||||||
|
_( "Strip" ),
|
||||||
|
_( "Strip all metadata from image" ),
|
||||||
|
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||||
|
G_STRUCT_OFFSET( VipsForeignSaveJpeg, strip ),
|
||||||
|
FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -181,7 +192,7 @@ vips_foreign_save_jpeg_file_build( VipsObject *object )
|
|||||||
|
|
||||||
if( vips__jpeg_write_file( save->ready, file->filename,
|
if( vips__jpeg_write_file( save->ready, file->filename,
|
||||||
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace ) )
|
jpeg->interlace, jpeg->strip ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
@ -247,7 +258,7 @@ vips_foreign_save_jpeg_buffer_build( VipsObject *object )
|
|||||||
|
|
||||||
if( vips__jpeg_write_buffer( save->ready,
|
if( vips__jpeg_write_buffer( save->ready,
|
||||||
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace ) )
|
jpeg->interlace, jpeg->strip ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
area = vips_area_new_blob( (VipsCallbackFn) vips_free, obuf, olen );
|
area = vips_area_new_blob( (VipsCallbackFn) vips_free, obuf, olen );
|
||||||
@ -309,7 +320,7 @@ vips_foreign_save_jpeg_mime_build( VipsObject *object )
|
|||||||
|
|
||||||
if( vips__jpeg_write_buffer( save->ready,
|
if( vips__jpeg_write_buffer( save->ready,
|
||||||
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
&obuf, &olen, jpeg->Q, jpeg->profile, jpeg->optimize_coding,
|
||||||
jpeg->interlace ) )
|
jpeg->interlace, jpeg->strip ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
printf( "Content-length: %zd\r\n", olen );
|
printf( "Content-length: %zd\r\n", olen );
|
||||||
|
@ -58,6 +58,8 @@
|
|||||||
* - attach IPCT data (app13), thanks Gary
|
* - attach IPCT data (app13), thanks Gary
|
||||||
* 2/10/13 Lovell Fuller
|
* 2/10/13 Lovell Fuller
|
||||||
* - add optimize_coding parameter
|
* - add optimize_coding parameter
|
||||||
|
* 12/11/13
|
||||||
|
* - add "strip" option to remove all metadata
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -841,7 +843,7 @@ write_jpeg_block( REGION *region, Rect *area, void *a )
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
write_vips( Write *write, int qfac, const char *profile,
|
write_vips( Write *write, int qfac, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive )
|
gboolean optimize_coding, gboolean progressive, gboolean strip )
|
||||||
{
|
{
|
||||||
VipsImage *in;
|
VipsImage *in;
|
||||||
J_COLOR_SPACE space;
|
J_COLOR_SPACE space;
|
||||||
@ -909,22 +911,26 @@ write_vips( Write *write, int qfac, const char *profile,
|
|||||||
|
|
||||||
/* Write any APP markers we need.
|
/* Write any APP markers we need.
|
||||||
*/
|
*/
|
||||||
if( write_exif( write ) ||
|
if( !strip ) {
|
||||||
write_blob( write, VIPS_META_XMP_NAME, JPEG_APP0 + 1 ) ||
|
if( write_exif( write ) ||
|
||||||
write_blob( write, VIPS_META_IPCT_NAME, JPEG_APP0 + 13 ) )
|
write_blob( write,
|
||||||
return( -1 );
|
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.
|
/* A profile supplied as an argument overrides an embedded
|
||||||
* "none" means don't attach a profile.
|
* profile. "none" means don't attach a profile.
|
||||||
*/
|
*/
|
||||||
if( profile &&
|
if( profile &&
|
||||||
strcmp( profile, "none" ) != 0 &&
|
strcmp( profile, "none" ) != 0 &&
|
||||||
write_profile_file( write, profile ) )
|
write_profile_file( write, profile ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
if( !profile &&
|
if( !profile &&
|
||||||
vips_image_get_typeof( in, VIPS_META_ICC_NAME ) &&
|
vips_image_get_typeof( in, VIPS_META_ICC_NAME ) &&
|
||||||
write_profile_meta( write ) )
|
write_profile_meta( write ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
/* Write data. Note that the write function grabs the longjmp()!
|
/* Write data. Note that the write function grabs the longjmp()!
|
||||||
*/
|
*/
|
||||||
@ -946,7 +952,7 @@ write_vips( Write *write, int qfac, const char *profile,
|
|||||||
int
|
int
|
||||||
vips__jpeg_write_file( VipsImage *in,
|
vips__jpeg_write_file( VipsImage *in,
|
||||||
const char *filename, int Q, const char *profile,
|
const char *filename, int Q, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive )
|
gboolean optimize_coding, gboolean progressive, gboolean strip )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
@ -976,7 +982,8 @@ vips__jpeg_write_file( VipsImage *in,
|
|||||||
|
|
||||||
/* Convert!
|
/* Convert!
|
||||||
*/
|
*/
|
||||||
if( write_vips( write, Q, profile, optimize_coding, progressive ) ) {
|
if( write_vips( write,
|
||||||
|
Q, profile, optimize_coding, progressive, strip ) ) {
|
||||||
write_destroy( write );
|
write_destroy( write );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -1223,7 +1230,8 @@ buf_dest( j_compress_ptr cinfo, void **obuf, size_t *olen )
|
|||||||
int
|
int
|
||||||
vips__jpeg_write_buffer( VipsImage *in,
|
vips__jpeg_write_buffer( VipsImage *in,
|
||||||
void **obuf, size_t *olen, int Q, const char *profile,
|
void **obuf, size_t *olen, int Q, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive )
|
gboolean optimize_coding, gboolean progressive,
|
||||||
|
gboolean strip )
|
||||||
{
|
{
|
||||||
Write *write;
|
Write *write;
|
||||||
|
|
||||||
@ -1252,7 +1260,8 @@ vips__jpeg_write_buffer( VipsImage *in,
|
|||||||
|
|
||||||
/* Convert!
|
/* Convert!
|
||||||
*/
|
*/
|
||||||
if( write_vips( write, Q, profile, optimize_coding, progressive ) ) {
|
if( write_vips( write,
|
||||||
|
Q, profile, optimize_coding, progressive, strip ) ) {
|
||||||
write_destroy( write );
|
write_destroy( write );
|
||||||
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
@ -39,10 +39,10 @@ extern const char *vips__jpeg_suffs[];
|
|||||||
|
|
||||||
int vips__jpeg_write_file( VipsImage *in,
|
int vips__jpeg_write_file( VipsImage *in,
|
||||||
const char *filename, int Q, const char *profile,
|
const char *filename, int Q, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive );
|
gboolean optimize_coding, gboolean progressive, gboolean strip );
|
||||||
int vips__jpeg_write_buffer( VipsImage *in,
|
int vips__jpeg_write_buffer( VipsImage *in,
|
||||||
void **obuf, size_t *olen, int Q, const char *profile,
|
void **obuf, size_t *olen, int Q, const char *profile,
|
||||||
gboolean optimize_coding, gboolean progressive );
|
gboolean optimize_coding, gboolean progressive, gboolean strip );
|
||||||
|
|
||||||
int vips__isjpeg( const char *filename );
|
int vips__isjpeg( const char *filename );
|
||||||
int vips__jpeg_read_file( const char *name, VipsImage *out,
|
int vips__jpeg_read_file( const char *name, VipsImage *out,
|
||||||
|
Loading…
Reference in New Issue
Block a user