Ken Robertson's Blog

Ramblings of a .NET developer

Not making a habit of this...

Not going to let myself make a habit of staying up until 4am working.  Especially since last night, I stayed up until about 3am working.

Up working so late because I really wanted to work on improving the way metadata (EXIF data) is stored in Community Server :: Gallery.  One user on communityserver.org had suggested that we add an option to order pictures based on the EXIF picture date value.  This was definitely a great idea, since even though I haven't used CS on a live site, I certainly have noticed the issue with sorting by upload date and upload a bunch of your digital photos.

I want everything ordered by dates, since I have my misc folders that randomly get new stuff, and I want the most recent ones up on top.  But for my digital photos, I want those in the order I took them.  To do that, I basically have to upload them in reverse of the order that I took them.  Not very logical.

I don't want to override the post date with the picture date, since I want to use the "top 5 most recent pictures" module and if I did that, if I uploaded a pic that was taken a year ago of my cousin Bob, then it wouldn't show up, even though I just uploaded it.  And I need to be able to query the EXIF date in the database to handle the paging right, but it is stored in a serialized string with all the other EXIF data.

Solution?  Branch the metadata off into a separate table just for metadata.  But I wanted to take it further than that.  I want to be able to format fields like date/times to the user's selected format... but I don't want to have to parse it from a string to a DateTime.  If I put a DateTime into the DB, I want a DateTime back.  Same for string, int, float, double, whatever.  Also, looking out to expanding CS even further, there might be a use sometime for this kind of thing.

At first, I was thinking about converting everything to a byte array and store it that way.  However, we can't use a BinaryFormatter since it won't work under medium trust (one of our goals is to work in medium trust).  Then was trying to convert them using uglier methods, which didn't work.  Finally I woke up and released I could use a string and store the original type as well.  Convert everything to a string (DateTimes go to 2004-12-31 04:12:31), store the type (System.DateTime), and then use Convert.ChangeType() to get the original object back.  Yay.  Also serialize everything into an XML string so all the types are sent to the DB at once.

Next... work on reading the EXIF tags raw.  Using System.Drawing can to get the properties can be a huge drain, especially with some of the bulk upload tools we're working on (this thing will knock everyone's socks off... its cool... like, why didn't I think of that before cool).

Posted: Dec 31 2004, 04:18 AM by qgyen | with no comments
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)