fix some more metadata updates
some more minor cases picked up by the test suite
This commit is contained in:
parent
5c7a649001
commit
686829166d
@ -15,7 +15,7 @@ script:
|
|||||||
- LD_LIBRARY_PATH=$PWD/libvips/.libs
|
- LD_LIBRARY_PATH=$PWD/libvips/.libs
|
||||||
DYLD_LIBRARY_PATH=$PWD/libvips/.libs
|
DYLD_LIBRARY_PATH=$PWD/libvips/.libs
|
||||||
LD_PRELOAD=$ASAN_DSO
|
LD_PRELOAD=$ASAN_DSO
|
||||||
$PYTHON -m pytest -v test/test-suite
|
$PYTHON -m pytest -sv --log-cli-level=WARNING test/test-suite
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
@ -64,7 +64,7 @@ vips_convsep_build( VipsObject *object )
|
|||||||
VipsConvolution *convolution = (VipsConvolution *) object;
|
VipsConvolution *convolution = (VipsConvolution *) object;
|
||||||
VipsConvsep *convsep = (VipsConvsep *) object;
|
VipsConvsep *convsep = (VipsConvsep *) object;
|
||||||
VipsImage **t = (VipsImage **)
|
VipsImage **t = (VipsImage **)
|
||||||
vips_object_local_array( object, 3 );
|
vips_object_local_array( object, 4 );
|
||||||
|
|
||||||
VipsImage *in;
|
VipsImage *in;
|
||||||
|
|
||||||
@ -86,19 +86,19 @@ vips_convsep_build( VipsObject *object )
|
|||||||
in = t[0];
|
in = t[0];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( vips_rot( convolution->M, &t[0], VIPS_ANGLE_D90, NULL ) )
|
/* Take a copy, since we must set the offset.
|
||||||
return( -1 );
|
|
||||||
|
|
||||||
/* We must only add the offset once.
|
|
||||||
*/
|
*/
|
||||||
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,
|
if( vips_conv( in, &t[1], convolution->M,
|
||||||
"precision", convsep->precision,
|
"precision", convsep->precision,
|
||||||
"layers", convsep->layers,
|
"layers", convsep->layers,
|
||||||
"cluster", convsep->cluster,
|
"cluster", convsep->cluster,
|
||||||
NULL ) ||
|
NULL ) ||
|
||||||
vips_conv( t[1], &t[2], t[0],
|
vips_conv( t[1], &t[2], t[3],
|
||||||
"precision", convsep->precision,
|
"precision", convsep->precision,
|
||||||
"layers", convsep->layers,
|
"layers", convsep->layers,
|
||||||
"cluster", convsep->cluster,
|
"cluster", convsep->cluster,
|
||||||
|
@ -590,17 +590,28 @@ write_image( VipsForeignSaveDz *dz,
|
|||||||
{
|
{
|
||||||
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( dz );
|
VipsObjectClass *class = VIPS_OBJECT_GET_CLASS( dz );
|
||||||
|
|
||||||
|
VipsImage *t;
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t len;
|
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
|
/* We default to stripping all metadata. Only "no_strip" turns this
|
||||||
* off. Very few people really want metadata on every tile.
|
* off. Very few people really want metadata on every tile.
|
||||||
*/
|
*/
|
||||||
vips_image_set_int( image, "hide-progress", 1 );
|
vips_image_set_int( t, "hide-progress", 1 );
|
||||||
if( vips_image_write_to_buffer( image, format, &buf, &len,
|
if( vips_image_write_to_buffer( t, format, &buf, &len,
|
||||||
"strip", !dz->no_strip,
|
"strip", !dz->no_strip,
|
||||||
NULL ) )
|
NULL ) ) {
|
||||||
|
VIPS_UNREF( t );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
}
|
||||||
|
VIPS_UNREF( t );
|
||||||
|
|
||||||
/* gsf doesn't like more than one write active at once.
|
/* gsf doesn't like more than one write active at once.
|
||||||
*/
|
*/
|
||||||
|
@ -304,11 +304,14 @@ vips_foreign_save_heif_build( VipsObject *object )
|
|||||||
build( object ) )
|
build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
/* We must copy the input image since we will be updating the
|
/* Only rebuild exif if there's an EXIF block or we'll make a
|
||||||
* metadata when we write the exif.
|
* default set of tags. EXIF is not required for heif.
|
||||||
*/
|
*/
|
||||||
if( vips_copy( save->ready, &heif->image, NULL ) )
|
if( vips_copy( save->ready, &heif->image, NULL ) )
|
||||||
return( -1 );
|
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,
|
error = heif_context_get_encoder_for_format( heif->ctx,
|
||||||
(enum heif_compression_format) heif->compression,
|
(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->data = heif_image_get_plane( heif->img,
|
||||||
heif_channel_interleaved, &heif->stride );
|
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.
|
/* Write data.
|
||||||
*/
|
*/
|
||||||
if( vips_sink_disc( heif->image,
|
if( vips_sink_disc( heif->image,
|
||||||
|
@ -233,10 +233,8 @@ write_new( VipsImage *in )
|
|||||||
write->eman.fp = NULL;
|
write->eman.fp = NULL;
|
||||||
write->inverted = NULL;
|
write->inverted = NULL;
|
||||||
|
|
||||||
/* We must copy the input image since we will be updating the
|
if( vips_copy( in, &write->in, NULL ) ||
|
||||||
* metadata when we write the exif.
|
vips__exif_update( write->in ) ) {
|
||||||
*/
|
|
||||||
if( vips_copy( in, &write->in, NULL ) ) {
|
|
||||||
write_destroy( write );
|
write_destroy( write );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
@ -331,8 +329,7 @@ write_xmp( Write *write )
|
|||||||
static int
|
static int
|
||||||
write_exif( Write *write )
|
write_exif( Write *write )
|
||||||
{
|
{
|
||||||
if( vips__exif_update( write->in ) ||
|
if( write_blob( write, VIPS_META_EXIF_NAME, JPEG_APP0 + 1 ) )
|
||||||
write_blob( write, VIPS_META_EXIF_NAME, JPEG_APP0 + 1 ) )
|
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
@ -164,10 +164,10 @@ vips_webp_write_init( VipsWebPWrite *write, VipsImage *image,
|
|||||||
write->enc = NULL;
|
write->enc = NULL;
|
||||||
write->mux = NULL;
|
write->mux = NULL;
|
||||||
|
|
||||||
/* We must copy the input image since we will be updating the
|
/* Rebuild exif on image. We must do this on a copy.
|
||||||
* metadata when we write the exif.
|
|
||||||
*/
|
*/
|
||||||
if( vips_copy( image, &write->image, NULL ) ) {
|
if( vips_copy( image, &write->image, NULL ) ||
|
||||||
|
vips__exif_update( write->image ) ) {
|
||||||
vips_webp_write_unset( write );
|
vips_webp_write_unset( write );
|
||||||
return( -1 );
|
return( -1 );
|
||||||
}
|
}
|
||||||
@ -474,11 +474,6 @@ vips_webp_add_metadata( VipsWebPWrite *write )
|
|||||||
{
|
{
|
||||||
WebPData data;
|
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.bytes = write->memory_writer.mem;
|
||||||
data.size = write->memory_writer.size;
|
data.size = write->memory_writer.size;
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ static int
|
|||||||
vips_thumbnail_build( VipsObject *object )
|
vips_thumbnail_build( VipsObject *object )
|
||||||
{
|
{
|
||||||
VipsThumbnail *thumbnail = VIPS_THUMBNAIL( 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 ?
|
VipsInterpretation interpretation = thumbnail->linear ?
|
||||||
VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB;
|
VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB;
|
||||||
|
|
||||||
@ -673,6 +673,9 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
in = t[4];
|
in = t[4];
|
||||||
|
|
||||||
|
if( vips_copy( in, &t[13], NULL ) )
|
||||||
|
return( -1 );
|
||||||
|
in = t[13];
|
||||||
output_page_height = VIPS_RINT( preshrunk_page_height / vshrink );
|
output_page_height = VIPS_RINT( preshrunk_page_height / vshrink );
|
||||||
vips_image_set_int( in,
|
vips_image_set_int( in,
|
||||||
VIPS_META_PAGE_HEIGHT, output_page_height );
|
VIPS_META_PAGE_HEIGHT, output_page_height );
|
||||||
|
@ -544,6 +544,7 @@ class TestForeign:
|
|||||||
if have("gifload"):
|
if have("gifload"):
|
||||||
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
|
x1 = pyvips.Image.new_from_file(GIF_ANIM_FILE, n=-1)
|
||||||
w1 = x1.webpsave_buffer(Q=10)
|
w1 = x1.webpsave_buffer(Q=10)
|
||||||
|
|
||||||
x2 = pyvips.Image.new_from_buffer(w1, "", n=-1)
|
x2 = pyvips.Image.new_from_buffer(w1, "", n=-1)
|
||||||
assert x1.width == x2.width
|
assert x1.width == x2.width
|
||||||
assert x1.height == x2.height
|
assert x1.height == x2.height
|
||||||
|
@ -26,10 +26,10 @@ class TestStream:
|
|||||||
cls.tempdir = tempfile.mkdtemp()
|
cls.tempdir = tempfile.mkdtemp()
|
||||||
|
|
||||||
cls.colour = pyvips.Image.jpegload(JPEG_FILE)
|
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
|
# we remove the ICC profile: the RGB one will no longer be appropriate
|
||||||
cls.mono.remove("icc-profile-data")
|
cls.mono.remove("icc-profile-data")
|
||||||
cls.rad = cls.colour.float2rad()
|
cls.rad = cls.colour.float2rad().copy()
|
||||||
cls.rad.remove("icc-profile-data")
|
cls.rad.remove("icc-profile-data")
|
||||||
cls.cmyk = cls.colour.bandjoin(cls.mono)
|
cls.cmyk = cls.colour.bandjoin(cls.mono)
|
||||||
cls.cmyk = cls.cmyk.copy(interpretation=pyvips.Interpretation.CMYK)
|
cls.cmyk = cls.cmyk.copy(interpretation=pyvips.Interpretation.CMYK)
|
||||||
|
Loading…
Reference in New Issue
Block a user