Home

Please support mflenses.com if you need any graphic related work order it from us, click on above banner to order!

SearchSearch MemberlistMemberlist RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in

EXIF hacking
View previous topic :: View next topic  


PostPosted: Fri Jan 11, 2008 7:06 am    Post subject: EXIF hacking Reply with quote

It bugs me that non-CPU MF lenses mean that the EXIF data is either missing or wrong on some parts. For example I run a tool that analyzes photos and it draws a graph of focal lengths, apertures, exposure times and iso that I use. But for the manual non-CPU lenses, these come up as a 0mm lens.

ExifTool by Phil Harvey allows EXIF data to be not only read, but also written. (It saves a copy of the original JPEG or NEF in case you screw up). This is good.

Unfortunately camera body makes can be bloody minded at times and for example Nikon encrypts (no, really) the lens data in their MakerNotes. Boo! But ExifTool can decrypt it. Hooray! But can't write it or update it. Boo!

Still, there is some lens-related stuff in the standardized (non-MakerNotes) area. Using exiftool I could update an image that I knew was taken by a particular lens:

Code:
exiftool -Lens="Nikkor 80-200 f/4.5 AiS" -"MaxApertureValue"=4.5 DSC1234.jpg


or (for non-zooms ,where you also know the focal length)

Code:
exiftool -Lens="Micro-Nikkor 55 f/2.8 AiS" -"MaxApertureValue"=2.8 -FocalLength="55" DSC5678.jpg


I converted a directory full of test shots (all taken with the one lens) also:

Code:
$ for i in *.jpg; do exiftool -Lens="Nikkor 80-200 f/4.5 AiS" -"MaxApertureValue"=4.5 $i; done


(this is using cygwin, a bash shell for windows).

Lastly, I found out what info the CV40 puts into the MakerNote lens area:

Code:
Lens Data Version               : 0202
Exit Pupil Position             : 64.0mm
AF Aperture                     : 2.0
Focus Position                  : 0x00
Focus Distance                  : 0.01 m
Lens ID Number                  : 0
Lens F Stops                    : 7.00
Min Focal Length                : 40.0mm
Max Focal Length                : 40.0mm
Max Aperture At Min Focal       : 2.0
Max Aperture At Max Focal       : 2.0
MCU Version                     : 0
Effective Max Aperture          : 2.0


(note that it claims to be an AF lens Smile )


PostPosted: Fri Jan 11, 2008 7:28 am    Post subject: Reply with quote

Does this tool work with JPGs only, not RAWs, correct?

-


PostPosted: Fri Jan 11, 2008 8:40 am    Post subject: Reply with quote

Nice tip thank you.

Almost every program I have used allows manual changes in Exif. I can especially recommend ACDsee Pro.

Free to try here:
http://store.acdsee.com/servlet/ControllerServlet;jsessionid=060596c8badf44c9afa5bf7a8217de45?Action=DisplayPage&Locale=en_US&SiteID=acd&id=ProductDetailsPage&productID=78701700


Last edited by lahnet on Fri Jan 11, 2008 8:42 am; edited 1 time in total


PostPosted: Fri Jan 11, 2008 8:40 am    Post subject: Reply with quote

Hi,

It does work with some RAW formats (but not all).

Here is the list of formats supported with Read only or Read / Write capabilities.

When I had a Sony A100, I had to convert Raw -> jpg, and then alter exif accordingly, but now with Pentax K10D I can do it directly in the RAW files.
Exiftool creates a backup automatically, so no risk to lose data there...

Once the raw file is corrected with valid exif data, conversion normally keeps the data valid (depending on the program used...)


Last edited by LeFanch on Fri Jan 11, 2008 9:04 am; edited 1 time in total


PostPosted: Fri Jan 11, 2008 8:44 am    Post subject: Reply with quote

I suppose good idea to store from every raw images a Jpeg version in smaller size (in your typical web publish size) and store information there. When you browse local hard disk small jpeg showed lot faster than Raw.


PostPosted: Fri Jan 11, 2008 9:54 am    Post subject: Reply with quote

lahnet wrote:
Almost every program I have used allows manual changes in Exif

You made me lost 5 min to check acdsee pro Evil or Very Mad
For exif you can just change artist,date, description
With exiftool I change focal length and aperture and it's the only one I know that allow that.


PostPosted: Fri Jan 11, 2008 10:06 am    Post subject: Reply with quote

hmmm... a program that uses perl command lines and takes 2 pages to explain me how to install and run a exe file? Not for me. I was off reading after the 20th line of the intro document. It may be the best program for sure but I don't want something so painful and so self-concerned to just edit a couple text lines.


PostPosted: Fri Jan 11, 2008 10:26 am    Post subject: Reply with quote

poilu wrote:
lahnet wrote:
Almost every program I have used allows manual changes in Exif

You made me lost 5 min to check acdsee pro Evil or Very Mad
For exif you can just change artist,date, description
With exiftool I change focal length and aperture and it's the only one I know that allow that.


Sorry poilu

I can chance everything in the right side of the screen. don't know if any restrictions has been made.


PostPosted: Fri Jan 11, 2008 10:29 am    Post subject: Reply with quote

poilu wrote:
lahnet wrote:
Almost every program I have used allows manual changes in Exif

You made me lost 5 min to check acdsee pro Evil or Very Mad
For exif you can just change artist,date, description
With exiftool I change focal length and aperture and it's the only one I know that allow that.


Exactly!

So, thanks for the link to ExifTool! Very Happy


PostPosted: Fri Jan 11, 2008 10:31 am    Post subject: Reply with quote

Orio wrote:
hmmm... a program that uses perl command lines and takes 2 pages to explain me how to install and run a exe file? Not for me. I was off reading after the 20th line of the intro document. It may be the best program for sure but I don't want something so painful and so self-concerned to just edit a couple text lines.


Scroll further down and you will find some GUIs for Windows. That should make thing easier.
I will try one of them...

... Try ExifToolGui - it works!
http://freeweb.siol.net/hrastni3/foto/exif/exiftoolgui.htm


Last edited by LucisPictor on Fri Jan 11, 2008 10:36 am; edited 2 times in total


PostPosted: Fri Jan 11, 2008 10:32 am    Post subject: Reply with quote

Well, there is a standalone Windows version, still command line.

Edit : And as it was said above, some gui do exist.

I must admit the first contact is far from being easy but I think it is worth it.
I created a batch file for each of my lenses so I do not have to type everything each time... Very Happy

If you want to keep away from the command line and complex options, there is Exif Editor.
I had listed it in this thread, but it is a while ago!


PostPosted: Fri Jan 11, 2008 10:40 am    Post subject: Reply with quote

lahnet wrote:
poilu wrote:
lahnet wrote:
Almost every program I have used allows manual changes in Exif

You made me lost 5 min to check acdsee pro Evil or Very Mad
For exif you can just change artist,date, description
With exiftool I change focal length and aperture and it's the only one I know that allow that.


Sorry poilu

I can chance everything in the right side of the screen. don't know if any restrictions has been made.


Your right, I have just tried to download to new version, and i can NOT change focal length here.

Strange, I think i will keep my "old" version.


PostPosted: Fri Jan 11, 2008 11:55 am    Post subject: Reply with quote

I use a perl script who read a text file with my lenses, I drag drop file I want to change and select lens in a combobox
If a program can do this job more easily I would like to know

portion of text file
Code:
flektogon 20,20,20,4.0
helios 44-2,58,58,2.0
jupiter 9,85,85,2.0
industar 50,50,50,3.5
jena 80,80,80,2.8


portion of perl who edit exif
Code:
$exifTool->SetNewValue('Lens',$focmin{$key});
$exifTool->SetNewValue('FocalLength',$focmin{$key});
$exifTool->SetNewValue('ShortFocal',$focmin{$key});
$exifTool->SetNewValue('LongFocal',$focmax{$key});
$exifTool->SetNewValue('FNumber',$apert{$key});
$exifTool->WriteInfo($_[0]);


I change also the IPTC to have the full name of the lens
Code:
$exifTool->SetNewValue('Keywords',$objectif);



I also have a script to extract jpg with exif, I keep all jpg and only cr2 I like
Code:
sub makejpg {
    my ($name,$path,$suffix);
    my $srcfile = $_[0];
    use File::Basename;
    ($name,$path,$suffix)=fileparse($srcfile,"\.[^.]*");
    my $dstfile=$path.$name.".jpg";
    my $exifTool = new Image::ExifTool;
    $exifTool->Options(Binary => 1);
    $exifTool->Options(PrintConv => 0);
    my $info = $exifTool->ImageInfo($srcfile);
    my $blob = $exifTool->GetValue('PreviewImage');
    open(OUT, ">".$dstfile);
    binmode(OUT); syswrite(OUT, $$blob); close(OUT);
}


PostPosted: Fri Jan 11, 2008 12:00 pm    Post subject: Reply with quote

I use lens name and aperture settings as file name instead of exif info ...
How about this ?


PostPosted: Fri Jan 11, 2008 12:03 pm    Post subject: Reply with quote

Attila wrote:
I use lens name and aperture settings as file name instead of exif info ...
How about this ?


Me too (although with the D200 most of my exif files are okay too Wink )

My boss will tell you how badly my script writing sucks Embarassed


PostPosted: Fri Jan 11, 2008 12:12 pm    Post subject: Reply with quote

poilu wrote:

If a program can do this job more easily I would like to know


That may be easy for you - for me those lines of command codes are like Sanscrypt.
I'm a simple computer user, not a programmer. I'm at the dumb end of the Bill Gates chain Laughing


PostPosted: Fri Jan 11, 2008 12:35 pm    Post subject: Reply with quote

Orio wrote:
for me those lines of command codes are like Sanscrypt

Don't worry, for me also it's Chinese and I never wrote any perl script.
I used google to get portion of code I assembled.
It is the reason I put it here to maybe help someone who want to try.


PostPosted: Fri Jan 11, 2008 12:43 pm    Post subject: Reply with quote

Attila wrote:
I use lens name and aperture settings as file name instead of exif info ...

That's a good idea, easy and efficient


PostPosted: Fri Jan 11, 2008 1:02 pm    Post subject: Reply with quote

Orio wrote:
poilu wrote:

If a program can do this job more easily I would like to know


That may be easy for you - for me those lines of command codes are like Sanscrypt.
I'm a simple computer user, not a programmer. I'm at the dumb end of the Bill Gates chain Laughing


Don't worry, Orio. I teach IT classes and I only can "read" these scripts, I cannot "write" them, i.e. I know what they do, but I don't know the active syntax.

Your script, poilu, is interesting, though!


PostPosted: Fri Jan 11, 2008 3:56 pm    Post subject: Reply with quote

Orio wrote:
Does this tool work with JPGs only, not RAWs, correct?
-


No, it works with a large number of formats including assorted RAW files.

I have not tested it on NEF yet. I don't mind something writing to a JPG as I can always make another, but I will need to be rather more confident before letting it trample on my NEFs. (I shoot only NEF).


PostPosted: Fri Jan 11, 2008 4:04 pm    Post subject: Reply with quote

Orio wrote:
hmmm... a program that uses perl command lines and takes 2 pages to explain me how to install and run a exe file? Not for me. I was off reading after the 20th line of the intro document. It may be the best program for sure but I don't want something so painful and so self-concerned to just edit a couple text lines.


Yes its a typical badly organised "oh I suppose I should add some documentation" web page. Most of the info is there ... somewhere. I was looking for something with flexibility, power, and batch capability which it provides. This is probably the most capable of the exif libraries. A huge amount of work has gone into reverse-engineering some parts of it whewre manufacturers don't follow the standard.

But its more of a library plus 'sample application'.

Other people have taken that code and wrapped it up with a GUI front end to make a product normal people will want to use. There are programs fro MacOS X and forWin XP/Vista/2000. I suggest downloading one (so you get a regular installer and a program that looks like other programs)

Linux users are expected to rejoice in the command line Smile


PostPosted: Fri Jan 11, 2008 4:18 pm    Post subject: Reply with quote

I can not use ExifEditor on my laptop, because it requires MS Framework 2.0, and MS Framework 2.0 requires XP SP2, and my laptop requires that XP is not updated to SP2 - if I do, the computer goes in autoblock Sad


PostPosted: Fri Jan 11, 2008 4:18 pm    Post subject: Reply with quote

LucisPictor wrote:
Orio wrote:
hmmm... a program that uses perl command lines and takes 2 pages to explain me how to install and run a exe file? Not for me. I was off reading after the 20th line of the intro document. It may be the best program for sure but I don't want something so painful and so self-concerned to just edit a couple text lines.


Scroll further down and you will find some GUIs for Windows. That should make thing easier.
I will try one of them...

... Try ExifToolGui - it works!
http://freeweb.siol.net/hrastni3/foto/exif/exiftoolgui.htm

Wink


PostPosted: Fri Jan 11, 2008 4:40 pm    Post subject: Reply with quote

Takes a lifetime to save a file... is that normal?

Also I have questions:

- why it shows ImageWidth 2496 ImageHeight 1664 (wrong values) and in the bottom, ExifImageWidth 4368 ExifImageHeight 2912 (correct values)?

- in the editor, why it shows:
FNumber
Aperture Value
Max. Aperture Value
?
I understand Max. Aperture value is the wide open possibility, while the other two should show the actual aperture used, but why place two fields? It seems to me that one of FNumber and Aperture Value is redundant.

- Also, why show:
Focal Lenght (mm)
FocalLenghtIn35mmFormat
?
What is the purpose of the second field? Looks redundant also.

- Isn't there the possiblity to add the "Exif Comments" field? I don't see it.


PostPosted: Fri Jan 11, 2008 4:53 pm    Post subject: Reply with quote

Orio wrote:
Takes a lifetime to save a file... is that normal?

No, not if you tried ExifToolGUI...


Orio wrote:

- Also, why show:
Focal Lenght (mm)
FocalLenghtIn35mmFormat
?
What is the purpose of the second field? Looks redundant also.



This is for digital cams with a crop factor. The first one shows the "real" focal length and the second one the "equivalent" on a 135film.
(So a Sigma 17-70 at 17mm would have "17" mm in the first line and "27mm" in the second.)