-
-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to open RAW images #1304
Comments
Hello @rps01, libvips does not support camera RAW files directly. You'll need to convert to TIFF using something like dcraw first. |
@jcupitt |
libvips will attempt to load unknown files via libMagick, so if you can configure your imagemagick to load Sony RAW files, it should work. |
Running Format Module Mode Description
-------------------------------------------------------------------------------
3FR DNG r-- Hasselblad CFV/H3D39II
3G2 MPEG r-- Media Container
3GP MPEG r-- Media Container
AAI* AAI rw+ AAI Dune image
AI PDF rw- Adobe Illustrator CS2
ART* ART rw- PFS: 1st Publisher Clip Art
ARW DNG r-- Sony Alpha Raw Image Format
... With Base filename: A7rII-Various-15-08-15-3.ARW
Format: ARW (Sony Alpha Raw Image Format)
Class: DirectClass
Geometry: 8000x5320+0+0
Units: Undefined
Colorspace: sRGB
Type: TrueColor
Base type: Undefined
Endianess: Undefined
Depth: 16-bit
Channel depth:
Red: 16-bit
Green: 16-bit
Blue: 16-bit
Channel statistics:
Pixels: 42560000
Red:
min: 0 (0)
max: 63796 (0.973465)
mean: 21089.1 (0.321799)
standard deviation: 10425.6 (0.159084)
kurtosis: -0.776482
skewness: -0.587452
entropy: 0.947934
Green:
min: 0 (0)
max: 61350 (0.936141)
mean: 24252.9 (0.370076)
standard deviation: 11027.7 (0.168272)
kurtosis: -0.482587
skewness: -0.920075
entropy: 0.942753
Blue:
min: 0 (0)
max: 53579 (0.817563)
mean: 25478 (0.388769)
standard deviation: 15691.2 (0.239432)
kurtosis: -1.5413
skewness: -0.308184
entropy: 0.933881
Image statistics:
Overall:
min: 0 (0)
max: 63796 (0.973465)
mean: 23606.7 (0.360215)
standard deviation: 12381.5 (0.18893)
kurtosis: -1.02245
skewness: -0.371304
entropy: 0.941523
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 8000x5320+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2019-06-07T10:10:00+00:00
date:modify: 2019-06-07T10:10:00+00:00
dng:Aperture: F/5.6
dng:AspectRatio: 1.503759
dng:ChannelMultipliers: 2.394531 1.000000 1.558594 1.000000
dng:CreateID: 1
dng:Crop: 0 0 8000 5320
dng:EXIFSource: DCRaw
dng:FocalLength: 55.0 mm
dng:Green: 1.027
dng:ISOSpeed: 100
dng:Make: Sony
dng:MatrixInputProfile: Color matrix
dng:Model: ILCE-7RM2
dng:Orientation: 0
dng:Rotation: 0.000000
dng:Shutter: 1/800.0 s
dng:sRGBOutputProfile: sRGB
dng:Temperature: 4780
dng:Timestamp: Sat Aug 15 16:22:38 2015
dng:WB: Camera WB
dng:WBFineTuning: 0
png:IHDR.bit-depth-orig: 16
png:IHDR.bit_depth: 16
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 8000, 5320
png:sRGB: intent=0 (Perceptual Intent)
png:text: 2 tEXt/zTXt/iTXt chunks were found
signature: 0161efe1bcfda28849039417aaaba574d96bab65427ecbed0f73b4585dbabcc6
Software: UFRaw
Source: SonyILCE-7RM2
Artifacts:
verbose: true
Tainted: False
Filesize: 197.932MiB
Number pixels: 42560000
Pixels per second: 15.0814MP
User time: 2.820u
Elapsed time: 0:03.822
Version: ImageMagick 7.0.8-44 Q16 x86_64 2019-05-11 https://imagemagick.org While attempt to get metadata 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 |
It looks like Sony RAW files are TIFFs with extra fields, so libvips is trying to load them itself with libtiff and not falling back to imagemagick. Will libvips convert to a regular TIFF successfully?
|
Yes ... running below produces expected vips magickload A7rII-Various-15-08-15-3.ARW A7rII-Various-15-08-15-3.TIFF |
That's good. I don't think the command-line For example, in Python you could write: import os
import pyvips
if os.path.splitext(filename)[1] == 'ARW':
img = pyvips.Image.magickload(filename, access='sequential')
thumb = img.thumbnail_image(128)
else:
img = pyvips.Image.thumbnail(filename)
img.write_to_file('thumb.jpg') It'd be something very similar for PHP / C# / Ruby / Go / Rust / JavaScript / etc. |
I need to extract While this works fine with |
vipsheader A7rII-Various-15-08-15-3.ARW
(vipsheader:9898): VIPS-WARNING **: 12:11:03.911: Unknown field with tag 50341 (0xc4a5) encountered
(vipsheader:9898): VIPS-WARNING **: 12:11:03.912: Unknown field with tag 50341 (0xc4a5) encountered
vipsheader: MissingRequired: TIFF directory is missing required "ImageLength" field
tiff: unable to open "A7rII-Various-15-08-15-3.ARW" for input |
Yes, that's right, it's trying to use the TIFF loader. At the moment the Would that fix your problem? |
Sounds like a solution that could work. |
We were testing for TIFF by checking the magic number at the head of the file. However, formats like ARW are TIFF-like without being TIFF, and will not load with tiffload. Instead, try reading the whole of the first directory. This is enough to stop tiffload trying to load files where it will simply fail immediately, and make libvips fall back to eg. imagemagick. see #1304
OK, it seems to work now, though it's not quick. I see:
It's trying to load the first directory with libtiff and failing, then falling back tom imagemagick. IM in turn is shelling out to This works too:
Though it's even slower: it's converting the file once to get the header, then (unfortunately) converting again to get the pixels. |
Overall it's probably better when it resolves with outcome even if it takes longer than fail fast without outcome. |
I found a speedup: it's down to 15s for This improvement should be in 8.8.1, thanks for pointing it out! |
OK, 8.8.1 is out now with this improvement. Thanks! |
Unable to open ARW asset for generating a JPG thumbnail using libvips
Libvips version : vips-8.7.4
Command: vipsthumbnail example1.arw -o tn_%s.jpg --size 1280x1280
The text was updated successfully, but these errors were encountered: