ExifTool Forum

ExifTool => Archives => Topic started by: Archive on May 12, 2010, 08:54:12 AM

Title: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:12 AM
[Originally posted by msbc on 2007-12-06 23:55:23-08]

I'm trying to copy metadata from an original Canon CR2 to a JPG version using -TagFromFile. Tried this with 7.03 and 7.05, with and without the additional -all:all option. I get the same error message

Code:
$ exiftool -TagsFromFile 20050910-8582.CR2 20050910-8582.jpg
Error: Bad format (0) for IFD0 entry 6 - 20050910-8582.jpg

Not sure what this means. Is there a way to fix this problem?
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:12 AM
[Originally posted by exiftool on 2007-12-07 00:24:22-08]

The EXIF information in your JPEG image is corrupt.

ExifTool will not rewrite EXIF information which has such a
severe problem due to the high probability that information
will be lost.  However, you can use exiftool to repair the file.
Here are the steps:

1) Make a copy of the JPEG image (let's call it "new.jpg").

2) use "exiftool -exif:all= new.jpg" to remove all EXIF information.

3) use "exiftool -tagsfromfile 20050910-8582.jpg -all:all new.jpg"
to copy any recoverable information from the original image
(we know at least one tag won't be copied because of the invalid
format code, but if you are lucky the rest of the information may
still be good).

4) now go ahead and copy your CR2 tags to "new.jpg".

- Phil
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:12 AM
[Originally posted by msbc on 2007-12-07 01:29:45-08]

Phil,

That worked great and allowed me to copy all the tags from the CR2.

I notice that the PreviewImage is also copied (though the online doc says it will be excluded). Is there a way to exclude the CR2 preview and thumbnail (not sure of the difference?) being copied and keep the ones already in the JPG?
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:12 AM
[Originally posted by msbc on 2007-12-07 01:37:46-08]

Doh! RTFM!! Answered my own question - just had to put the --Tag between the src and dest image names. I also think I was wrong in saying the Previewimage was copied - it was the ThumbnailImage I had to delete.
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:12 AM
[Originally posted by exiftool on 2007-12-07 12:05:11-08]

Glad you figured that out.
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:13 AM
[Originally posted by robladdish on 2007-12-28 06:09:36-08]

Hi Phil,

First off, thanks for an awesome tool! You've done a great job of managing the complexity with easy options. That's hard to do well!

I have a similar problem as this poster. I have a lot of images stored from an older Fuji FinePix 601z camera that I'm trying to organize. It's finding corruption in the header & declining to write to the tag header:

Code:
$ exiftool -m -Software=Fred test_bak.jpg
Warning: Truncated MakerNotes directory - test_bak.jpg
Error: Bad format (1792) for ExifIFD entry 19 - test_bak.jpg
    0 image files updated
    1 files weren't updated due to errors

I tried a similar process to what you did above - make a copy, remove exif tags, copy exif tags, and continue. Unfortunately, it seems to copy the corruption, and the error remains. Do you have any suggestions?

Here's the relevant output:

$ copy test.jpg test_bak.jpg
$ exiftool -exif:all= test_bak.jpg
    1 image files updated
$ exiftool -m -Software=Fred test_bak.jpg
    1 image files updated

This implies the clearing of tags removed the problem.

$ exiftool -exif:all= test_bak.jpg
    1 image files updated
$ exiftool -tagsfromfile test.jpg test_bak.jpg
Warning: Bad MakerNotes directory - test.jpg
    1 image files updated
$ exiftool -m -Software=Fred test_bak.jpg
Warning: Truncated MakerNotes directory - test_bak.jpg
Error: Bad format (1792) for ExifIFD entry 19 - test_bak.jpg
    0 image files updated
    1 files weren't updated due to errors

This implied to me that the corruption got copied over too. :(

Here's some more verbose output in case it helps:

P:\ArchiveMisc\Home TV Copies>exiftool -v2 -m -Software=Fred test_bak.jpg
Writing PNG:Software
Writing MIE-Doc:Software
Writing Sigma:Software if tag exists
Writing XMP-tiff:Software if tag exists
Writing IFD0:Software
Rewriting test_bak.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes PNG XMP
  Creating tags in: APP1 IFD0 MIE-Doc PNG
JPEG APP1 (8182 bytes):
  ExifByteOrder = MM
  Rewriting IFD0
    - IFD0:Software = 'Adobe Photoshop Elements 6.0'
    + IFD0:Software = 'Fred'
  Rewriting ExifIFD
  Rewriting MakerNotes
  Warning = Truncated MakerNotes directory
  Deleting MakerNotes
  Error = Bad format (1792) for ExifIFD entry 19
JPEG APP13 (142 bytes):
JPEG APP1 (5718 bytes):
  Rewriting XMP
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG DQT (65 bytes):
JPEG SOF0:
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG DHT (29 bytes):
JPEG DHT (179 bytes):
JPEG DRI (2 bytes):
JPEG SOS
Warning: Truncated MakerNotes directory - test_bak.jpg
Error: Bad format (1792) for ExifIFD entry 19 - test_bak.jpg
    0 image files updated
    1 files weren't updated due to errors

Thanks for any help!
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:13 AM
[Originally posted by robladdish on 2007-12-28 06:33:40-08]

Ahah! Posting the problem got me to thinking about it again, and I found I could exclude MakerNotes from the tag recopy. Nevermind it's working now. Smiley If others are curious, here's the snippet of code I used within Perl. (Camera_id formed from Make and Model tags, I then set other tags and call $exifTool->WriteInfo after this code to make it all stick)

Code:
   if ($camera_id =~ /^FUJIFILM FinePix F601 ZOOM/i) {
   system("exiftool -overwrite_original -q -exif:all= \"$dest_file\"");
   system("exiftool -overwrite_original -q -q -tagsfromfile \"$src_file\" --MakerNotes \"$dest_file\"");
    }
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:13 AM
[Originally posted by exiftool on 2007-12-28 12:54:42-08]

Hi Rob,

I'm glad you sorted it out.  As you have discovered, sometimes when
exiftool issues a makernote warning during writing it will fall back to
just copying the offending information as-is instead of trying to
restructure it properly.  In your case this also caused the format error
to be copied, although without seeing the image I can't tell what the
specific problem was.  I usually use the htmldump feature to debug
this sort of format problem in case you're interested.

- Phil
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:23 AM
[Originally posted by dzurn on 2008-08-01 19:15:02-07]

I have about 100 photos that I need to do this to! How can I adapt this method for 100 files?

Thanks
Darryl
Title: Re: Error copying Tags
Post by: Archive on May 12, 2010, 08:54:23 AM
[Originally posted by sjmulder on 2008-08-08 23:57:55-07]

Dzum, I wrote a ruby script to do this. It simply executes the above commands on all files.

Code:
#! /usr/bin/ruby
# fix_tags.rb by Sijmen Mulder <sjmulder@gmail.com> in 2008. Public domain.

files = Dir.glob("*.JPG").concat Dir.glob("*.jpg")
files.each do |file|
  commands = [
    "cp #{file} #{file}_original",
    "exiftool -overwrite_original -q -exif:all= \"#{file}\"",
    "exiftool -overwrite_original -q -q -tagsfromfile \"#{file}_original\" --MakerNotes \"#{file}\""
  ]
 
  puts(file)
  commands.each do |c|
    #puts(c)
    system(c)
  end
end

puts "Processed #{files.length} file(s)."

Have fun.