.net Metafile class?

Become a member of the CGSociety

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

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2012   #1
.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.

Thanks,

D.
__________________
"i'd rather have a full bottle in front of me than a full frontal lobotomy"
 
Old 03 March 2012   #2
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:

http://www.developerfusion.com/arti...photo-metadata/
 
Old 03 March 2012   #3
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.

-Eric
__________________
"The Evil Monkey hiding in your closet."
 
Old 03 March 2012   #4
A c# library:

http://www.codeproject.com/Articles...XIF-information
 
Old 03 March 2012   #5
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
    file=@"c:\test.jpg"
    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?

Thanks,

D.
__________________
"i'd rather have a full bottle in front of me than a full frontal lobotomy"
 
Old 03 March 2012   #6
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
		(
			1:(v)
			2:(asciiCls.getString v 0 (l-1))
			3:(bCnv.ToUInt16 v 0)
			4:(bCnv.ToUInt32 v 0)
			7:(bCnv.ToInt32 v 0)
			default:(v)
			
			
		)
		format "ID:%\tType:%\tValue:%\n" item.id item.type displayValue
	)
	thebmp.dispose()


The following information will help you continue it:
http://msdn.microsoft.com/en-us/lib...yitem.type.aspx
http://msdn.microsoft.com/en-us/library/ms534418(v=vs.85).aspx
 
Old 03 March 2012   #7
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"
 
Old 03 March 2012   #8
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
CGSociety
Society of Digital Artists
www.cgsociety.org

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

All times are GMT. The time now is 07:24 PM.


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