restore bandfmt after unpremultiply in thumbnail
vips_unpremultiply() always outputs float. If you save the output of vipsthumbnail to a format that supports float files, like tiff, it won't ever get cast back to the source format. Example: $ vipsheader Opera-icon-high-res.png Opera-icon-high-res.png: 3056x3325 uchar, 4 bands, srgb, pngload $ vipsthumbnail Opera-icon-high-res.png -o x.tif $ vipsheader x.tif x.tif: 117x128 float, 4 bands, scrgb, tiffload This change makes it note and restore BandFmt aropund pre/unpremultiply. See https://github.com/jcupitt/libvips/issues/447
This commit is contained in:
parent
db11d3b973
commit
54d8e4808f
@ -5,6 +5,7 @@
|
|||||||
- dzsave won't write empty tiles in google mode, thanks bverem, perog,
|
- dzsave won't write empty tiles in google mode, thanks bverem, perog,
|
||||||
felixbuenemann
|
felixbuenemann
|
||||||
- allow nested [] in CLI args
|
- allow nested [] in CLI args
|
||||||
|
- restore BandFmt on unpremultiply in vipsthumbnail
|
||||||
|
|
||||||
15/4/16 started 8.3.1
|
15/4/16 started 8.3.1
|
||||||
- rename vips wrapper script, it was still vips-8.2, thanks Benjamin
|
- rename vips wrapper script, it was still vips-8.2, thanks Benjamin
|
||||||
|
@ -77,6 +77,8 @@
|
|||||||
* - add webp --shrink support
|
* - add webp --shrink support
|
||||||
* 29/2/16
|
* 29/2/16
|
||||||
* - deprecate sharpen and interpolate
|
* - deprecate sharpen and interpolate
|
||||||
|
* 6/5/16
|
||||||
|
* - restore BandFmt after unpremultiply
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
@ -363,6 +365,7 @@ thumbnail_shrink( VipsObject *process, VipsImage *in )
|
|||||||
/* TRUE if we've premultiplied and need to unpremultiply.
|
/* TRUE if we've premultiplied and need to unpremultiply.
|
||||||
*/
|
*/
|
||||||
gboolean have_premultiplied;
|
gboolean have_premultiplied;
|
||||||
|
VipsBandFormat unpremultiplied_format;
|
||||||
|
|
||||||
/* Sniff the incoming image and try to guess what the alpha max is.
|
/* Sniff the incoming image and try to guess what the alpha max is.
|
||||||
*/
|
*/
|
||||||
@ -444,8 +447,14 @@ thumbnail_shrink( VipsObject *process, VipsImage *in )
|
|||||||
"max_alpha", max_alpha,
|
"max_alpha", max_alpha,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
in = t[3];
|
|
||||||
have_premultiplied = TRUE;
|
have_premultiplied = TRUE;
|
||||||
|
|
||||||
|
/* vips_premultiply() makes a float image. When we
|
||||||
|
* vips_unpremultiply() below, we need to cast back to the
|
||||||
|
* pre-premultiply format.
|
||||||
|
*/
|
||||||
|
unpremultiplied_format = in->BandFmt;
|
||||||
|
in = t[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
shrink = calculate_shrink( in );
|
shrink = calculate_shrink( in );
|
||||||
@ -458,16 +467,17 @@ thumbnail_shrink( VipsObject *process, VipsImage *in )
|
|||||||
vips_info( "vipsthumbnail", "unpremultiplying alpha" );
|
vips_info( "vipsthumbnail", "unpremultiplying alpha" );
|
||||||
if( vips_unpremultiply( in, &t[5],
|
if( vips_unpremultiply( in, &t[5],
|
||||||
"max_alpha", max_alpha,
|
"max_alpha", max_alpha,
|
||||||
NULL ) )
|
NULL ) ||
|
||||||
|
vips_cast( t[5], &t[6], unpremultiplied_format, NULL ) )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
in = t[5];
|
in = t[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Colour management.
|
/* Colour management.
|
||||||
*
|
*
|
||||||
* If we've already imported, just export. Otherwise, we're in
|
* If we've already imported, just export. Otherwise, we're in
|
||||||
* device space device and we need a combined
|
* device space and we need a combined import/export to transform to
|
||||||
* import/export to transform to the target space.
|
* the target space.
|
||||||
*/
|
*/
|
||||||
if( have_imported ) {
|
if( have_imported ) {
|
||||||
if( export_profile ||
|
if( export_profile ||
|
||||||
|
Loading…
Reference in New Issue
Block a user