Changing duplicate tags all at once - how?

Started by 6BQ5, March 10, 2015, 10:22:48 AM

Previous topic - Next topic

6BQ5

Hello everyone!  :)

I have a Pentax Q7 that generates multiple duplicate tags in the DNG file for the Image Height and Image Width. Each set of tags contains different values. For example, one set will be 4064x3000 and the other set will be 1920x1280. The smaller resolution is for Subfile Type : Reduced-resolution image. My raw processor, Capture One, reads this set of the tags and interprets it as the full resolution. The result is a heavily cropped image. I would like to change this second set of resolution numbers to be 4064x3000 so Capture One won't auto-crop.

I tried the command:

exiftool -a -ImageWidth IMGP0378.DNG

And I get this output:

Image Width                     : 160
Image Width                     : 4064
Image Width                     : 1920


To change the 1920 to 4064 I enter :

exiftool -a -ImageWidth=4064 IMGP0378.DNG

And I get this output :

    1 image files updated

Hooray! Right? Well, no. I check the resolution values again :

exiftool -a -ImageWidth IMGP0378.DNG

And I get :

Image Width                     : 4064
Image Width                     : 4064
Image Width                     : 1920


How do I go about changing that 1920 to 4064? Here is a link to the DNG file on my DropBox account:

https://www.dropbox.com/s/yf3wildlmtifljw/IMGP0378.DNG?dl=0

I understand that this is a bug in Capture One ... but I would like to have some sort of solution while I wait for a fix.

Thanks! :)

-=- Boris

Phil Harvey

Hi Boris,

Try this:

exiftool -a -G1 -imagewidth IMGP0378.DNG

Then change the one in the group that you want.  For example:

exiftool -subifd1:imagewidth=4064 IMGP0378.DNG

However, doubt that this will do what you want, because I suspect you are just changing the dimensions of a preview image, which will likely invalidate the preview in the DNG.

- 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 ($).

6BQ5

Hi Phil,

Thanks for the reply! Changing the resolution values significantly reduced the file size for some reason. I thought this operation would only change the values of a few bytes and the file size would be the same. Loading the updated DNG into Capture One made the program crash.

I wanted to use exiftool to replace a script that someone wrote which changes the embedded JPG preview (picture + resolution).

Phil Harvey

I see.  The FAQ explains why you saw a change in file size.  I don't recall having ever tried to write a preview to a DNG image, so I'm not sure what success you will have, but you must write PreviewImage as well as the Width/Height tags (or else some badly written readers may crash).

- 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

Just for fun I tested this on a Q7 DNG image, and it does seem to work, although you need to change both the Pentax and the DNG preview at the same time:

exiftool "-previewimage<=preview.jpg" -subifd1:imagewidth=WIDE -subifd1:imageheight=HIGH -pentax:previewimagesize#="WIDE HIGH" image.dng

where WIDE/HIGH are the width/height of the preview jpg.

- 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 ($).

6BQ5

Hi Phil,

Thanks again for another reply!  :)

I tried your command line example on my machine and it worked! Brilliant!  8)

The preview starts off showing a white screen since I am using a 4000x3000 pure white empty JPG. Capture One generates its own preview and the white thumbnail changes to the actual image.

Now I am thinking of writing some sort of script that applies this command line in a loop on all files in a directory. Looks like I have a little project ahead of me.  :)

Hayo Baan

Quote from: 6BQ5 on March 12, 2015, 11:12:13 PM
Now I am thinking of writing some sort of script that applies this command line in a loop on all files in a directory. Looks like I have a little project ahead of me.  :)

Instead of image.dng, just provide the name of the directory and PM will process all images I. That directory. Add the -r option to have it recurse subdirectories as well. And if you want to limit it to e.g., only dng files, add the option -ext dng (multiple -ext option can be provided).

Hope this helps :)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

This is the command:

exiftool "-previewimage<=preview.jpg" -subifd1:imagewidth=WIDE -subifd1:imageheight=HIGH -pentax:previewimagesize#="WIDE HIGH" -ext dng DIR

where DIR is the directory name.

If you want a different preview written to each, then change "preview.jpg" to "%d%f.jpg" and name the previews the same as the dng files.

- 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 ($).

6BQ5

Finally got around to trying this out on some test images ...  and it worked!!  :)

You guys are absolutely awesome! Thanks again for helping me out!  8)