Update February 5th, 2005
DOWNLOAD ASP v2.0

This is a set of ASP functions for reading EXIF header data (metadata) from JPEG (.JPG) and TIFF (.TIF) files.

Thank you to Mike Trinder who has done a pretty thorough rewrite of the code and added many nice new features. This is now a sourceforge project. If you would like to contribute then please visit the project pages @ http://sourceforge.net/projects/aspexiffuncs/. Version 2.0 is not backwardly compatible to the function calls from 1.0. Do not overwrite your version 1.x functions_exif.asp until you understand the changes that need to be made.

History

Ryan Vettese:
I had figured out a while ago that it was possible to do binary reads on files in ASP. The idea to convert the binary JPEG header data to HEX was lifted from a script written by Lewis Moten. His script can be found here: http://www.lewismoten.com/Items/File/Zip.asp?ItemID=131. At this point I figured all I would need to get out the Exif data was a specification on the format and a couple hours to do some HEX parsing. I was wrong. Exif data is messy and hard to work with. I did manage to find someone out there who was smarter than me though: The main chunk of code to parse the Exif header comes from Jeremy Waite's Exif reader class/dll for VB 6 found here: http://sourceforge.net/projects/exifclass/. I had to do a lot of converting of his ideas because VB6 and ASP are not the same. Big headache.

Mike Trinder
On my timings, this reads a 22Mb TIFF in around 4 seconds, and a 1.5Mb JPEG in 0.22 seconds. The timing is most affected by how much of the file you need to wind through to reach the EXIF data - JPEGs are fast as this tends to be at the start of the file, the TIFF in question has the entire RAW image before the EXIF data. Moving the file pointer to the EXIF area takes about 3.7 seconds...

If you run across any JPEG images that make this script die a painful death then contact Ryan Vettese here.

Changes
Mike Trinder - 2005/02/03
* thorough rewrite to deal with TIFFs as well as JPEGs
* More efficient IFD reading
* File read buffering
* corrected decoding of inline Undefined format
* More efficient byte order checking
* removed dependance on global variables. Now only file buffer is declated by this include
* Utility functions to read Fstop, Shutter Speed, Date and focallength from EXIF
* More value descriptions added
* IFD number added to IFDdirectory to aid distinguishing between thumbnail and main image in TIFF (not actually used yet though)

TODO
* Process MakerNote for various cameras - some formats here: http://park2.wakwak.com/~tsuruzoh/Computer/Digicams/exif-e.html
* Merge EXIF directories from two images
* Save updated EXIF to image
* Return thumbnail data as image

* Support for more image formats?

This sample image is a JPEG of Times Square in New York City taken on my Canon G3.

Date Time: 10/1/2003 9:22:10 PM
Exif Image Width: 341
Exif Image Height: 454
FStop: 4
Shutter: 1/318s
Focal Length: 7.1875mm

IFD # # Tag HEX Tag Name Format Size Offset Value Value Described
00010EImage Description225170The Description Field...
01010FCamera Make26195Canon
020110Camera Model219201Canon PowerShot G3
030112Orientation311Normal
04011AX Resolution51220180/1
05011BY Resolution51228180/1
060128Resolution Unit312inch
070131Software228236ACD Systems Digital Imaging
080132Date Time2202642003:10:01 21:22:1010/1/2003 9:22:10 PM
09013BArtist27284Ryan V
0100213YCbCr Positioning311
0118298Copyright252912003
0128769Exif Offset41296
0.113829AExposure Time516861/320
0.114829DFStop5169440/10
0.1159000Exif Version7402102.10
0.1169003Date Time Original2207022003:08:25 08:48:548/25/2003 8:48:54 AM
0.1179004Date Time Digitized2207222003:08:25 08:48:548/25/2003 8:48:54 AM
0.1189101Components Configuration74
0.1199102Compressed Bits Per Pixel517425/1
0.1209201Shutter Speed Value101750266/32
0.1219202Aperture Value51758128/32
0.1229204Exposure Bias Value1017660/3
0.1239205Max Aperture Value5177464/32
0.1249207Metering Mode315Multi-segment
0.1259209Flash3124Undefined
0.126920AFocal Length51782230/32
0.127927CMaker Note7606790
0.1289286User Comment7191404Crazy Times Square
0.1299290Subsec Time24156
0.130A000Flash Pix Version7401001.00
0.131A001Color Space311sRGB
0.132A002Exif Image Width41341
0.133A003Exif Image Height41454
0.134A005Exif Interoperability Offset411423
0.135A20EFocal Plane X Resolution5114532272000/280
0.136A20FFocal Plane Y Resolution5114611704000/210
0.137A210Focal Plane Resolution Unit312inch
0.138A217Sensing Method312
0.139A300File Source71
0.140A401A401310
0.141A402A402310
0.142A403A403310
0.143A404A4045114692272/2272
0.144A406A406310
1450103Compression316JPEG
1460201JPEG Interchange Format411519
1470202JPEG Interchange Format Length414723

This sample image is a NON Intel saved JPEG file format (maybe Mac OS?).

Date Time: 4/20/2004 10:07:58 PM
Exif Image Width: 640
Exif Image Height: 480
FStop: 2
Shutter: 1/60s
Focal Length: 7.13mm

IFD # # Tag HEX Tag Name Format Size Offset Value Value Described
00010FCamera Make26146CASIO
010110Camera Model210152QV-5700
020112Orientation311Normal
03011AX Resolution5116272/1
04011BY Resolution5117072/1
050128Resolution Unit312inch
060131Software220178Adobe Photoshop 7.0
070132Date Time2201982004:04:20 22:07:584/20/2004 10:07:58 PM
080213YCbCr Positioning311
09C4A5C4A5740218PrintIM
0108769Exif Offset41260
0.111829AExposure Time5161416666/1000000
0.112829DFStop5162220/10
0.1138822Exposure Program312
0.1149000Exif Version7402202.20
0.1159003Date Time Original2206302003:04:19 18:40:144/19/2003 6:40:14 PM
0.1169004Date Time Digitized2206502003:04:19 18:40:144/19/2003 6:40:14 PM
0.1179101Components Configuration74
0.1189102Compressed Bits Per Pixel5167019293792/4915200
0.1199204Exposure Bias Value1016780/6
0.1209205Max Aperture Value5168620/10
0.1219207Metering Mode315Multi-segment
0.1229208Light Source310
0.1239209Flash3125Undefined
0.124920AFocal Length51694713/100
0.125A000Flash Pix Version7401001.00
0.126A001Color Space311sRGB
0.127A002Exif Image Width41640
0.128A003Exif Image Height41480
0.129A300File Source71
0.130A401A401310
0.131A402A402310
0.132A403A403310
0.133A404A4045170265536/65536
0.134A405A4053134
0.135A406A406310
0.136A407A407310
0.137A408A408310
0.138A409A409312
0.139A40AA40A310
1400103Compression316JPEG
141011AX Resolution5179072/1
142011BY Resolution5179872/1
1430128Resolution Unit312inch
1440201JPEG Interchange Format41806
1450202JPEG Interchange Format Length415154