.net Metafile class?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Display Modes
  03 March 2012
.net Metafile class?

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.


"i'd rather have a full bottle in front of me than a full frontal lobotomy"
  03 March 2012
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 March 2012
There are tools out there to do what you want like DCRaw and ExifTools, 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.

"The Evil Monkey hiding in your closet."
  03 March 2012
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
    FileMode=dotNetClass "System.IO.FileMode"
    FileAccess=dotNetClass "System.IO.FileAccess"
    FileShare=dotNetClass "System.IO.FileShare"
    BitmapStream = dotNetObject "System.IO.FileStream" file FileMode.Open FileAccess.ReadWrite FileShare.ReadWrite;
    --Jpeg bitmap decoder
    BitmapCreateOptions=dotNetClass "System.Windows.Media.Imaging.BitmapCreateOptions"
    BitmapCacheOption=dotNetClass "System.Windows.Media.Imaging.BitmapCacheOption"
    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[0]

   Jpegframe = bitmapdecoder.frames.Item[0]

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'd rather have a full bottle in front of me than a full frontal lobotomy"
  03 March 2012
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 March 2012
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.
"i'd rather have a full bottle in front of me than a full frontal lobotomy"
  03 March 2012
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 09:46 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.