lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.35k stars 1.3k forks source link

Sharp fails to provide metadata for Sony .ARW RAW files #1745

Closed przemyslawpluta closed 5 years ago

przemyslawpluta commented 5 years ago

sharp fails to provide metadata for Sony .ARW RAW files while works fine for Nikon .NEF & Canon .CR2RAW files. Running below:

await sharp('A7rII-Various-15-08-15-3.ARW').metadata();

fails with:

UnhandledPromiseRejectionWarning: Error: Input file has corrupt header: MissingRequired: TIFF directory is missing required "ImageLength" field tiff: unable to open "A7rII-Various-15-08-15-3.ARW" for input

Examples of Sony .ARW RAW files can be located in Raw Samples

exiftool provides metadata for the file without any issues nor warnings as per below:

ExifTool Version Number         : 11.30
File Name                       : A7rII-Various-15-08-15-3.ARW
Directory                       : /Raw
File Size                       : 41 MB
File Modification Date/Time     : 2019:06:06 22:03:13+01:00
File Access Date/Time           : 2019:06:06 22:15:10+01:00
File Inode Change Date/Time     : 2019:06:06 22:03:14+01:00
File Permissions                : rw-r--r--
File Type                       : ARW
File Type Extension             : arw
MIME Type                       : image/x-sony-arw
Exif Byte Order                 : Little-endian (Intel, II)
Image Description               :
Orientation                     : Horizontal (normal)
White Point                     : 0.313 0.329
Primary Chromaticities          : 0.64 0.33 0.21 0.71 0.15 0.06
Image Width                     : 8000
Image Height                    : 5320
Bits Per Sample                 : 14
Compression                     : Sony ARW Compressed
Photometric Interpretation      : Color Filter Array
Samples Per Pixel               : 1
Planar Configuration            : Chunky
X Resolution                    : 350
Y Resolution                    : 350
Resolution Unit                 : inches
CFA Repeat Pattern Dim          : 2 2
CFA Pattern 2                   : 0 1 1 2
Sony Raw File Type              : Sony Compressed RAW
Sony Tone Curve                 : 8000 10400 12900 14100
Strip Offsets                   : 723456
Rows Per Strip                  : 5320
Strip Byte Counts               : 42560000
Chromatic Aberration Correction : Auto
Distortion Correction           : Auto fixed by lens
Preview Image Start             : 141986
Preview Image Length            : 578958
Y Cb Cr Coefficients            : 0.299 0.587 0.114
Y Cb Cr Positioning             : Co-sited
Exposure Time                   : 1/800
F Number                        : 5.6
ISO                             : 100
Sensitivity Type                : Recommended Exposure Index
Recommended Exposure Index      : 100
Exif Version                    : 0230
Date/Time Original              : 2015:08:15 16:22:38
Create Date                     : 2015:08:15 16:22:38
Components Configuration        : Y, Cb, Cr, -
Compressed Bits Per Pixel       : 8
Brightness Value                : 10.70078125
Exposure Compensation           : 0
Max Aperture Value              : 1.8
Metering Mode                   : Multi-segment
Light Source                    : Unknown
Flash                           : Off, Did not fire
Focal Length                    : 55.0 mm
Rating                          : 0
Brightness                      : 0
Long Exposure Noise Reduction   : On (unused)
High ISO Noise Reduction        : Off
HDR                             : Off; Uncorrected image
WB Shift AB GM                  : 0 0
WB Shift AB GM Precise          : 0.00 0.00
Face Info Offset                : 94
Sony Date Time                  : 2015:08:15 16:22:38
Sony Image Width                : 7952
Faces Detected                  : 1
Face Info Length                : 37
Meta Version                    : DC7303320222000
Face 1 Position                 : 3785 2634 596 596
Creative Style                  : Standard
Color Temperature               : Auto
Color Compensation Filter       : 0
Scene Mode                      : Standard
Zone Matching                   : ISO Setting Used
Dynamic Range Optimizer         : Off
Image Stabilization             : Off
Color Mode                      : Standard
Full Image Size                 : 7952x5304
Preview Image Size              : 1616x1080
File Format                     : ARW 2.3.1
Quality                         : RAW + JPEG
Flash Exposure Compensation     : 0
White Balance Fine Tune         : 0
White Balance                   : Auto
Sony Model ID                   : ILCE-7RM2
Multi Frame Noise Reduction     : Off
Picture Effect                  : Off
Soft Skin Effect                : Off
Vignetting Correction           : Auto
Lateral Chromatic Aberration    : Auto
Distortion Correction Setting   : Auto
Lens Type                       : E-Mount, T-Mount, Other Lens or no lens
Lens Spec                       : FE 55mm F1.8 ZA
Auto Portrait Framed            : No
Flash Action                    : Did not fire
Electronic Front Curtain Shutter: Off
Focus Mode                      : AF-S
AF Area Mode Setting            : Flexible Spot
Flexible Spot Position          : 320 240
AF Point Selected               : n/a
AF Points Used                  : (none)
AF Tracking                     : Off
Focal Plane AF Points Used      : (none)
Multi Frame NR Effect           : Normal
Focus Location                  : 7952 5304 3976 2652
Variable Low Pass Filter        : n/a
Flash Level                     : Normal
Release Mode                    : Normal
Sequence Number                 : Single
Anti-Blur                       : Off
Shot Number Since Power Up      : 1
Sequence Image Number           : 1
Sequence File Number            : 1
Sequence Length                 : 1 file
Camera Orientation              : Horizontal (normal)
Quality 2                       : RAW + JPEG
Sony Image Height               : 5304
Model Release Year              : 2015
ISO Setting                     : 100
ISO Auto Min                    : 100
ISO Auto Max                    : 6400
Ambient Temperature             : 23 C
AF Area Mode                    : Flexible Spot
Focus Position 2                : 214
Camera Temperature              : 26 C
Exposure Program                : Aperture-priority AE
Intelligent Auto                : Off
Sony ISO                        : 100
Base ISO                        : 100
Stops Above Base ISO            : 0
Sony Exposure Time 2            : 1/777
Sony Max Aperture Value         : 1.8
Sony Image Width Max            : 7968
Sony Image Height Max           : 5320
Picture Effect 2                : Off
Lens Zoom Position              : 0%
Battery Temperature             : 32.2 C
Battery Level                   : 37%
Lens Mount 2                    : E-mount
Lens Type 3                     : Sony FE 55mm F1.8 ZA
Camera E-mount Version          : 1.50
Lens E-mount Version            : 1.31
Lens Firmware Version           : Ver.02.000
Tiff Metering Image Width       : 44
Tiff Metering Image Height      : 30
Tiff Metering Image             : (Binary data 2640 bytes, use -b option to extract)
Release Mode 3                  : Normal
Self Timer                      : Off
Flash Mode                      : Fill-flash
HDR Setting                     : Off
Picture Profile                 : Gamma Cine1 (PP5)
WB RGB Levels                   : 612 256 399
Min Focal Length                : 55.0 mm
Distortion Corr Params Number   : 16 (Full-frame)
Shutter                         : Mechanical
Flash Status                    : No Flash present
Shutter Count                   : 1189
Sony Exposure Time              : 1/777
Sony F Number                   : 5.7
Shutter Count 2                 : 1189
Sony Time Min Sec               : 22:38
Release Mode 2                  : Normal
Internal Serial Number          : 5eff00008809
Lens Mount                      : E-mount
Lens Format                     : Full-frame
Lens Type 2                     : Sony FE 55mm F1.8 ZA
Distortion Corr Params Present  : Yes
Lens Spec Features              : FE ZA
Shutter Count 3                 : 1189
User Comment                    : 
Flashpix Version                : 0100
Color Space                     : Uncalibrated
Exif Image Width                : 7952
Exif Image Height               : 5304
Interoperability Index          : R03 - DCF option file (Adobe RGB)
Interoperability Version        : 0100
File Source                     : Digital Camera
Scene Type                      : Directly photographed
Custom Rendered                 : Normal
Exposure Mode                   : Auto
Digital Zoom Ratio              : 1
Focal Length In 35mm Format     : 55 mm
Scene Capture Type              : Standard
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : Normal
Lens Info                       : 55mm f/1.8
Lens Model                      : FE 55mm F1.8 ZA
Gamma                           : 2.2
PrintIM Version                 : 0300
SR2 Sub IFD Offset              : 47126
SR2 Sub IFD Length              : 56958
SR2 Sub IFD Key                 : 0x44332211
Black Level                     : 512 512 512 512
WB RGGB Levels Auto             : 2452 1024 1024 1596
WB RGGB Levels                  : 2452 1024 1024 1596
Color Matrix                    : 1253 -194 -35 0 1024 0 106 -106 1024
WB RGB Levels Daylight          : 2444 1024 1612
WB RGB Levels Cloudy            : 2640 1024 1476
WB RGB Levels Tungsten          : 1504 1024 2904
WB RGB Levels Flash             : 2692 1024 1452
WB RGB Levels 4500K             : 2200 1024 1812
WB RGB Levels Shade             : 2912 1024 1328
WB RGB Levels Fluorescent       : 2228 1024 2280
WB RGB Levels Fluorescent P1    : 2368 1024 1692
WB RGB Levels Fluorescent P2    : 2656 1024 1560
WB RGB Levels Fluorescent M1    : 1768 1024 2788
WB RGB Levels 8500K             : 3068 1024 1256
WB RGB Levels 6000K             : 2616 1024 1492
WB RGB Levels 3200K             : 1680 1024 2516
WB RGB Levels 2500K             : 1304 1024 3504
White Level                     : 15360 15360 15360
Vignetting Corr Params          : 16 0 32 96 224 384 608 864 1120 1408 1696 2016 2240 2656 3488 4928 6528
Chromatic Aberration Corr Params: 32 384 384 384 384 384 384 256 256 256 256 128 128 128 128 128 0 -256 -256 -256 -384 -384 -256 -256 -256 -256 -256 -256 -128 -128 -128 -128 0
Distortion Corr Params          : 16 -4 0 4 10 17 25 34 41 48 51 51 47 35 13 -19 -67
Subfile Type                    : Reduced-resolution image
Make                            : SONY
Camera Model Name               : ILCE-7RM2
Software                        : ILCE-7RM2 v1.00
Modify Date                     : 2015:08:15 16:22:38
Thumbnail Offset                : 38964
Thumbnail Length                : 6606
Aperture                        : 5.6
Blue Balance                    : 1.558594
CFA Pattern                     : [Red,Green][Green,Blue]
Focus Distance 2                : 18.31 m
Image Size                      : 8000x5320
Lens ID                         : Sony FE 55mm F1.8 ZA
Megapixels                      : 42.6
Preview Image                   : (Binary data 578958 bytes, use -b option to extract)
Red Balance                     : 2.394531
Scale Factor To 35 mm Equivalent: 1.0
Shutter Speed                   : 1/800
Thumbnail Image                 : (Binary data 6606 bytes, use -b option to extract)
Circle Of Confusion             : 0.030 mm
Field Of View                   : 36.2 deg
Focal Length                    : 55.0 mm (35 mm equivalent: 55.0 mm)
Hyperfocal Distance             : 17.98 m
Light Value                     : 14.6
lovell commented 5 years ago

Please see https://github.com/libvips/libvips/issues/1304