Skip to content

Commit

Permalink
Make subsample-mode=on and lossless=true mutually exclusive
Browse files Browse the repository at this point in the history
i.e. always disable chroma subsampling when saving lossless.

See: libvips#4232.
  • Loading branch information
kleisauke committed Nov 17, 2024
1 parent f6aa2bd commit cc4de1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- morph: fix erode Highway path [kleisauke]
- morph: fix C-paths with masks containing zero [kleisauke]
- fix `--vips-info` CLI flag with GLib >= 2.80 [kleisauke]
- make `subsample-mode=on` and `lossless=true` mutually exclusive [kleisauke]

10/10/24 8.16.0

Expand Down
6 changes: 2 additions & 4 deletions libvips/foreign/heifsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,9 @@ vips_foreign_save_heif_build(VipsObject *object)
!vips_object_argument_isset(object, "effort"))
heif->effort = 9 - heif->speed;

/* Disable chroma subsampling by default when the "lossless" param
* is being used.
/* The "lossless" param implies no chroma subsampling.
*/
if (vips_object_argument_isset(object, "lossless") &&
!vips_object_argument_isset(object, "subsample_mode"))
if (heif->lossless)
heif->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_OFF;

/* Default 12 bit save for 16-bit images.
Expand Down
9 changes: 6 additions & 3 deletions libvips/foreign/jp2ksave.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,14 @@ vips_foreign_save_jp2k_build(VipsObject *object)
return -1;
}

/* The "lossless" param implies no chroma subsampling.
*/
if (jp2k->lossless)
jp2k->subsample_mode = VIPS_FOREIGN_SUBSAMPLE_OFF;

switch (jp2k->subsample_mode) {
case VIPS_FOREIGN_SUBSAMPLE_AUTO:
jp2k->subsample =
!jp2k->lossless &&
jp2k->Q < 90 &&
jp2k->subsample = jp2k->Q < 90 &&
(save->ready->Type == VIPS_INTERPRETATION_sRGB ||
save->ready->Type == VIPS_INTERPRETATION_RGB16) &&
save->ready->Bands == 3;
Expand Down

0 comments on commit cc4de1d

Please sign in to comment.