View Full Version : .net Metafile class?
03-05-2012, 12:21 PM
Has anybody made use of the .net class below using maxscript (dotNetClass "System.Drawing.Imaging.Metafile")
I am looking for a way to access the metadata stored in image files, specifically the camera data and keywords stored in image files. Just a little unsure how I would go about implementing the above class in my script.
Any suggestions would be greatly appreciated.
The Imaging.Metafile class doesn't do what you think it does. It has nothing to do with image EXIF data.
I don't have any working code to share, but here is a link to give you a direction, provided you can convert the c# code to maxscript code:
03-05-2012, 10:10 PM
There are tools out there to do what you want like DCRaw (http://www.cybercom.net/%7Edcoffin/dcraw/) and ExifTools (http://www.sno.phy.queensu.ca/%7Ephil/exiftool/), but both are command-line tools and not dotnet libraries. ExifTools is also available as a Perl Library, but I have no idea how you would go about using that with Maxscript.
A c# library:
03-06-2012, 11:23 AM
Sorry after I posted I did a little research and realised that this metafile class wasn't exactly what I was looking for. Thanks lo for the links.
Here is what I have so far...
-- Bitmap stream
BitmapStream = dotNetObject "System.IO.FileStream" file FileMode.Open FileAccess.ReadWrite FileShare.ReadWrite;
--Jpeg bitmap decoder
BitmapDecoder = dotNetObject "System.Windows.Media.Imaging.JpegBitmapDecoder" BitmapStream BitmapCreateOptions.PreservePixelFormat BitmapCacheOption.Default;
Show properties on the Bitmapdecoder now reveals a metadata property. I understand the metadata, in the case of a Jpeg image, is stored in Frame
Jpegframe = bitmapdecoder.frames.Item
However this seems to return an error
-- Runtime error: dotNet runtime exception: Specified value of type 'System.Windows.Media.Imaging.BitmapFrameDecode' must have IsFrozen set to false to modify.
Any thoughts on where I may be going wrong?
I think you're still looking in the wrong place. Here's an incomplete code block to get you started:
thebmp = dotnetobject "system.drawing.bitmap" @"c:\test.jpg"
asciiCls = (dotnetClass "System.Text.Encoding").ascii
bCnv = (dotnetClass "System.BitConverter")
for item in thebmp.propertyitems do
local l = item.len
local v = item.value
local displayValue = case item.type of
2:(asciiCls.getString v 0 (l-1))
3:(bCnv.ToUInt16 v 0)
4:(bCnv.ToUInt32 v 0)
7:(bCnv.ToInt32 v 0)
format "ID:%\tType:%\tValue:%\n" item.id item.type displayValue
The following information will help you continue it:
03-06-2012, 01:35 PM
Thanks Lo, looks like I was way off the mark. This seems to be closer to what I was looking for, will have a play around with this.
03-06-2012, 01:35 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.