Page MenuHomePhabricator

PNG thumbnail has wrong colors for a huge (>2GB) TIFF image file (fixed in upstream vips 8.10)
Open, LowPublicBUG REPORT

Description

Event Timeline

Aklapper renamed this task from Thumbnail rendering bug in (huge: > 2GB) TIFF to PNG thumbnail has wrong colors for a huge (>2GB) TIFF image file.Aug 26 2021, 4:16 PM

My guess is that the problem isn't the file size, but something to do with the colorspace. I don't think I need to do the calculation to say that this file is initially scaled by vips.

metadata
$ vipsheader badtiff.tiff                                                                             

(vipsheader:8822): VIPS-WARNING **: 11:36:55.016: Incorrect value for "RichTIFFIPTC"; tag ignored

(vipsheader:8822): VIPS-WARNING **: 11:36:55.022: Incorrect value for "RichTIFFIPTC"; tag ignored

(vipsheader:8822): VIPS-WARNING **: 11:36:55.024: Incorrect value for "RichTIFFIPTC"; tag ignored

(vipsheader:8822): VIPS-WARNING **: 11:36:55.026: Incorrect value for "RichTIFFIPTC"; tag ignored

(vipsheader:8822): VIPS-WARNING **: 11:36:55.027: Incorrect value for "RichTIFFIPTC"; tag ignored
badtiff.tiff: 15575x38598 uchar, 4 bands, cmyk, tiffload
$ exiftool badtiff.tiff                                                                               
ExifTool Version Number         : 12.26
File Name                       : badtiff.tiff
Directory                       : .
File Size                       : 2043 MiB
File Modification Date/Time     : 2021:08:30 23:17:21-04:00
File Access Date/Time           : 2021:08:30 23:22:28-04:00
File Inode Change Date/Time     : 2021:08:30 23:21:59-04:00
File Permissions                : -rw-r--r--
File Type                       : TIFF
File Type Extension             : tif
MIME Type                       : image/tiff
Exif Byte Order                 : Big-endian (Motorola, MM)
Subfile Type                    : Full-resolution image
Image Width                     : 15575
Image Height                    : 38598
Bits Per Sample                 : 8 8 8 8
Compression                     : LZW
Photometric Interpretation      : CMYK
Strip Offsets                   : (Binary data 100658 bytes, use -b option to extract)
Samples Per Pixel               : 4
Rows Per Strip                  : 4
Strip Byte Counts               : (Binary data 67549 bytes, use -b option to extract)
X Resolution                    : 430
Y Resolution                    : 430
Planar Configuration            : Chunky
Resolution Unit                 : inches
Software                        : Adobe Photoshop CS Windows
Modify Date                     : 2009:05:13 15:09:09
Predictor                       : Horizontal differencing
XMP Toolkit                     : XMP toolkit 3.0-28, framework 1.6
About                           : uuid:a00c0322-3f88-11de-9420-a4843377f42b
Native Digest                   : 36864,40960,40961,37121,37122,40962,40963,37510,40964,36867,36868,33434,33437,34850,34852,34855,34856,37377,37378,37379,37380,37381,37382,37383,37384,37385,37386,37396,41483,41484,41486,41487,41488,41492,41493,41495,41728,41729,41730,41985,41986,41987,41988,41989,41990,41991,41992,41993,41994,41995,41996,42016,0,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,22,23,24,25,26,27,28,30;682E33D3FA2231FFF275E82C21E7D936
Color Mode                      : CMYK
ICC Profile Name                : Ep9600-02-LiaoBoJuan-071019
History                         : 
Orientation                     : Horizontal (normal)
Create Date                     : 2009:05:13 15:09:09+08:00
Creator Tool                    : Adobe Photoshop CS Windows
Metadata Date                   : 2009:05:13 15:09:09+08:00
Instance ID                     : uuid:97AAA84AC4C5DD11933CA5C2CAEDCD63
Derived From Instance ID        : uuid:E9D80E5CC6E311DDAE7DAF4E8B560401
Derived From Document ID        : uuid:96AAA84AC4C5DD11933CA5C2CAEDCD63
Document ID                     : adobe:docid:photoshop:a00c0321-3f88-11de-9420-a4843377f42b
Format                          : image/tiff
Current IPTC Digest             : 8cd1cec100db56eee4951930207e3206
Application Record Version      : 2
IPTC Digest                     : 460cf28926b856dab09c01a1b0a79077
Displayed Units X               : inches
Displayed Units Y               : inches
Print Style                     : Centered
Print Position                  : 0 0
Print Scale                     : 1
Global Angle                    : 30
Global Altitude                 : 30
Copyright Flag                  : False
URL List                        : 
Slices Group Name               : 胡湄玉堂富贵轴-HX总-修裂缝
Num Slices                      : 1
Pixel Aspect Ratio              : 1
Photoshop Thumbnail             : (Binary data 4605 bytes, use -b option to extract)
Has Real Merged Data            : Yes
Writer Name                     : Adobe Photoshop
Reader Name                     : Adobe Photoshop CS
Color Space                     : Uncalibrated
Exif Image Width                : 15575
Exif Image Height               : 38598
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.1.0
Profile Class                   : Output Device Profile
Color Space Data                : CMYK
Profile Connection Space        : Lab
Profile Date Time               : 2007:10:19 06:59:32
Profile File Signature          : acsp
Primary Platform                : Microsoft Corporation
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : 
Device Model                    : 
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Media-Relative Colorimetric
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Unknown (LOGO)
Profile ID                      : 0
Profile Copyright (en-UK)       : Copyright by LOGO GmbH, Steinfurt
Profile Description (en-UK)     : Ep9600-02-LiaoBoJuan-071019
Chromatic Adaptation            : 1 0 0 0 1 0 0 0 1
Media White Point               : 0.80209 0.82645 0.73715
Gray Tone Reproduction Curve    : (Binary data 1034 bytes, use -b option to extract)
A To B1                         : (Binary data 508444 bytes, use -b option to extract)
B To A1                         : (Binary data 294800 bytes, use -b option to extract)
A To B0                         : (Binary data 508444 bytes, use -b option to extract)
B To A0                         : (Binary data 294800 bytes, use -b option to extract)
A To B2                         : (Binary data 508444 bytes, use -b option to extract)
B To A2                         : (Binary data 294800 bytes, use -b option to extract)
Gamut                           : (Binary data 76038 bytes, use -b option to extract)
Image Size                      : 15575x38598
Megapixels                      : 601.2

Vips tries to scale the image, but libpng doesn't like the ICC profile.

$ vips shrink badtiff.tiff vips_result.png 35 35
vipspng: profile 'icc': 'CMYK': invalid ICC profile color space
vips2png: unable to write "vips_result.png"

Then the T219569: libvips thumbnail generation fails for TIFF files with invalid ICC profiles mitigation kicks in, and forces vips to write the PNG using an sRGB profile. Something goes wrong there, and we get the off-color image.

Upstream fixed the root issue in vips 8.10, and the image renders fine in vips 8.11 (we're on 8.4.5 now, buster has 8.7.4, would have to wait for bullseye for 8.10.5).

vips_result.png (1×445 px, 2 MB)

I'd normally suggest something like using ImageMagick to convert the file from CMYK to sRGB, but I already had to get out the oomkiller just trying to run display badtiff.tiff on my machine.

Aklapper renamed this task from PNG thumbnail has wrong colors for a huge (>2GB) TIFF image file to PNG thumbnail has wrong colors for a huge (>2GB) TIFF image file (fixed in upstream vips 8.10).Sep 8 2021, 8:35 PM