Home
What's New

User Manual
1. Introduction
2. Thumbnails
3. Using AspUpload
4. Image Processing
5. Drawing & Typing
6. Picture-in-Picture
7. Metadata
8. Miscellaneous
9. GIF Output

Object Reference
Live Demos
Support

Download & Buy

Other Products
Contact Us


Search this site:

Chapter 8: Miscellaneous Features Chapter 6: Picture-in-Picture Chapter 7: Metadata Extraction

7.1 Metadata Overview
7.2 EXIF Item List
7.3 IPTC Item List
7.4 TIFF Support
7.5 Metadata Preservation
7.6 Metadata Editing

7.1 Metadata Overview

Most digital cameras nowadays embed various pieces of information into the JPEG images they generate, including the current date/time, shooting conditions (e.g. whether a flash was used), camera settings (shutter, aperture, focal length), etc. Adobe Photoshop, the leading image editing package, is also capable of embedding various pieces of metadata into the JPEGs it produces, such as an author, title, copyright notice, etc.

The format for camera-embedded metadata is called EXIF, which stands for Exchangeable Image File Format. For more information on EXIF, visit www.exif.org. The format used by Photoshop is described by the International Press Telecommunications Council (www.iptc.org) and usually referred to as IPTC.

AspJpeg 1.4+ is capable of extracting EXIF and IPTC metadata from JPEG images via the OpenInfo and OpenInfoBinary methods. The difference between the two is the same as between Open and OpenBinary - the former opens a source image from disk, the latter from memory.

The OpenInfo and OpenInfoBinary methods both return an instance of the Info object which is a collection of InfoItem objects, each representing a separate EXIF or IPTC field. The InfoItem object supports the following properties: Name (String), Value (Variant, default property), Tag (Integer), and Description (String).

The following code sample extracts and displays all metadata fields from a JPEG image:

VB Script:
<%
' Directory with images
Path = Server.MapPath("../images/photo.jpg")

Set Jpeg = Server.CreateObject("Persits.Jpeg")

' Open image for metadata exraction
Set Info = Jpeg.OpenInfo( Path )

' Display collection of items
For Each Item in Info
  Response.Write "<TR><TD>"
  Response.Write Item.Name & "</TD><TD>"
  Response.Write Item.Description & "</TD><TD>"
  Response.Write Item.Value & "</TD>"

  Response.Write "</TD></TR>"
Next
%>

C#:
<script runat="server" LANGUAGE="C#">

void Page_Load(Object Source, EventArgs E)
{
IASPJpeg objJpeg;
objJpeg = new ASPJpeg();

// Compute path to source image
String strPath = Server.MapPath("../images/photo.jpg");

// Open source image for metadata exraction
IInfo objInfo = objJpeg.OpenInfo( strPath );

foreach( IInfoItem objItem in objInfo )
{
  TableRow objRow = new TableRow();

  TableCell objCell1 = new TableCell();
  objCell1.Controls.Add( new LiteralControl( objItem.Name ) );

  TableCell objCell2 = new TableCell();
  objCell2.Controls.Add(new LiteralControl(objItem.Description));

  TableCell objCell3 = new TableCell();
  objCell3.Controls.Add(
    new LiteralControl( objItem.Value.ToString() ) );

  objRow.Cells.Add( objCell1 );
  objRow.Cells.Add( objCell2 );
  objRow.Cells.Add( objCell3 );
  objTable.Rows.Add( objRow );
}

}
</script>

Click the links below to run this code sample:

http://localhost/aspjpeg/manual_07/07_metadata.asp
http://localhost/aspjpeg/manual_07/07_metadata.aspx  Why is this link not working?

To obtain a value for a specific metadata field, such as a camera make, you should use Info's default Item property which accepts this field's name as an index. Since Item is the default property, the word "Item" can be omitted. In C#, square brackets must be used. The following code snippet obtains camera make information and assigns it to a string variable:

VB Script:
Dim s
s = Info("Make")
C#:
String s = Info["Make"].Value;

All valid EXIF and IPTC field names are listed below.

7.2 EXIF Item List

The following table lists all valid EXIF field names and descriptions. Most real-world images only contain a small subset of these items, if any. Note that in addition to general image and camera setting information, EXIF also provides for GPS-related data.

NameDescription
NewSubfileTypeSubfile type
ImageWidthImage width
ImageLengthImage height
BitsPerSampleNumber of bits per component
CompressionCompression scheme
PhotometricInterpretationPixel composition
ImageDescriptionImage title
MakeManufacturer of image input equipment
ModelModel of image input equipment
StripOffsetsImage data location
OrientationOrientation of image
SamplesPerPixelNumber of components
RowsPerStripNumber of rows per strip
StripByteCountsBytes per compressed strip
XResolutionImage resolution in width direction
YResolutionImage resolution in height direction
PlanarConfigurationImage data arrangement
ResolutionUnitUnit of X and Y resolution
TransferFunctionTransfer function
SoftwareSoftware used
DateTimeFile change date and time
ArtistPerson who created the image
HostComputerThe computer and/or operating system in use
WhitePointWhite point chromaticity
PrimaryChromaticitiesChromaticities of primaries
JPEGInterchangeFormatOffset to JPEG SOI
JPEGInterchangeFormatLengthBytes of JPEG data
YCbCrCoefficientsColor space transformation matrix coefficients
YCbCrSubSamplingSubsampling ratio of Y to C
YCbCrPositioningY and C positioning
ReferenceBlackWhitePair of black and white reference values
CopyrightCopyright holder
ExifTagExif IFD Pointer
GPSTagGPSInfo IFD Pointer
ExposureTimeExposure time
FNumberF number
ExposureProgramExposure program
SpectralSensitivitySpectral sensitivity
ISOSpeedRatingsISO speed ratings
OECFOptoelectric coefficient
ExifVersionExif Version
DateTimeOriginalDate and time original image was generated
DateTimeDigitizedDate and time image was made digital data
ComponentsConfigurationMeaning of each component
CompressedBitsPerPixelImage compression mode
ShutterSpeedValueShutter speed
ApertureValueAperture
BrightnessValueBrightness
ExposureBiasValueExposure bias
MaxApertureValueMaximum lens aperture
SubjectDistanceSubject distance
MeteringModeMetering mode
LightSourceLight source
FlashFlash
FocalLengthLens focal length
SubjectAreaSubject area
MakerNoteManufacturer notes
UserCommentUser comments
SubSecTimeDateTime subseconds
SubSecTimeOriginalDateTimeOriginal subseconds
SubSecTimeDigitizedDateTimeDigitized subseconds
FlashpixVersionSupported Flashpix version
ColorSpaceColor space information
PixelXDimensionValid image width
PixelYDimensionValid image height
RelatedSoundFileRelated audio file
InteroperabilityTagInteroperability IFD Pointer
FlashEnergyFlash energy
SpatialFrequencyResponseSpatial frequency response
FocalPlaneXResolutionFocal plane X resolution
FocalPlaneYResolutionFocal plane Y resolution
FocalPlaneResolutionUnitFocal plane resolution unit
SubjectLocationSubject location
ExposureIndexExposure index
SensingMethodSensing method
FileSourceFile source
SceneTypeScene type
CFAPatternCFA pattern
CustomRenderedCustom image processing
ExposureModeExposure mode
WhiteBalanceWhite balance
DigitalZoomRatioDigital zoom ratio
FocalLengthIn35mmFilmFocal length in 35 mm film
SceneCaptureTypeScene capture type
GainControlGain control
ContrastContrast
SaturationSaturation
SharpnessSharpness
DeviceSettingDescriptionDevice settings description
SubjectDistanceRangeSubject distance range
ImageUniqueIDUnique image ID
RelatedImageFileFormatFile format of image file
RelatedImageWidthImage width
RelatedImageLengthImage height
GPSVersionIDGPS tag version
GPSLatitudeRefNorth or South Latitude
GPSLatitudeLatitude
GPSLongitudeRefEast or West Longitude
GPSLongitudeLongitude
GPSAltitudeRefAltitude reference
GPSAltitudeAltitude
GPSTimeStampGPS time (atomic clock)
GPSSatellitesGPS satellites used for measurement
GPSStatusGPS receiver status
GPSMeasureModeGPS measurement mode
GPSDOPMeasurement precision
GPSSpeedRefSpeed unit
GPSSpeedSpeed of GPS receiver
GPSTrackRefReference for direction of movement
GPSTrackDirection of movement
GPSImgDirectionRefReference for direction of image
GPSImgDirectionDirection of image
GPSMapDatumGeodetic survey data used
GPSDestLatitudeRefReference for latitude of destination
GPSDestLatitudeLatitude of destination
GPSDestLongitudeRefReference for longitude of destination
GPSDestLongitudeLongitude of destination
GPSDestBearingRefReference for bearing of destination
GPSDestBearingBearing of destination
GPSDestDistanceRefReference for distance to destination
GPSDestDistanceDistance to destination
GPSProcessingMethodName of GPS processing method
GPSAreaInformationName of GPS area
GPSDateStampGPS date
GPSDifferentialGPS differential correction
WinTitleWindows Explorer Title
WinAuthorWindows Explorer Author
WinSubjectWindows Explorer Subject
WinCommentsWindows Explorer Comments
WinKeywordsWindows Explorer Keywords

In addition to the pre-defined fields, some images may contain custom fields not described in the EXIF specifications. Custom field names have the form Tag#nnn where nnn is a decimal number, e.g. Tag#37388.

7.3 IPTC Item List

The following IPTC fields are supported by AspJpeg:

IptcByline
IptcBylineTitle
IptcCredits
IptcSource
IptcObjectName
IptcDateCreated
IptcCity
IptcState
IptcCountry
IptcOriginalTransmissionReference
IptcCopyrightNotice
IptcCaption
IptcCaptionWriter
IptcHeadline
IptcSpecialInstructions
IptcCategory
IptcSupplementalCategories
IptcUrgency
IptcKeywords
IptcTimeCreated
IptcDigitalCreationDate
IptcDigitalCreationTime
IptcOriginatingProgram
IptcProgramVersion
IptcUno
IptcEditStatus
IptcFixtureIdentifier
IptcReleaseDate
IptcReleaseTime
IptcObjectCycle
IptcImageNotes
IptcTextSaved
IptcCustom1
IptcCustom2
IptcCustom3
IptcCustom4
IptcCustom5
IptcCustom6
IptcCustom7
IptcCustom8
IptcCustom9
IptcCustom10
IptcCustom11
IptcCustom12
IptcCustom13
IptcCustom14
IptcCustom15
IptcCustom16
IptcCustom17
IptcCustom18
IptcCustom19
IptcCustom20
IptcImageURL
IptcCopyrighted

Note: The IptcKeywords field may appear multiple times in the Info collection. IptcCopyrighted was introduced in version 2.0 of AspJpeg and is a True/False value.

7.4 TIFF Support

If the image being opened is a TIFF, the Info collection will contain a special field by the name of "TiffPages" which contains the number of pages (images) in that TIFF file. This value can be used to iterate through all images in a multi-page TIFF. To open an image with an index other than 1, the property TiffIndex should be used, as follows:

<%
path = "c:\path\multipage.tif"

Set Info = jpeg.OpenInfo(path)
nPages = Info("TiffPages")

For i = 1 To nPages
  jpeg.TiffIndex = i
  jpeg.Open path
  jpeg.Save "c:\path\" & i & ".jpg"
Next
%>

7.5 Metadata Preservation

Starting with Version 1.9, AspJpeg is capable of preserving the Exif and IPTC metadata of the original image when a thumbnail is created. To enable this functionality, you need to set the property PreserveMetadata to True before opening the image, as follows:

<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")

Jpeg.PreserveMetadata = True
Jpeg.Open Path
...
%>

This property must be set before calling Open or OpenBinary, an exception will be thrown otherwise.

Note that preserving metadata in a thumbnail can considerably increase its file size.

7.6 Metadata Editing

As of Version 2.0, AspJpeg can be used to add or replace IPTC values in an image via the method AddMetadataItem. This method accepts two arguments: an IPTC tag from the table shown in Section 7.3 above, and a string value to be inserted under that tag. This method can be called multiple times, if necessary. To use AddMetadataItem, the property PreserveMetadata described in the previous section must be set to True before the image is opened:

<%
Set Jpeg = Server.CreateObject("Persits.Jpeg")

Jpeg.PreserveMetadata = True
Jpeg.Open Path
Jpeg.AddMetadataItem "IptcCaption", "New York City Skyline"
Jpeg.AddMetadataItem "IptcCaptionWriter", "John Smith"
...
Jpeg.Save ...
%>

All IPTC fields are strings with one exception: the IptcCopyrighted tag introduced in version 2.0 is an on/off flag. Use the string "True" to set this flag or "False" to clear it.

Chapter 8: Miscellaneous Features Chapter 6: Picture-in-Picture 

Home
Copyright © 1998 - 2007 Persits Software, Inc.
All Rights Reserved.
AspJpeg is a trademark of Persits Software, Inc.