필터 지우기
필터 지우기

Read thumbnail/embedded JPEG in DNG file

조회 수: 10 (최근 30일)
KAE
KAE 2023년 2월 28일
댓글: KAE 2023년 3월 7일
I have a compressed DNG file which I can preview in the Photos app on Windows 11, possibly because there is an embedded JPEG aka thumbnail in the DNG file. Is there a way to read this thumbnail into Matlab? I figure if Windows Photos can do it, Matlab should be able to also. I can't seem to use imread as suggeted here to get the preview, however:
imread('SomeCompressedDngFile.DNG') % Error: Unable to read TIFF file "SomeCompressedDngFile.DNG". File is corrupt or image does not
contain any readable tiles.
imread('SomeCompressedDngFile.DNG', 'jpeg') % Error: 'SomeCompressedDngFile.DNG is not a jpeg file
  댓글 수: 2
Walter Roberson
Walter Roberson 2023년 2월 28일
Note that the TIFF content itself is probably not going to make sense as DNG images are typically compressed in a way that the Tiff class does not know how to handle.
KAE
KAE 2023년 3월 3일
편집: KAE 2023년 3월 3일
Thanks for these suggestions. With the FEX program, I was getting errors ("Error using tifflib. Unable to retrieve SubIFD") with the compressed version of the DNG files, so I tried it on the uncompressed version, which fails at,
curve = uint16(info.SubIFDs{1}.LinearizationTable);
Unrecognized field name "LinearizationTable".
But just to make sure I'm heading down the right path, I don't need to access the TIFF data, just the JPEG preview that Windows Photos can display. Is there a way to do this? [I ended up using an external program and made it as an answer in case it helps someone].

댓글을 달려면 로그인하십시오.

채택된 답변

KAE
KAE 2023년 3월 3일
편집: KAE 2023년 3월 6일
In case it helps someone, here's one approach. The program exiftool contains functions to extract the embedded jpg, and here's how to run it from Matlab,
% Run exiftool.exe from Matlab command line using system
% Format of exiftool command was taken from examples displayed if exiftool
% is run without any arguments
system('"C:\LongPathName\Image-ExifTool-12.57\exiftool" -a -b -W %d%f_%t%-c.%s -preview:all SomeDngUncompressedFile.dng');
% Creates SomeDngUncompressedFile_PreviewImage.jpg
% Read in the jpg and display it
imshow(imread('SomeDngUncompressedFile_PreviewImage.jpg'));
This worked on the uncompressed version of the DNG files, and not on the compressed.
You can also get helpful info on the uncompressed or compressed file,
% Generate a TXT file containing information about the DNG file including
% the preview thumbnail
system('"C:\LongPathName\Image-ExifTool-12.57\exiftool" -s -s SomeDngCompressedFile.dng > SomeDngCompressedFile_EXIF.txt')
  댓글 수: 5
Walter Roberson
Walter Roberson 2023년 3월 6일
It looks like the answer might be to use .NET
System.IO.File.GetCreationTime(PATH)
KAE
KAE 2023년 3월 7일
Oddly, that is also showing the file modification date, see here. My final workaround will likely be outside of Matlab and I'll post it when I figure it out! Thank you for all your help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by