-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
vips_magickload behaves differently from vips_magickload_buffer when dealing with NEF files #3380
Comments
ImageMagick doesn't have a buffer recognizer for Nikon's NEF file format. Since this file format uses the standard TIFF header, it tries to load the buffer through its TIFF loader. libvips has a special path to workaround this limitation of *magick, but that does not include support for NEF. I had a quick attempt to add a NEF sniffer for this, see e.g. commit kleisauke@ab5d0e3, but somehow(?) this would cause a regression on the file-based loader, as it outputs |
Edit: Sorry I misunderstood your comment. That's weird. |
I just reported this upstream at ImageMagick/ImageMagick#6242. |
Resolves: libvips#3380.
I just opened PR #3460 for this. |
I can see that #3460 did not actually include a fix for this @kleisauke. Do you have any ideas on how we can reliably differentiate between NEF and TIFF files? |
@uhthomas AFAIK, the only reliable way is to get parse the make TIFF tag and check for This would also mean that the magick sniffer needs to inspect more than 256 bytes, which would probably affect performance. Looking at the linked issues, I think the issue is that libvips/libvips/foreign/tiffload.c Lines 181 to 183 in 8d5f331
libvips/libvips/foreign/magick7load.c Lines 365 to 368 in 8d5f331
One way to fix this is to prevent TIFF-based RAW images from being loaded via libtiff, see e.g. commit kleisauke@a061854 (this feels quite hackish 😅). A dedicated LibRaw/RawSpeed loader would make more sense, please subscribe to #2075 for updates regarding this. |
Yes, the libvips TIFF loader is quite a bit quicker than the imagemagick one, so it needs to be higher priority. As you say, the best solution is probably adding a libraw loader to libvips. Someone just neds to do the work heh. |
We fixed the issue for now by compiling libvips without libtiff. Adding libraw support would be amazing, but the |
Bug report
Describe the bug
When loading a NEF file vips_magickload produces a image of the correct dimension while vips_magickload_buffer produces a image of dimension 160x120 (probably some embedded thumbnail). This small image is also produced when loading the image as a TIFF (which is what libvips identifies the image as).
To Reproduce
Steps to reproduce the behavior:
4284 160
not the expected4284 4284
.Expected behavior
Both methods should produce the same image.
Actual behavior
Loading from buffer produces a much smaller image.
Environment
The text was updated successfully, but these errors were encountered: