Closed waclaw66 closed 9 months ago
This image appears to be a RAW camera image masquerading as a "multiband" TIFF. I suspect it has three band RGB pixel data but the TIFF header says it only has one band.
The metadata suggests it is from a Samsung SM-G780G and the software on Samsung devices is notorious for generating images that don't follow standards.
You'll need to process it with something that can handle RAW images from Samsung devices first, perhaps libraw or dcraw.
Thanks for explanation. It does only for raw images with longer exposure time (e.g. >4s). Images with shorter exposure time taken in Pro mode can be processed without problem. <-- Not true, all raw images are affected.
Another example...
File Name : 20231108_081401.dng
Directory : .
File Size : 25 MB
File Modification Date/Time : 2023:11:08 09:26:04+01:00
File Access Date/Time : 2023:11:08 09:26:04+01:00
File Inode Change Date/Time : 2023:11:08 09:26:04+01:00
File Permissions : -rw-r--r--
File Type : DNG
File Type Extension : dng
MIME Type : image/x-adobe-dng
Exif Byte Order : Little-endian (Intel, II)
Image Width : 4032
Image Height : 3024
Bits Per Sample : 16
Compression : Uncompressed
Photometric Interpretation : Color Filter Array
Image Description :
Make : samsung
Camera Model Name : SM-G780G
Orientation : Horizontal (normal)
Samples Per Pixel : 1
Rows Per Strip : 1
X Resolution : 72
Y Resolution : 72
Planar Configuration : Chunky
Resolution Unit : inches
Software : G780GXXS7EWI3
Modify Date : 2023:11:08 08:14:02
Subfile Type : Reduced-resolution image
Strip Offsets : 26208
Strip Byte Counts : 230400
CFA Repeat Pattern Dim : 2 2
CFA Pattern 2 : 1 0 2 1
Copyright :
Exposure Time : 1/20
F Number : 1.8
ISO : 50
Exif Version : 0221
Date/Time Original : 2023:11:08 08:14:02
Exposure Compensation : 0
Focal Length : 5.4 mm
Focal Length In 35mm Format : 26 mm
Sub Sec Time : 352581
Sub Sec Time Original : 352581
Offset Time : +01:00
Offset Time Original : +01:00
TIFF-EP Standard ID : 1 0 0 0
DNG Version : 1.6.0.0
DNG Backward Version : 1.1.0.0
Unique Camera Model : SM-G780G
CFA Plane Color : Red,Green,Blue
CFA Layout : Rectangular
Black Level Repeat Dim : 2 2
Black Level : 0 0 0 0
White Level : 1023
Default Scale : 1 1
Default Crop Origin : 0 0
Default Crop Size : 4032 3024
Color Matrix 1 : 0.6787109375 -0.1640625 -0.0810546875 -0.3935546875 1.193359375 0.166015625 -0.1015625 0.2685546875 0.4541015625
Color Matrix 2 : 1.280273438 -0.634765625 0.0419921875 -0.3486328125 1.236328125 0.4111328125 -0.0625 0.203125 0.6064453125
Camera Calibration 1 : 1.017578125 0 0 0 1 0 0 0 0.9677734375
Camera Calibration 2 : 1.017578125 0 0 0 1 0 0 0 0.9677734375
As Shot Neutral : 0.494140625 1 0.5595703125
Calibration Illuminant 1 : D65
Calibration Illuminant 2 : Standard Light A
Active Area : 0 0 3024 4032
Forward Matrix 1 : 0.6650390625 0.2265625 0.072265625 0.2216796875 0.97265625 -0.1943359375 0.01171875 -0.3896484375 1.203125
Forward Matrix 2 : 0.609375 0.2958984375 0.05859375 0.1376953125 1.072265625 -0.2099609375 0.037109375 -0.78125 1.569335938
Opcode List 2 : GainMap, GainMap, GainMap, GainMap
Noise Profile : 7.546851e-05 2.749345e-08 7.546851e-05 2.749345e-08 7.546851e-05 2.749345e-08
Aperture : 1.8
CFA Pattern : [Green,Red][Blue,Green]
Image Size : 4032x3024
Megapixels : 12.2
Scale Factor To 35 mm Equivalent: 4.8
Shutter Speed : 1/20
Date/Time Original : 2023:11:08 08:14:02.352581+01:00
Modify Date : 2023:11:08 08:14:02.352581+01:00
Circle Of Confusion : 0.006 mm
Field Of View : 69.4 deg
Focal Length : 5.4 mm (35 mm equivalent: 26.0 mm)
Hyperfocal Distance : 2.60 m
Light Value : 7.0
I've checked that Imagemagick can convert them without any problem.
Imagemagick uses dcraw to decode this image:
$ identify -verbose 20231108_081716.dng
identify identify: "dcraw" -c -w -6 -T "20231108_081716.dng" > "/tmp/gmZkiVom".
Image: 20231108_081716.dng
Format: DCRAW
...
This does not look like a valid TIFF image.
That's what I got...
# identify -verbose 20231108_081716.dng
Image:
Filename: 20231108_081716.dng
Permissions: rw-r--r--
Format: DNG (Digital Negative)
Class: DirectClass
Geometry: 4032x3024+0+0
Units: Undefined
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianness: Undefined
Depth: 16-bit
Channels: 3.0
Channel depth:
Red: 16-bit
Green: 16-bit
Blue: 16-bit
Channel statistics:
Pixels: 12192768
Red:
min: 0 (0)
max: 65535 (1)
mean: 18438.4 (0.281352)
median: 0 (0)
standard deviation: 22808.6 (0.348037)
kurtosis: -1.01076
skewness: 0.727245
entropy: 0.465742
Green:
min: 0 (0)
max: 65535 (1)
mean: 6761.74 (0.103178)
median: 0 (0)
standard deviation: 12280.1 (0.187382)
kurtosis: 0.622227
skewness: 1.46396
entropy: 0.301047
Blue:
min: 0 (0)
max: 65535 (1)
mean: 13775.5 (0.2102)
median: 1084 (0.0165408)
standard deviation: 17807.7 (0.271729)
kurtosis: -0.718843
skewness: 0.8674
entropy: 0.498238
Image statistics:
Overall:
min: 0 (0)
max: 65535 (1)
mean: 12991.9 (0.198243)
median: 361.333 (0.00551359)
standard deviation: 17632.2 (0.269049)
kurtosis: -0.00149026
skewness: 1.138
entropy: 0.421675
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: 4032x3024+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2023-11-08T07:17:58+00:00
date:modify: 2023-11-08T07:17:58+00:00
date:timestamp: 2023-11-08T10:04:05+00:00
dng:camera.model.name: SM-G780G
dng:create.date: 2023-11-08T07:17:22+00:00
dng:exposure.time: 1/0
dng:f.number: 1.8
dng:focal.length: 5.4 mm
dng:focal.length.in.35mm.format: 26 mm
dng:gps.altitude: 0.0 m
dng:gps.latitude: 0 deg 0' 0.00" N
dng:gps.longitude: 0 deg 0' 0.00" W
dng:iso.setting: 50
dng:lens: 0.0-0.0mm f/0.0-0.0
dng:lens.f.stops: 0.00
dng:lens.type:
dng:make: Samsung
dng:max.aperture.at.max.focal: 0.0
dng:max.aperture.at.min.focal: 0.0
dng:max.aperture.value: 0.0
dng:max.focal.length: 0.0 mm
dng:min.focal.length: 0.0 mm
dng:software: G780GXXS7EWI3
dng:wb.rb.levels: 1.835125 2.003914 1.000000 0.000000
signature: 28d5553975bf7905603386dd472bbac2bd0282c8a89dbaff645e51636125ed2d
Artifacts:
verbose: true
Tainted: False
Filesize: 23.3908MiB
Number pixels: 12.1928M
Pixel cache type: Memory
Pixels per second: 28.8798MP
User time: 1.470u
Elapsed time: 0:01.422
Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org
I've just noticed you cross-posted this at https://github.com/immich-app/immich/issues/4899
My understanding is that Immich compiles its own (patched) libraw+imagemagick+libvips combo, so this might relate to https://github.com/libvips/libvips/pull/3735
I think this is the same issue as https://github.com/libvips/libvips/issues/3380. With libvips v8.15.0-rc2, I see:
$ VIPS_WARNING=0 vipsheader 20231108_08*.dng
20231108_081401.dng: 4032x3024 ushort, 1 band, multiband, tiffload
20231108_081716.dng: 4032x3024 ushort, 1 band, multiband, tiffload
But, when building with -Dtiff=disabled
:
$ vipsheader 20231108_08*.dng
20231108_081401.dng: 4032x3024 ushort, 3 bands, rgb16, magickload
20231108_081716.dng: 4032x3024 ushort, 3 bands, rgb16, magickload
PR https://github.com/libvips/libvips/pull/3735 would only help for the RAW/DNG formats defined here: https://github.com/ImageMagick/ImageMagick/blob/fb02f76da911581ad728cb830f5ebb1660692879/coders/dng.h#L19
I'll close as there's not a lot we can do in sharp - please subscribe to https://github.com/libvips/libvips/issues/3380 for possible updates.
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of
sharp
that is not the latest, please open an issue against that package instead.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?What are the steps to reproduce?
Run snippet below.
What is the expected behaviour?
Run without errors.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Please provide sample image(s) that help explain this problem
20231108_081716.zip