Description of "showexif.asp"

The form data is posted to "showexif.asp" which uses csASPUpload to extract the uploaded file as well as some other file information. The image data is then passed into the csImageFile component where it is resized and the EXIF attributes extracted.

Usually the file would then be saved to disk or input into a database but as this is a demonstration using somebody else's image, we have avoided doing this. The file data is stored in a session variable so it can be used later in the script "showexifimage.asp". This is a technique that should be treated with caution because storing large amounts of data in session variables can use a lot of memory. In this case the image is stored after resizing, and the session variable is reset immediately after use, so there should be no problems although most browsers will be unable to print the page showing the image. This part of the example is identical to the Upload and Resize example so the description is not repeated here.

Below is the code that extracts the EXIF attributes:

If Image.ExifCount = 0 Then
  Response.Write "<p>No EXIF data in the image.</p>"
  Response.Write "<p>EXIF Data:</p><p>"
  For I = 0 to Image.ExifCount - 1
    Response.Write Image.ExifName(I) & ": " & Image.ExifValueByIndex(I) & "<br>"
  'The following code has been added to read any XP Summary Information
  If Image.XP_Title <> "" Then
    Response.Write "XPTitle: " & Image.XP_Title & "<br />"
  End If
  If Image.XP_Comments<> "" Then
    Response.Write "XPComments: " & Image.XP_Comments & "<br />"
  End If
  If Image.XP_Author <> "" Then
    Response.Write "XPAuthor: " & Image.XP_Author & "<br />"
  End If
  If Image.XP_Keywords <> "" Then
    Response.Write "XPKeywords: " & Image.XP_Keywords & "<br />"
  End If
  If Image.XP_Subject <> "" Then
    Response.Write "XPSubject: " & Image.XP_Subject & "<br />"
  End If
  Response.Write "</p>"
End If

The names and values of the EXIF attributes are stored in a zero based string array and can either be accessed by index or by quoting the name of the attribute. This example loops through all the values so the index is used and ExifCount is used to find the number of attributes.

Some extra code has been added to check for XP Summary Information, and this will be stored in the properties XP_Title through to XP_Subject.

Return to the upload form.

Click Here for an explanation of writing EXIF attributes.