don't try to write oversized jpeg markers

see https://github.com/jcupitt/libvips/issues/311
This commit is contained in:
John Cupitt 2015-07-08 13:28:50 +01:00
parent 0ab44b1aff
commit b3d35da677
2 changed files with 22 additions and 3 deletions

View File

@ -12,6 +12,7 @@
- add vips_bandfold()/vips_bandunfold()
- dzsave supports zip output > 4gb, thanks benjamin
- add support for HSV colourspace [Jonas Øgaard]
- skip oversized markers in jpeg write
7/5/15 started 8.0.3
- dzsave and tif pyr write could fail for some image dimensions, thanks Jonas

View File

@ -65,6 +65,8 @@
* - add a "no_subsample" option to disable chroma subsample
* 9/9/14
* - support "none" as a resolution unit
* 8/7/15
* - omit oversized jpeg markers
*/
/*
@ -634,12 +636,28 @@ write_blob( Write *write, const char *field, int app )
(void *) &data, &data_length ) )
return( -1 );
/* Single jpeg markers can only hold 64kb, large objects must
* be split into multiple markers.
*
* Unfortunately, how this splitting is done depends on the
* data type. For example, ICC and XMP have completely
* different ways of doing this.
*
* For now, just ignore oversize objects and warn.
*/
if( data_length > 65530 )
vips_warn( "VipsJpeg", _( "field \"%s\" is too large "
"for a single JPEG marker, ignoring" ),
field );
else {
#ifdef DEBUG
printf( "write_blob: attaching %zd bytes of %s\n",
data_length, field );
printf( "write_blob: attaching %zd bytes of %s\n",
data_length, field );
#endif /*DEBUG*/
jpeg_write_marker( &write->cinfo, app, data, data_length );
jpeg_write_marker( &write->cinfo, app,
data, data_length );
}
}
return( 0 );