Skip to content

Commit 4ece872

Browse files
authored
Make subsample-mode=on and lossless=true mutually exclusive (#4263)
i.e. always disable chroma subsampling when saving lossless. Resolves: #4232.
1 parent f6aa2bd commit 4ece872

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- morph: fix erode Highway path [kleisauke]
66
- morph: fix C-paths with masks containing zero [kleisauke]
77
- fix `--vips-info` CLI flag with GLib >= 2.80 [kleisauke]
8+
- make `subsample-mode=on` and `lossless=true` mutually exclusive [kleisauke]
89

910
10/10/24 8.16.0
1011

libvips/foreign/heifsave.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,11 +526,9 @@ vips_foreign_save_heif_build(VipsObject *object)
526526
!vips_object_argument_isset(object, "effort"))
527527
heif->effort = 9 - heif->speed;
528528

529-
/* Disable chroma subsampling by default when the "lossless" param
530-
* is being used.
529+
/* The "lossless" param implies no chroma subsampling.
531530
*/
532-
if (vips_object_argument_isset(object, "lossless") &&
533-
!vips_object_argument_isset(object, "subsample_mode"))
531+
if (heif->lossless)
534532
heif->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_OFF;
535533

536534
/* Default 12 bit save for 16-bit images.

libvips/foreign/jp2ksave.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,14 @@ vips_foreign_save_jp2k_build(VipsObject *object)
819819
return -1;
820820
}
821821

822+
/* The "lossless" param implies no chroma subsampling.
823+
*/
824+
if (jp2k->lossless)
825+
jp2k->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_OFF;
826+
822827
switch (jp2k->subsample_mode) {
823828
case VIPS_FOREIGN_SUBSAMPLE_AUTO:
824-
jp2k->subsample =
825-
!jp2k->lossless &&
826-
jp2k->Q < 90 &&
829+
jp2k->subsample = jp2k->Q < 90 &&
827830
(save->ready->Type == VIPS_INTERPRETATION_sRGB ||
828831
save->ready->Type == VIPS_INTERPRETATION_RGB16) &&
829832
save->ready->Bands == 3;

0 commit comments

Comments
 (0)