Skip to content
Permalink
Browse files

fix some more metadata updates

some more minor cases picked up by the test suite
  • Loading branch information
jcupitt committed Nov 30, 2019
1 parent 5c7a649 commit 686829166d2149b5eda4e7cc0a7e25f83ac7b631
@@ -15,7 +15,7 @@ script:
- LD_LIBRARY_PATH=$PWD/libvips/.libs
DYLD_LIBRARY_PATH=$PWD/libvips/.libs
LD_PRELOAD=$ASAN_DSO
$PYTHON -m pytest -v test/test-suite
$PYTHON -m pytest -sv --log-cli-level=WARNING test/test-suite

matrix:
allow_failures:
@@ -64,7 +64,7 @@ vips_convsep_build( VipsObject *object )
VipsConvolution *convolution = (VipsConvolution *) object;
VipsConvsep *convsep = (VipsConvsep *) object;
VipsImage **t = (VipsImage **)
vips_object_local_array( object, 3 );
vips_object_local_array( object, 4 );

VipsImage *in;

@@ -86,19 +86,19 @@ vips_convsep_build( VipsObject *object )
in = t[0];
}
else {
if( vips_rot( convolution->M, &t[0], VIPS_ANGLE_D90, NULL ) )
return( -1 );

/* We must only add the offset once.
/* Take a copy, since we must set the offset.
*/
vips_image_set_double( t[0], "offset", 0 );
if( vips_rot( convolution->M, &t[0], VIPS_ANGLE_D90, NULL ) ||
vips_copy( t[0], &t[3], NULL ) )
return( -1 );
vips_image_set_double( t[3], "offset", 0 );

if( vips_conv( in, &t[1], convolution->M,
"precision", convsep->precision,
"layers", convsep->layers,
"cluster", convsep->cluster,
NULL ) ||
vips_conv( t[1], &t[2], t[0],
vips_conv( t[1], &t[2], t[3],
"precision", convsep->precision,
"layers", convsep->layers,
"cluster", convsep->cluster,
@@ -590,17 +590,28 @@ write_image( VipsForeignSaveDz *dz,
{
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( dz );

VipsImage *t;
void *buf;
size_t len;

/* We need to block progress signalling on individual image write, so
* we need a copy of the tile in case it's shared (eg. associated
* images).
*/
if( vips_copy( image, &t, NULL ) )
return( -1 );

/* We default to stripping all metadata. Only "no_strip" turns this
* off. Very few people really want metadata on every tile.
*/
vips_image_set_int( image, "hide-progress", 1 );
if( vips_image_write_to_buffer( image, format, &buf, &len,
vips_image_set_int( t, "hide-progress", 1 );
if( vips_image_write_to_buffer( t, format, &buf, &len,
"strip", !dz->no_strip,
NULL ) )
NULL ) ) {
VIPS_UNREF( t );
return( -1 );
}
VIPS_UNREF( t );

/* gsf doesn't like more than one write active at once.
*/
@@ -304,11 +304,14 @@ vips_foreign_save_heif_build( VipsObject *object )
build( object ) )
return( -1 );

/* We must copy the input image since we will be updating the
* metadata when we write the exif.
/* Only rebuild exif if there's an EXIF block or we'll make a
* default set of tags. EXIF is not required for heif.
*/
if( vips_copy( save->ready, &heif->image, NULL ) )
return( -1 );
if( vips_image_get_typeof( heif->image, VIPS_META_EXIF_NAME ) )
if( vips__exif_update( heif->image ) )
return( -1 );

error = heif_context_get_encoder_for_format( heif->ctx,
(enum heif_compression_format) heif->compression,
@@ -368,12 +371,6 @@ vips_foreign_save_heif_build( VipsObject *object )
heif->data = heif_image_get_plane( heif->img,
heif_channel_interleaved, &heif->stride );

/* Just do this once, so we don't rebuild exif on every page.
*/
if( vips_image_get_typeof( heif->image, VIPS_META_EXIF_NAME ) )
if( vips__exif_update( heif->image ) )
return( -1 );

/* Write data.
*/
if( vips_sink_disc( heif->image,
@@ -233,10 +233,8 @@ write_new( VipsImage *in )
write->eman.fp = NULL;
write->inverted = NULL;

/* We must copy the input image since we will be updating the
* metadata when we write the exif.
*/
if( vips_copy( in, &write->in, NULL ) ) {
if( vips_copy( in, &write->in, NULL ) ||
vips__exif_update( write->in ) ) {
write_destroy( write );
return( NULL );
}
@@ -331,8 +329,7 @@ write_xmp( Write *write )
static int
write_exif( Write *write )
{
if( vips__exif_update( write->in ) ||
write_blob( write, VIPS_META_EXIF_NAME, JPEG_APP0 + 1 ) )
if( write_blob( write, VIPS_META_EXIF_NAME, JPEG_APP0 + 1 ) )
return( -1 );

return( 0 );
@@ -164,10 +164,10 @@ vips_webp_write_init( VipsWebPWrite *write, VipsImage *image,
write->enc = NULL;
write->mux = NULL;

/* We must copy the input image since we will be updating the
* metadata when we write the exif.
/* Rebuild exif on image. We must do this on a copy.
*/
if( vips_copy( image, &write->image, NULL ) ) {
if( vips_copy( image, &write->image, NULL ) ||
vips__exif_update( write->image ) ) {
vips_webp_write_unset( write );
return( -1 );
}
@@ -474,11 +474,6 @@ vips_webp_add_metadata( VipsWebPWrite *write )
{
WebPData data;

/* Rebuild the EXIF block, if any, ready for writing.
*/
if( vips__exif_update( write->image ) )
return( -1 );

data.bytes = write->memory_writer.mem;
data.size = write->memory_writer.size;

@@ -520,7 +520,7 @@ static int
vips_thumbnail_build( VipsObject *object )
{
VipsThumbnail *thumbnail = VIPS_THUMBNAIL( object );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 13 );
VipsImage **t = (VipsImage **) vips_object_local_array( object, 14 );
VipsInterpretation interpretation = thumbnail->linear ?
VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB;

@@ -673,6 +673,9 @@ vips_thumbnail_build( VipsObject *object )
return( -1 );
in = t[4];

if( vips_copy( in, &t[13], NULL ) )
return( -1 );
in = t[13];
output_page_height = VIPS_RINT( preshrunk_page_height / vshrink );
vips_image_set_int( in,
VIPS_META_PAGE_HEIGHT, output_page_height );
@@ -544,6 +544,7 @@ def webp_valid(im):
if have("gifload"):
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
w1 = x1.webpsave_buffer(Q=10)

x2 = pyvips.Image.new_from_buffer(w1, "", n=-1)
assert x1.width == x2.width
assert x1.height == x2.height
@@ -26,10 +26,10 @@ def setup_class(cls):
cls.tempdir = tempfile.mkdtemp()

cls.colour = pyvips.Image.jpegload(JPEG_FILE)
cls.mono = cls.colour.extract_band(1)
cls.mono = cls.colour.extract_band(1).copy()
# we remove the ICC profile: the RGB one will no longer be appropriate
cls.mono.remove("icc-profile-data")
cls.rad = cls.colour.float2rad()
cls.rad = cls.colour.float2rad().copy()
cls.rad.remove("icc-profile-data")
cls.cmyk = cls.colour.bandjoin(cls.mono)
cls.cmyk = cls.cmyk.copy(interpretation=pyvips.Interpretation.CMYK)

0 comments on commit 6868291

Please sign in to comment.
You can’t perform that action at this time.