ASP.NET Gather information about an image

Posted on 2009-02-20
Last Modified: 2012-05-06
Hello experts.

On my web site I have created the ability to upload, resize and store images.

I now want to be able to gather extra information about these images such as.

When the image was taken.
By what camera etc.

These images will be photographs taken by digital cameras so they will have this type of info embedded into the file.

So my question is how do I get access to this?

I am currently using the file upload control.

Question by:thomasmutton
    LVL 21

    Expert Comment

    Using a Bitmap or Image object, you must load the image first in the instance object....Then using either one of the before mentioned, it will have accessors ...i.e.  Bitmap x = (Path...filename);....
                                             int x = x.Width;
    LVL 21

    Expert Comment

    if you look up the properties of image, bitmap/image will have an accessor for each property of the image...some may have null value, you have to take that into consideration....
    LVL 21

    Expert Comment

    and finally, yes,  you have to load way to just go into the directory and get attributes of file that way...

    Author Comment

    This is the code I have been using to resize the image..

    So what you are saying is that I have to get the properties from the bitmap object?

    So in my case it would be accessed at
    Bitmap temp ?

    I have looked at the properties of this bitmap object and there are none for exif data..
        private void ResizeImageWithAspect(int intWidth, string strSize)
            Image original = System.Drawing.Image.FromStream(new MemoryStream(byteImage));
            //Find the aspect ratio between the height and width.
            float aspect = (float)original.Height / (float)original.Width;
            //Calculate the new height using the aspect ratio
            // and the desired new width.
            int newHeight = (int)(intWidth * aspect);
            //Create a bitmap of the correct size.
            Bitmap temp = new Bitmap(intWidth, newHeight, original.PixelFormat);
            //Get a Graphics object from the bitmap.
            Graphics newImage = Graphics.FromImage(temp);
            int intFontWidth = 215;
            int intFontHeight = 35;
            int intFontSize = 10;
            // Create font
            System.Drawing.Font font = new System.Drawing.Font("Trebuchet MS", intFontSize);
            // Create text position
            System.Drawing.PointF point = new System.Drawing.PointF(temp.Width - intFontWidth, temp.Height - intFontHeight);
            //Draw the image with the new width/height
            newImage.DrawImage(original, 0, 0, intWidth, newHeight);
            if (strSize == "620")
                //Draw on the watermark
                newImage.DrawString("Copyright © " + DateTime.Now.Year.ToString() + "", font, System.Drawing.Brushes.White, point);
            //Save the bitmap
            temp.Save(HttpContext.Current.Server.MapPath("~/Images/UserPhotos/" + strSize + "/" + intId.ToString() + ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);
            //Dispose of our objects.

    Open in new window

    LVL 21

    Accepted Solution

    ok...i see what you mean...

    they have  a library to use to do this...just add it to your bin and reference it...

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now