fix write RGBA as JPG

it was saving RGBA as CMYK JPG, with comical results (thanks Tobias)
This commit is contained in:
John Cupitt 2012-06-17 22:16:20 +01:00
parent fdd3b0a387
commit f07fb25ab5
5 changed files with 26 additions and 8 deletions

View File

@ -6,6 +6,7 @@
- add dzsave, save in deep zoom format
- rework im_shrink() as a class
- remove im_rightshift_size(), just a convenience function now
- fix write RGBA as JPG (thanks Tobias)
19/4/12 started 7.28.6
- better resolution unit handling in deprecated im_vips2tiff()

4
TODO
View File

@ -2,10 +2,6 @@
- add a int-only path?
- compare to rightshift_size, deprecate that? should be as quick
- warn if used with float factors
- vipsthumbnail should not remove profiles by default

View File

@ -1160,9 +1160,18 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
in = out;
}
else if( in->Bands > 3 &&
class->saveable == VIPS_SAVEABLE_RGB ) {
(class->saveable == VIPS_SAVEABLE_RGB ||
(class->saveable == VIPS_SAVEABLE_RGB_CMYK &&
in->Type != VIPS_INTERPRETATION_CMYK)) ) {
VipsImage *out;
/* Don't let 4 bands though unless the image really is
* a CMYK.
*
* Consider a RGBA png being saved as JPG. We can
* write CMYK jpg, but we mustn't do that for RGBA
* images.
*/
if( vips_extract_band( in, &out, 0,
"n", 3,
NULL ) ) {
@ -1174,7 +1183,8 @@ vips_foreign_convert_saveable( VipsForeignSave *save )
in = out;
}
else if( in->Bands > 4 &&
(class->saveable == VIPS_SAVEABLE_RGB_CMYK ||
((class->saveable == VIPS_SAVEABLE_RGB_CMYK &&
in->Type == VIPS_INTERPRETATION_CMYK) ||
class->saveable == VIPS_SAVEABLE_RGBA) ) {
VipsImage *out;

View File

@ -43,6 +43,9 @@
* 15/3/12
* - better alpha handling
* - sanity check pixel geometry before allowing read
* 17/6/12
* - more alpha fixes ... some images have no transparency chunk but
* still set color_type to alpha
*/
/*
@ -263,6 +266,13 @@ png2vips_header( Read *read, VipsImage *out )
png_set_tRNS_to_alpha( read->pPng );
bands += 1;
}
else if( color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA ) {
/* Some images have no transparency chunk, but still set
* color_type to alpha.
*/
bands += 1;
}
/* Expand <8 bit images to full bytes.
*/

View File

@ -326,10 +326,11 @@ vips_shrink_build( VipsObject *object )
* be OK, but FATSTRIP would be a disaster: thread 2 would be given a
* strip some way down the output, which would be a huge distance down
* the input.
*
* Make sure we always work by insisting on SMALLTILE.
*/
vips_demand_hint( resample->out,
//VIPS_DEMAND_STYLE_SMALLTILE, resample->in, NULL );
VIPS_DEMAND_STYLE_THINSTRIP, resample->in, NULL );
VIPS_DEMAND_STYLE_SMALLTILE, resample->in, NULL );
/* Size output. Note: we round the output width down!
*/