Author Topic: Changing duplicate tags all at once - how?  (Read 3197 times)

6BQ5

  • Newbie
  • *
  • Posts: 4
Changing duplicate tags all at once - how?
« on: March 10, 2015, 10:22:48 AM »
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:

Code: [Select]
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 :

Code: [Select]
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 :

Code: [Select]
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Changing duplicate tags all at once - how?
« Reply #1 on: March 10, 2015, 10:44:36 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

6BQ5

  • Newbie
  • *
  • Posts: 4
Re: Changing duplicate tags all at once - how?
« Reply #2 on: March 10, 2015, 03:50:19 PM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Changing duplicate tags all at once - how?
« Reply #3 on: March 10, 2015, 07:27:04 PM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Changing duplicate tags all at once - how?
« Reply #4 on: March 11, 2015, 08:22:10 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

6BQ5

  • Newbie
  • *
  • Posts: 4
Re: Changing duplicate tags all at once - how?
« Reply #5 on: March 12, 2015, 11:12:13 PM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 974
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Changing duplicate tags all at once - how?
« Reply #6 on: March 13, 2015, 03:43:17 AM »
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14554
    • ExifTool Home Page
Re: Changing duplicate tags all at once - how?
« Reply #7 on: March 13, 2015, 06:55:42 AM »
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

6BQ5

  • Newbie
  • *
  • Posts: 4
Re: Changing duplicate tags all at once - how?
« Reply #8 on: March 21, 2015, 12:48:58 AM »
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)