dcrawload tries to select one thumbnail image from the raw file to attach as metadata. In some cases, the current implementation does not always make the best choice.
Revisit this code and see if we can improve it.
Discussed in #5001
Originally posted by kiefermat April 17, 2026
Hi,
I am currently looking into raw support of vips. Let me first thank you all for this project. I really like it!
I am curious what is the reason behind this code in dcrawload.c:
// useless thumbnails the same size as the main image are very
// common
if (this->twidth >= sizes->iwidth &&
this->theight >= sizes->iheight)
continue;
The code loops over all embedded previews and puts the best fitting into the field "raw-thumbnail-data". Many raw images have a full scale jpeg image embedded which can be used for previewing the file content.
Let me explain my use case: My target is to get a full HD preview of a raw file as fast as possible. For this, I am experimenting with the following python code:
def open_image_with_preview_if_available(file_path: str, size: int) -> Image:
vips_image = Image.new_from_file(file_path, access="sequential")
result = None
if vips_image.get_typeof("raw-thumbnail-data"):
thumbnail_data = vips_image.get("raw-thumbnail-data")
embedded_image = Image.thumbnail_buffer(thumbnail_data, size, height=size, size=Size.DOWN, auto_rotate=False)
if embedded_image.width < size and embedded_image.height < size:
LOG.info("skipping embedded thumbnail because it is smaller than the target size: %dx%d", embedded_image.width, embedded_image.height)
else:
original_orientation = vips_image.get("orientation") if vips_image.get_typeof("orientation") else None
if original_orientation:
embedded_image = transform_according_to_orientation(embedded_image, original_orientation)
result = embedded_image
if not result:
result = Image.thumbnail(file_path, size, height=size, size=Size.DOWN)
return result
I am currently using a similar mechanism using dcraw to extract the embedded preview image and using the embedded jpeg is usually much faster than processing the raw file directly.
However, since vips filters out the full sized jpeg preview, this approach does currently not work since the other embedded thumbnails are often much smaller.
So my questions are:
- Is this reasonable code to accomplish my use case with vips?
- Would it be possible to include the full sized jpeg as thumbnail data into the image fields (either as separate field or as "raw-thumbnail-data")?
- Is there a possibility to extend vipsthumbnail to also use the embedded image data? 😄
dcrawload tries to select one thumbnail image from the raw file to attach as metadata. In some cases, the current implementation does not always make the best choice.
Revisit this code and see if we can improve it.
Discussed in #5001
Originally posted by kiefermat April 17, 2026
Hi,
I am currently looking into raw support of vips. Let me first thank you all for this project. I really like it!
I am curious what is the reason behind this code in dcrawload.c:
The code loops over all embedded previews and puts the best fitting into the field "raw-thumbnail-data". Many raw images have a full scale jpeg image embedded which can be used for previewing the file content.
Let me explain my use case: My target is to get a full HD preview of a raw file as fast as possible. For this, I am experimenting with the following python code:
I am currently using a similar mechanism using dcraw to extract the embedded preview image and using the embedded jpeg is usually much faster than processing the raw file directly.
However, since vips filters out the full sized jpeg preview, this approach does currently not work since the other embedded thumbnails are often much smaller.
So my questions are: