libvips / libvips

A fast image processing library with low memory needs.
https://libvips.github.io/libvips/
GNU Lesser General Public License v2.1
9.72k stars 676 forks source link

jxlsave fails with "jxlsave: error JxlEncoderSetBasicInfo" for a 32-bit (?) CMYK colour TIFF #3880

Closed JinEnMok closed 8 months ago

JinEnMok commented 8 months ago

Bug report

Trying to convert any of the TIFF images from NASA's "Visions of the Future" gallery fails with jxlsave: error JxlEncoderSetBasicInfo. Since this seems to be a 32-bit colour (see below for ImageMagick's identify) image, this appears to be an issue not dissimilar to #2830, although that one's marked resolved.

pngsave and jpegsave appear to work as intended on the same file.

To Reproduce Steps to reproduce the behavior:

  1. Use any of the TIFF images from "here", the smallest one (24MB) is this
  2. try vips jxlsave with any quality/effort setting
  3. See error

Expected behavior VIPS converts the TIFF to JXL without any hiccups.

Actual behavior VIPS produces an error (jxlsave: error JxlEncoderSetBasicInfo) and converts nothing.

Environment

vipsheader --all .\kepler186f.tif: 8175x11775 uchar, 4 bands, cmyk, tiffload width: 8175 height: 11775 bands: 4 format: uchar coding: none interpretation: cmyk xoffset: 0 yoffset: 0 xres: 11,811 yres: 11,811 filename: .\kepler186f.tif vips-loader: tiffload n-pages: 1 icc-profile-data: 557168 bytes of binary data xmp-data: 14642 bytes of binary data iptc-data: 220 bytes of binary data photoshop-data: 8400 bytes of binary data resolution-unit: in bits-per-sample: 8 orientation: 1
magick identify -verbose ``` Image: Filename: .\kepler186f.tif Permissions: rw-rw-rw- Format: TIFF (Tagged Image File Format) Mime type: image/tiff Class: DirectClass Geometry: 8175x11775+0+0 Resolution: 300x300 Print size: 27.25x39.25 Units: PixelsPerInch Colorspace: CMYK Type: ColorSeparation Endianness: LSB Depth: 8-bit Channels: 4.0 Channel depth: Cyan: 8-bit Magenta: 8-bit Yellow: 8-bit Black: 8-bit Channel statistics: Pixels: 96260625 Cyan: min: 0 (0) max: 241 (0.945098) mean: 53.7115 (0.210633) median: 23 (0.0901961) standard deviation: 60.0958 (0.23567) kurtosis: 1.29277 skewness: 1.47651 entropy: 0.559342 Magenta: min: 0 (0) max: 255 (1) mean: 123.282 (0.483459) median: 123 (0.482353) standard deviation: 101.831 (0.399339) kurtosis: -1.74149 skewness: 0.150029 entropy: 0.565645 Yellow: min: 0 (0) max: 255 (1) mean: 129.453 (0.507659) median: 114 (0.447059) standard deviation: 94.4301 (0.370314) kurtosis: -1.61053 skewness: 0.147783 entropy: 0.557822 Black: min: 0 (0) max: 210 (0.823529) mean: 22.935 (0.0899411) median: 0 (0) standard deviation: 50.204 (0.196878) kurtosis: 4.02712 skewness: 2.28744 entropy: 0.289141 Image statistics: Overall: min: 0 (0) max: 255 (1) mean: 82.3453 (0.322923) median: 65 (0.254902) standard deviation: 76.6403 (0.30055) kurtosis: 0.491966 skewness: 1.01544 entropy: 0.492988 Total ink density: 314.118% Rendering intent: Perceptual Gamma: 0.454545 Chromaticity: red primary: (0.64,0.33,0.03) green primary: (0.3,0.6,0.1) blue primary: (0.15,0.06,0.79) white point: (0.3127,0.329,0.3583) Matte color: grey74 Background color: white Border color: srgb(223,223,223) Transparent color: black Interlace: None Intensity: Undefined Compose: Over Page geometry: 8175x11775+0+0 Dispose: Undefined Iterations: 0 Compression: LZW Orientation: TopLeft Profiles: Profile-8bim: 8400 bytes Profile-icc: 557168 bytes Profile-iptc: 220 bytes City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G City[1,90]: 0x00000000: 254700 -%G unknown[2,0]: Created Date[2,55]: 20141230 Created Time[2,60]: 000000+0000 Profile-xmp: 14642 bytes Properties: date:create: 2024-03-07T18:12:20+00:00 date:modify: 2024-03-07T18:12:43+00:00 date:timestamp: 2024-03-07T18:27:02+00:00 dc:format: image/tiff exif:ColorSpace: 65535 exif:ExifVersion: 0x30,0x32,0x32,0x31 exif:PixelXDimension: 8175 exif:PixelYDimension: 11775 icc:copyright: Copyright 2000 Adobe Systems, Inc. icc:description: U.S. Web Coated (SWOP) v2 photoshop:ColorMode: 4 photoshop:DateCreated: 2014-12-30 photoshop:ICCProfile: U.S. Web Coated (SWOP) v2 signature: e2bd0e9725a59e446e8cda99d8ec1c006bfa5bb0989dc0b9f63653f4023e177f tiff:alpha: unspecified tiff:endian: lsb tiff:photometric: separated tiff:rows-per-strip: 8 tiff:software: Adobe Photoshop CS6 (Windows) tiff:timestamp: 2016:03:21 17:03:00 xmp:CreateDate: 2016-03-21T16:59:15-07:00 xmp:CreatorTool: Adobe Photoshop CS6 (Macintosh) xmp:MetadataDate: 2016-03-21T17:03-07:00 xmp:ModifyDate: 2016-03-21T17:03-07:00 xmpMM:DocumentID: xmp.did:F595121EC1EFE5119BA8F267D490DEAB xmpMM:InstanceID: xmp.iid:F795121EC1EFE5119BA8F267D490DEAB xmpMM:OriginalDocumentID: xmp.did:F595121EC1EFE5119BA8F267D490DEAB Artifacts: verbose: true Tainted: False Filesize: 23.8116MiB Number pixels: 96.2606M Pixel cache type: Memory Pixels per second: 36.2183MP User time: 2.658u Elapsed time: 0:03.657 Version: ImageMagick 7.1.1-29 Q16-HDRI x64 0deac72:20240225 https://imagemagick.org ```
jcupitt commented 8 months ago

Hi @JinEnMok,

Looks like any CMYK image fails:

$ vips copy cmyk.jpg x.jxl
jxlsave_target: error JxlEncoderSetBasicInfo
error buffer: jxlsave_target: error JxlEncoderSetBasicInfo

I'll have a look. Thanks for reporting this.

jcupitt commented 8 months ago

I started a PR https://github.com/libvips/libvips/pull/3883 let's move any discussion there.