unpack_thumb unpacks previews instead

Upon using ExifRead (https://pypi.org/project/ExifRead/) to processes exif metadata from an image and using that to extract the Jpeg Thumbnail, we came to know that the extract_thumb method, instead of extracting the Jpeg Thumbnail, will extract the Jpeg Preview of a RAW image. Is this a desired behavior and if so, is there a way to extract the actual Jpeg Thumbnail from the image?

Also, in case the Jpeg Preview is missing, will Libraw report and error or extract the Jpeg Thumbnail instead?

More information about this issue can be found at the discussion here: https://github.com/letmaik/rawpy/issues/96



unpack_thumb() provides

unpack_thumb() provides largest available thumbnail/preview/whatever-it-called.

-- Alex Tutubalin @LibRaw LLC

pixel position of thumbnail image vs. of raw image

Dear Alex,
first of all, many thanks for the wonderful libraw and your effort.

I'm currently dealing with Canon R5 CR3.
I can sucessfully decode the largest thumbnail(JPEG 1620x1080) using this following code.
rawimgthumb = rawp->dcraw_make_mem_thumb(&err); //store unpacked and processed raw image

Mat rawData(1, rawimgthumb->data_size, CV_8UC1, (void*)rawp->imgdata.thumbnail.thumb);
thumbimg_file = imdecode(rawData, 1); //BGR

Howerver, it seems that the start pxiel(left-top conner) of the decoded thumbnail image is not the same of the start pixel of the raw image(8191x5463 or with frame 8352x5586).

How can we match the exackt position between the thumbnail and the raw image?
Is there any parameter about the croping region of the thumbnail from raw image?

Thank you for your response in advance.



We don't know of a general

We don't know of a general answer to this question that will always work.
For example:

  • Some previews (on some cameras) contain a black border on the right/left, which is not part of the RAW image, so no pixel in RAW corresponds to the left-top (or any) preview image corner.
  • The lens geometry correction has been applied to the preview, so its edges do not correspond to any straight horizontal/vertical line in the RAW
  • Aspect ratio in the preview may be not exactly the same as RAW image area.

In some cases imgdata.sizes.raw_inset_crops[..] may work.

-- Alex Tutubalin @LibRaw LLC

many thnaks for the prompt

many thnaks for the prompt response.
i'll try to test the parameter imgdata.sizes.raw_inset_crops[..].
best regards.