diff --git a/ChangeLog b/ChangeLog index 68d42d7e5d..28c213b3d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -30,12 +30,12 @@ - threaded write in tiffsave for tiled JPEG and JPEG2000 [jcupitt] - add vips_thread_execute() to the public API [jcupitt] - add "keep" flag to foreign savers, deprecate "strip" [a3mar] +- improve scRGB handling [jcupitt] 18/9/23 8.14.5 - fix a crash with alpha plus icc_import and icc_export [jcupitt] - fix a crash in jxlsave [jcupitt] -- improve scRGB handling [jcupitt] 15/8/23 8.14.4 diff --git a/libvips/foreign/jxlsave.c b/libvips/foreign/jxlsave.c index 8d3b13169a..19230e6e53 100644 --- a/libvips/foreign/jxlsave.c +++ b/libvips/foreign/jxlsave.c @@ -66,6 +66,8 @@ * - add animation support * * - libjxl is currently missing error messages (I think) + * + * - add support encoding images with > 4 bands. */ #define OUTPUT_BUFFER_SIZE (4096) @@ -226,7 +228,7 @@ vips_foreign_save_jxl_build(VipsObject *object) { VipsForeignSave *save = (VipsForeignSave *) object; VipsForeignSaveJxl *jxl = (VipsForeignSaveJxl *) object; - VipsImage **t = (VipsImage **) vips_object_local_array(object, 5); + VipsImage **t = (VipsImage **) vips_object_local_array(object, 2); #ifdef HAVE_LIBJXL_0_7 JxlEncoderFrameSettings *frame_settings; @@ -282,6 +284,17 @@ vips_foreign_save_jxl_build(VipsObject *object) return -1; in = t[0]; + /* Mimics VIPS_SAVEABLE_RGBA. + * FIXME: add support encoding images with > 4 bands. + */ + if (in->Bands > 4) { + if (vips_extract_band(in, &t[1], 0, + "n", 4, + NULL)) + return -1; + in = t[1]; + } + JxlEncoderInitBasicInfo(&jxl->info); switch (in->BandFmt) { @@ -523,9 +536,7 @@ vips_foreign_save_jxl_class_init(VipsForeignSaveJxlClass *class) foreign_class->suffs = vips__jxl_suffs; - /* This lets throuigh scRGB too, which we then save as jxl float. - */ - save_class->saveable = VIPS_SAVEABLE_RGBA; + save_class->saveable = VIPS_SAVEABLE_ANY; save_class->format_table = bandfmt_jxl; VIPS_ARG_INT(class, "tier", 10,