-
Hi, this is my first day using Magick.NET so please excuse me if this is already explained and I just did not find it. I did search GitHub and Google for quite a while. I'm working mostly with RAW images (NEF, CR2) and I want to extract the embedded preview JPG created by the camera: I only need to fallback to processing the full RAW when the embedded preview is too small. This is a matter of performance. I'm currently using LibRaw with C++ and use the Environment: For Magick.NET, I've started by using one of the samples:
This works, but loads the full RAW data and takes about 6 seconds per image, instead of the 0.5s I'm used to. I've tried various things, e.g., specifying the width and height in the constructor, providing a I could not find anything that would not load the full RAW data but only the embedded preview - which is optimized by the camera and optimal for my purposes. Is there a switch or option which tells IM.NET to load only the embedded preview, but do no other processing (basically a Ping which also reads the JPEG). |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
ImageMagick uses libraw and it should be possible to extract the jpg file. Not sure yet what the best soluton be for this. Maybe we could add a define for this to read the thumb and store that as an attribute on the image. Would probably become something like this: using (var image = new MagickImage())
{
image.Settings.SetDefine(new DngReadDefines
{
ReadThumbnail = true
});
image.Ping(FileName);
var profile = image.GetProfile("dng:thumbnail");
File.WriteAllBytes("thumbnail.jpg", profile.GetData());
} |
Beta Was this translation helpful? Give feedback.
-
Thank you for looking into this. Much appreciated! I'm totally new to Magick.NET so I cannot really make suggestions on how to best implement this within the framework. If the preview is large enough, it provides an almost instant and usually well-optimized rendition of the RAW data - created using the camera vendors algorithms. For many intents and purposes, the preview is all that's needed. And it's super fast. Maybe this would fit into how Magick.NET deals with multi-frame / multi-page files? That's how Windows WIC does it, when I recall correctly. Treating the 160px thumbnail, the JPG preview and the RAW sensor data as individual frames. Frame 0 = thumbnail, frame 1 = preview, frame 2 = full RAW image... and one can specify which frame to load via MagickReadSettings...? There is one thing to consider: Image Orientation (rotation). I'm new to Magick.NET but I understand that Magick.NET has functions to read EXIF data. |
Beta Was this translation helpful? Give feedback.
-
I decided to use the approach that I described earlier. You can load the thumbnail like this: var profile = image.GetProfile("dng:thumbnail");
using (var jpegThumbnail = new MagickImage(profile.GetData()))
{
// Correct the image orientation
jpegThumbnail.AutoOrient();
} If the thumbnail contains an exif profile it will be loaded automatically. |
Beta Was this translation helpful? Give feedback.
I decided to use the approach that I described earlier. You can load the thumbnail like this:
If the thumbnail contains an exif profile it will be loaded automatically.