The form data is posted to "showiptc.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 IPTC text 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 "showiptcimage.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. This part of the example is identical to the Upload and Resize example so the description is not repeated here.
Below is some of the code that extracts the IPTC meta data:
<%
If not Image.HasFileInfo and not Image.HasXMP Then
Response.Write "No meta data in the image."
Else
Response.Write "<p><b>IPTC text:</b><br>"
If Image.FFO_Caption <> "" Then
Response.Write "Caption: " & Server.HTMLEncode(Image.FFO_Caption) & "<br>"
End If
If Image.FFO_CaptionWriter <> "" Then
Response.Write "Caption Writer: " &_
Server.HTMLEncode(Image.FFO_CaptionWriter) & "<br>"
End If
If Image.FFO_Headline <> "" Then
Response.Write "Headline: " & Server.HTMLEncode(Image.FFO_Headline) & "<br>"
End If
If Image.FFO_DateCreated <> 0 Then
Response.Write "Date Created: " &_
Server.HTMLEncode(Image.FFO_DateCreated) & "<br>"
End If
If Image.FFO_CopyrightFlag = true Then
Response.Write "Copyright Flag: " &_
Server.HTMLEncode(Image.FFO_CopyrightFlag) & "<br>"
End If
If Image.FFO_KeywordsCount > 0 Then
Response.Write "Keywords: "
For I = 0 to Image.FFO_KeywordsCount - 1
Response.Write Image.FFO_Keywords(I) & " "
Next
Response.Write "<br>"
End If
If Image.FFO_SuppCatCount > 0 Then
Response.Write "Supplemental Categories: "
For I = 0 to Image.FFO_SuppCatCount - 1
Response.Write Image.FFO_SuppCat(I) & " "
Next
Response.Write "<br>"
End If
Response.Write "Urgency: " & Image.FFO_Urgency & "</p>"
End If
%>
Each meta data attribute supported has its own property. Most are string values and only the first three are shown here. The Keywords and SupplementalCategories are lists of values and they are displayed by looping through the list.
People tags are also lists and they require a loop, but the rectangle is optional and is not always present. csImageFile converts the rectangle postion and dimensions into pixels and so the values displayed are relevant to the resized image, not the original. The values stored inside the file are fractions of the image size and so they still locate the same region after resizing the image.
If Image.XMPPersonTagCount > 0 Then
For I = 0 to Image.XMPPersonTagCount - 1
Response.Write "XMPPersonTag: " & Image.XMPPersonTag(I) & "<br />"
If Image.XMPRectangleWidth(I) > 0 Then
Response.Write "Rectangle Position: (" & Image.XMPRectangleX(I) & ", " &_ Image.XMPRectangleY(I) & ")<br />"
Response.Write "Rectangle Size: " & Image.XMPRectangleWidth(I) & " x " &_ Image.XMPRectangleHeight(I) & "<br />"
End If
Next
End If
© Chestysoft, 2024.
This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.