turn off chroma subsample for Q > 90
see https://github.com/jcupitt/libvips/issues/482
This commit is contained in:
parent
de981cd9ec
commit
4c1e6dd023
@ -95,7 +95,8 @@ typedef struct _VipsForeignSaveJpeg {
|
||||
*/
|
||||
gboolean trellis_quant;
|
||||
|
||||
/* Apply overshooting to samples with extreme values e.g. 0 & 255 for 8-bit.
|
||||
/* Apply overshooting to samples with extreme values e.g. 0 & 255
|
||||
* for 8-bit.
|
||||
*/
|
||||
gboolean overshoot_deringing;
|
||||
|
||||
|
@ -78,6 +78,8 @@
|
||||
* - add quant_table
|
||||
* 26/5/16
|
||||
* - switch to new orientation tag
|
||||
* 9/7/16
|
||||
* - turn off chroma subsample for Q > 90
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1020,7 +1022,9 @@ write_vips( Write *write, int qfac, const char *profile,
|
||||
*/
|
||||
g_assert( in->BandFmt == VIPS_FORMAT_UCHAR );
|
||||
g_assert( in->Coding == VIPS_CODING_NONE );
|
||||
g_assert( in->Bands == 1 || in->Bands == 3 || in->Bands == 4 );
|
||||
g_assert( in->Bands == 1 ||
|
||||
in->Bands == 3 ||
|
||||
in->Bands == 4 );
|
||||
|
||||
/* Check input image.
|
||||
*/
|
||||
@ -1032,7 +1036,8 @@ write_vips( Write *write, int qfac, const char *profile,
|
||||
write->cinfo.image_width = in->Xsize;
|
||||
write->cinfo.image_height = in->Ysize;
|
||||
write->cinfo.input_components = in->Bands;
|
||||
if( in->Bands == 4 && in->Type == VIPS_INTERPRETATION_CMYK ) {
|
||||
if( in->Bands == 4 &&
|
||||
in->Type == VIPS_INTERPRETATION_CMYK ) {
|
||||
space = JCS_CMYK;
|
||||
/* IJG always sets an Adobe marker, so we should invert CMYK.
|
||||
*/
|
||||
@ -1153,9 +1158,11 @@ write_vips( Write *write, int qfac, const char *profile,
|
||||
if( progressive )
|
||||
jpeg_simple_progression( &write->cinfo );
|
||||
|
||||
/* Turn off chroma subsampling.
|
||||
/* Turn off chroma subsampling. Follow IM and do it automatically for
|
||||
* high Q.
|
||||
*/
|
||||
if( no_subsample ) {
|
||||
if( no_subsample ||
|
||||
Q > 90 ) {
|
||||
int i;
|
||||
|
||||
for( i = 0; i < in->Bands; i++ ) {
|
||||
@ -1250,7 +1257,8 @@ vips__jpeg_write_file( VipsImage *in,
|
||||
*/
|
||||
if( write_vips( write,
|
||||
Q, profile, optimize_coding, progressive, strip, no_subsample,
|
||||
trellis_quant, overshoot_deringing, optimize_scans, quant_table ) ) {
|
||||
trellis_quant, overshoot_deringing, optimize_scans,
|
||||
quant_table ) ) {
|
||||
write_destroy( write );
|
||||
return( -1 );
|
||||
}
|
||||
@ -1535,7 +1543,8 @@ vips__jpeg_write_buffer( VipsImage *in,
|
||||
*/
|
||||
if( write_vips( write,
|
||||
Q, profile, optimize_coding, progressive, strip, no_subsample,
|
||||
trellis_quant, overshoot_deringing, optimize_scans, quant_table ) ) {
|
||||
trellis_quant, overshoot_deringing, optimize_scans,
|
||||
quant_table ) ) {
|
||||
write_destroy( write );
|
||||
|
||||
return( -1 );
|
||||
|
Loading…
Reference in New Issue
Block a user