ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: desgphoto on September 08, 2010, 03:45:42 AM

Title: Calculations with exiftool - "Not a floating point number"?
Post by: desgphoto on September 08, 2010, 03:45:42 AM
Hi there,

currently I'm trying to do something stupid: in old times I cropped my RAW images with Nikon Capture and saved the cropped RAW file. The advantage was that I could see the cropped and processed (preview)image in my explorer. This was in a time before XMP became a standard. At this time Nikon wrotes the crop information into the makernotes like this:

Crop Left     : 114
Crop Right    : 2208
Crop Top      : 126
Crop Bottom  : 2136


Today I'm working with Lightroom which is not dealing with these makernotes but with XML. My idea and plan is now to use exiftool to transfer the makernotes into XMP. But the crop format has changed to something like:

Crop Left : 0.237312
Crop Right : 0.856908
Crop Top : 0.108404
Crop Bottom : 0.881356
Image Width : 4288
Image Height : 2844


The cropvalues in XMP are in percent of the image dimensions. The manual setting is working really fine and I can call, for example:

   exiftool.exe -xmp:cropleft=0.237312 2007-10-06-0038.NEF

So what I would like to do now is simply:

   exiftool.exe -xmp:cropleft=(cropleft/imagewidth) 2007-10-06-0038.NEF

But this doesn't work and I get an:

Warning: Not a floating point number for XMP-crs:CropLeft
Nothing to do.


Does anybody has an idea where the problem is or how can I get this thing to run?


Thanks for any help and greetings,
Lars
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: Phil Harvey on September 08, 2010, 06:22:08 AM
Hi Lars,

This can be done with user-defined Composite tags (https://exiftool.org/config.html).  Just define 4 new tags which combine the NikonCapture crop dimensions with the image dimensions as you indicated.  Then copy these user-defined tags to the XMP crop tags.

The definitions will look like this:

    MyLeft => {
        Require => {
            0 => 'NikonCapture:CropLeft',
            1 => 'ImageWidth',
        },
        ValueConv => '$val[0] / $val[1]',
    },


Good luck.

- Phil
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: desgphoto on September 08, 2010, 06:55:58 AM
Hi Phil,

thanks a lot. It works great now. You saved my day!

Last but not least a "further little" problem: I can now calculate the new cropvalues and can save them back into the NEF file. But is there a way to copy the cropvalues to the XMP file but without overwriting any other XMP data?

But one further question (not related to the above one). I also tried to remove the "IPTC:keywords" and "IPTC:SupplementalCategories" content, but it doesn't work. Actually, my command line looks like:

d:\exiftool\exiftool.exe -config d:\exiftool\ExifTool_config -v3 -iptc:SupplementalCategories= -iptc:keywords= "-xmp:cropleft<newcropleft" "-xmp:cropright<newcropright" "-xmp:croptop<newcroptop" "-xmp:cropbottom<newcropbottom" -tagsfromfile %d%f.xmp *.NEF -overwrite_original


The keywords will be removed fine, but not the SupplementalCategories. Where is my fault?




thanks again!
Lars
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: Phil Harvey on September 08, 2010, 07:34:45 PM
Hi Lars,

Quote from: desgphoto on September 08, 2010, 06:55:58 AM
But is there a way to copy the cropvalues to the XMP file but without overwriting any other XMP data?

This shouldn't overwrite any XMP except the crop values.

Quote
But one further question (not related to the above one). I also tried to remove the "IPTC:keywords" and "IPTC:SupplementalCategories" content, but it doesn't work. Actually, my command line looks like:

d:\exiftool\exiftool.exe -config d:\exiftool\ExifTool_config -v3 -iptc:SupplementalCategories= -iptc:keywords= "-xmp:cropleft<newcropleft" "-xmp:cropright<newcropright" "-xmp:croptop<newcroptop" "-xmp:cropbottom<newcropbottom" -tagsfromfile %d%f.xmp *.NEF -overwrite_original


This may explain why you think some XMP is being overwritten, and why you are writing IPTC:SupplementalCategories.  If you want to copy the XMP to the XMP, you need to add -xmp:all after -tagsfromfile %d%f.xmp in your command.  Otherwise the tags will be written to the preferred location instead of XMP as I think you want.  Both EXIF and IPTC are preferred over XMP.

- Phil
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: desgphoto on September 10, 2010, 03:38:07 AM
Hi Phil,

thanks again. Now it works fine!

But I guess I found a "bug" in exiftool. When reading exif:imageheight from a Nikon RAW file (NEF), then exiftool returns approx just the half value of the real height. Is it a bug or a feature?


greets,
Lars
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: Phil Harvey on September 10, 2010, 07:22:45 AM
Hi Lars,

I'm afraid you'll have to be more specific.  What Nikon model?  What value are you getting for EXIF:ImageHeight, and what did you expect?

- Phil
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: desgphoto on September 10, 2010, 07:34:36 AM
Quote from: Phil Harvey on September 10, 2010, 07:22:45 AM
I'm afraid you'll have to be more specific.  What Nikon model?  What value are you getting for EXIF:ImageHeight, and what did you expect?

Hi Phil,

you're right :-) Here it comes:

Nikon D2Xs :   exiftool: 4320 x 2868   expected: 4288 x 2848
Nikon D1X :   exiftool: 4028 x 1324   expected: 4011 x 2613 !!!
Nikon D3 :   exiftool: 4288 x 2844   expected: 4256 x 2832

can you see my confusion?

greets,
Lars
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: BogdanH on September 10, 2010, 08:22:43 AM
Hi,

I've just tried for Nikon D700 (same resolution as D3) and I can confirm what Lars said. As it seems, inside SubIFD1, there are values describing "total" sensor resolution, which is then displayed by Exiftool. But as far I could read elsewhere, for final result (after conversion) less pixels are used (has something to do with black level reference, or similar).
Is it that?

Bogdan
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: Phil Harvey on September 10, 2010, 08:41:58 AM
Hi Lars,

Thanks for the details.

ExifTool reports the values stored in EXIF for the full-resolution image.  I have no control over what Nikon writes for these.

I can't explain why the D1X stores half of the expected value, but the other small differences are perfectly normal.  Cameras usually crop borders from the image.  Sometimes these are black pixels as Bogdan mentioned, but often they are just cropped to simplify the camera algorithms so they don't have to deal with edge effects.  You may find that the image dimensions are different depending on what raw converter you use (often dcraw will give an image which is larger than from other converters).

For example, with a D700 sample I get:

4288x2844 - NEF size reported by ExifTool
4256x2832 - JPEG image size from the camera
4256x2832 - JPEG image size from Photoshop CS4
4284x2844 - JPEG image size from dcraw

- Phil
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: Phil Harvey on September 10, 2010, 09:03:55 AM
I did a bit of research on the D1X.  Oddly enough, the pixels of the D1X sensor are not square.  They are twice as high as they are wide.  (You can actually see this in the metadata since the XResolution is 600 while the YResolution is only 300.)  Therefore, the JPEG image height of 2613 is obtained by interpolation within the available 1324 pixels from the sensor.

So it seems that the values extracted by ExifTool for NEF images are the dimensions of the raw image data actually stored in the file, and correspond to the the actual dimensions of the camera sensor.

- Phil
Title: Re: Calculations with exiftool - "Not a floating point number"?
Post by: desgphoto on September 11, 2010, 06:16:31 AM
Hi Phil,

thanks for the info. This is very helpfull! Now I know how I have to adopt by "crop converter" from my origin post to get a satisfying result. I was really confused when I saw the first output of exiftool on a D1X file  :o

Thanks a lot and have a nice weekend,
Lars