Error reading image data when writing dng files from phone Samsung S20 5G

Started by Pierre5018, January 29, 2021, 10:00:45 PM

Previous topic - Next topic

Pierre5018

Windows 10 professional x64, 20H2
Command line :  exiftool -m -all= -tagsfromfile @ -all:all -unsafe -icc_profile filename.dng
version : exiftool-12.16
Output from tool

Warning: SubIFD BitsPerSample should have 3 values - C:/Users/pierr/Pictures/2021-01-29St-Laurent/20210129_163226.dng
Error: Error reading image data - C:/Users/pierr/Pictures/2021-01-29St-Laurent/20210129_163226.dng
    0 image files updated
    1 files weren't updated due to errors



Phil Harvey

ExifTool won't rewrite a file if the image data is compromised.  This file is corrupted somehow.

I can't say more without seeing a sample.  You can send it to me if you want (philharvey66 at gmail.com).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

I got the sample:

> exiftool ~/Desktop/SamsungGalaxyS20_5G.dng -validate -warning -a
Validate                        : 3 Warnings
Warning                         : SubIFD BitsPerSample should have 3 values
Warning                         : Undersized SubIFD StripByteCounts (230400 bytes, but expected 345600)
Warning                         : SubIFD:StripOffsets+StripByteCounts runs past end of file


It is that last Warning that is the real problem.  It looks like the file has been truncated, with about 100 kB missing somehow.  Only 115200 bytes of the strips exist.

Does this happen for original DNG files from this phone?  Or have they been modified by some other software?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pierre5018

The sample is a copy of the file straight out of the phone.
I will resend it from the phone.


Phil Harvey

Exact same problem with this one.  Must be a phone software bug.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pierre5018

I want to edit standard exif fields: camera model and make.
Shouldn't exiftool-m option allow to ignore the non-conformity, i.e. allow updating fields while keeping the rest of the file untouched ?

I am hoping to do this in batch using a command such as:
exiftool -m -Make="Apple" -Model="iPhone 8 Plus" -o %d%f_spoof.%e FILE ...

Phil Harvey

-m only downgrades minor errors.  Any error involving potential loss of image data is not minor.  ExifTool can not be used to edit a file like this.  Your only recourse (other than getting Samsung to fix this bug, which may happen eventually with a software update) is to find some software that will read these files and write an output file without this problem.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pierre5018

I found that Adobe DNG converter can process this file without problem. The result can be tweaked using Exiftool.

Going back to the Samsung dng file, couldn't you make Exiftool ignore this error, and allow change exif fields that are correctly identified.

The original dng image is not corrupted:  it can be read by at least two photo editors, and the DNG converter.

Thanks for your help. 

Phil Harvey

The original DNG was not written correctly.  Either the strip byte counts are wrong or the strip data is truncated.  Without processing the image, you can't tell which.  ExifTool does not process image data, so the only safe thing to do is to refuse to write these files.  Otherwise ExifTool could potentially further damage the image.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Pierre5018

How about a more permissive option for letting through more severe errors?

For example  an option -mSevere.  The risk will be fully understood by the user, if that is really what the user wants.


-- Pierre

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).