Freeimage exif metadata

BlitzMax Forums/Brucey's Modules/Freeimage exif metadata

Difference(Posted 2009) [#1]
Hi Brucey

Any chance bah.freeimage can be updated to support the reading of exif data from images? (In my case mainly the date, and maybe orientation.)


Brucey(Posted 2009) [#2]
Metadata, huh?

I'm sure that can be arranged. :-)


Brucey(Posted 2009) [#3]
If you want, you can add it as a feature-request here :

http://code.google.com/p/maxmods/issues/list

Think of it like a very public laundry list :-)


Difference(Posted 2009) [#4]
Added! :-) http://code.google.com/p/maxmods/issues/detail?id=9


Brucey(Posted 2009) [#5]
I've got most of the code in now.. but haven't tested any of it yet - haven't had time.

Hopefully I can play with it a little tonight. But if you want to try it out in the mean-time, it's all in the repository.


Difference(Posted 2009) [#6]
Great, I'm looking forward to testing, hopefully sometime during the Weekend.


Brucey(Posted 2009) [#7]
Found some time to give it a test.

Fixed some minor issues.
Added a small test (test_07.bmx), with test image.
Should give you an idea of what you can get out of it - which appears to be quite a lot.

I've also implemented enumeration, so you can do things like :
For Local tag:TFreeImageTag = EachIn img.metadata(FIMD_EXIF_EXIF)
...
Next

which I think is a better interface to the internal metadata list than having to manually - read next : if is null, exit loop...
...and more BlitzMax-like.

Only tested on Mac Intel, but it should *just work* everywhere else.


Brucey(Posted 2009) [#8]
One thing to note.

The data that comes out of the tags is RAW. i.e. Byte Ptr.
So, based on the data type, say, FIDT_INT, the pointer would actually refer to an int, which you could extract with :
Local valuePtr:byte ptr = tag.getValue()
Print Int Ptr(valuePtr)[0]

I was considering wrapping it up with helper methods, but since some of the data returned is non-specific, it seemed a bit silly to only wrap up some of them.

However, if you really need it, it can be done.
Perhaps with methods like :
getValueAsString:String()

:-)


Difference(Posted 2009) [#9]
I've been giving this a good testing with a lot of different images from different digicams, and it looks to be working perfectly.

Many, many thanks for the update.

I'll be using this to rename pictures, when they are gotten from my digicam. I'm planning on making a new version of my "rename and move to folder" app, because the last one made in powerbasic and with ImageSource.dll is getting to old to maintain.

I'm also thinking of rolling my own little picture database thingy with this and your sqllite module.

Function GetExifDate:String(img:TFreeImage)
	If img Then
		Local dateTag:TFreeImageTag  = img.getMetadata(FIMD_EXIF_EXIF,"DateTimeOriginal")
		If dateTag
			Return String.FromCString(dateTag.getValue())
		EndIf
	End If	
End Function



Brucey(Posted 2009) [#10]
Glad it's working for you.

If you see any other gaping holes in my implementation, please let me know :-)