@@ -667,30 +667,21 @@ set_cinfo(struct jpeg_compress_struct *cinfo,
667
667
if (progressive )
668
668
jpeg_simple_progression (cinfo );
669
669
670
- if (in -> Bands != 3 ||
671
- subsample_mode == VIPS_FOREIGN_SUBSAMPLE_OFF ||
672
- (subsample_mode == VIPS_FOREIGN_SUBSAMPLE_AUTO &&
673
- qfac >= 90 ))
674
- /* No chroma subsample.
675
- */
676
- for (int i = 0 ; i < in -> Bands ; i ++ ) {
677
- cinfo -> comp_info [i ].h_samp_factor = 1 ;
678
- cinfo -> comp_info [i ].v_samp_factor = 1 ;
679
- }
680
- else {
681
- /* Use 4:2:0 subsampling, we must set this explicitly, since some
682
- * jpeg libraries do not enable chroma subsample by default.
683
- */
684
- cinfo -> comp_info [0 ].h_samp_factor = 2 ;
685
- cinfo -> comp_info [0 ].v_samp_factor = 2 ;
670
+ /* We must set chroma subsampling explicitly since some libjpegs do not
671
+ * enable this by default.
672
+ */
673
+ if (in -> Bands == 3 &&
674
+ (subsample_mode == VIPS_FOREIGN_SUBSAMPLE_ON ||
675
+ (subsample_mode == VIPS_FOREIGN_SUBSAMPLE_AUTO &&
676
+ qfac < 90 )))
677
+ cinfo -> comp_info [0 ].h_samp_factor = cinfo -> comp_info [0 ].v_samp_factor = 2 ;
678
+ else
679
+ cinfo -> comp_info [0 ].h_samp_factor = cinfo -> comp_info [0 ].v_samp_factor = 1 ;
686
680
687
- /* Rest should have sampling factors 1,1.
688
- */
689
- for (int i = 1 ; i < in -> Bands ; i ++ ) {
690
- cinfo -> comp_info [i ].h_samp_factor = 1 ;
691
- cinfo -> comp_info [i ].v_samp_factor = 1 ;
692
- }
693
- }
681
+ /* Rest should have sampling factors 1,1.
682
+ */
683
+ for (int i = 1 ; i < in -> Bands ; i ++ )
684
+ cinfo -> comp_info [i ].h_samp_factor = cinfo -> comp_info [i ].v_samp_factor = 1 ;
694
685
695
686
/* Only write the JFIF headers if we have no EXIF.
696
687
* Some readers get confused if you set both.
0 commit comments