function openjpgfile(filename)
dim ascii, lasthex, currenthex, sosfound
dim fso, file, i
if not filename = "" then
if instr(1, filename, ":\") = 0 then
filename = server.mappath(filename)
end if
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(filename) then
set file = fso.opentextfile(filename, forreading, false, tristatefalse)
i = 0
while not file.atendofstream and sosfound = false
ascii = asc(file.read(1))
lasthex = currenthex
currenthex = right("0" & hex(ascii), 2)
if lasthex & currenthex = "ffda" or i > 100000 then
sosfound = true
end if
exiftemp(i) = currenthex
i = i + 1
redim preserve exiftemp(i)
wend
file.close
set file = nothing
else
response.write("file does not exist")
end if
set fso = nothing
end if
end function
sub getdirectoryentries(offset)
dim no_of_entries
dim upper_ifddirectory
dim newdimensions
dim processed_exifsubifd
dim bytespercomponent
dim offset_to_makernote
dim i, j, k
do
if isintel then
no_of_entries = _
hextodec(exiftemp(offset + 1)) * 256 + _
hextodec(exiftemp(offset + 0))
else
no_of_entries = _
hextodec(exiftemp(offset + 0)) * 256 + _
hextodec(exiftemp(offset + 1))
end if
on error resume next
upper_ifddirectory = ubound(ifddirectory)
on error goto 0
newdimensions = upper_ifddirectory + no_of_entries
redim preserve ifddirectory(newdimensions)
for i = 1 to no_of_entries
k = upper_ifddirectory + i – 1
ifddirectory(k) = array(null,null,null,null,null,null,null)
with ifddirectory(upper_ifddirectory + i)
if isintel then
ifddirectory(k)(ifd_idx_tag_no) = _
exiftemp((offset + 2) + ((i – 1) * 12) + 1) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 0)
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 1)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 0))
ifddirectory(k)(ifd_idx_data_format) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 3)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 2))
ifddirectory(k)(ifd_idx_components) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 7)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 6)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 5)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 4))
select case ifddirectory(k)(ifd_idx_data_format)
case m_byte, m_sbyte
bytespercomponent = 1
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
exiftemp((offset + 2) + ((i – 1) * 12) + 11) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 10) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 9) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 8)
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
for j = 0 to ifddirectory(k)(ifd_idx_components) – 1
ifddirectory(k)(ifd_idx_value) = ifddirectory(k)(ifd_idx_value) & exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + j)
next
end if
case m_string, m_undefined
bytespercomponent = 1
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8)))
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
for j = 0 to ifddirectory(k)(ifd_idx_components) – 2
ifddirectory(k)(ifd_idx_value) = ifddirectory(k)(ifd_idx_value) & chr(hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + j)))
next
end if
case m_short, m_sshort
bytespercomponent = 2
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
for j = 0 to ifddirectory(k)(ifd_idx_components) – 1
ifddirectory(k)(ifd_idx_value) = ifddirectory(k)(ifd_idx_value) & exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + j)
next
end if
case m_long, m_slong
bytespercomponent = 4
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
for j = 0 to ifddirectory(k)(ifd_idx_components) – 1
ifddirectory(k)(ifd_idx_value) = ifddirectory(k)(ifd_idx_value) & exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + j)
next
end if
case m_rational, m_srational
bytespercomponent = 8
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))
ifddirectory(k)(ifd_idx_value) = _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 3)) * 256 * 256 * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 2)) * 256 * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 1)) * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 0)) & _
"/" & _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 7)) * 256 * 256 * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 6)) * 256 * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 5)) * 256 + _
hextodec(exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + 4))
end select
else
ifddirectory(k)(ifd_idx_tag_no) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 0)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 1))
ifddirectory(k)(ifd_idx_data_format) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 2)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 3))
ifddirectory(k)(ifd_idx_components) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 4)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 5)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 6)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 7))
select case ifddirectory(k)(ifd_idx_data_format)
case m_byte, m_sbyte
bytespercomponent = 1
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
exiftemp((offset + 2) + ((i – 1) * 12) + 8) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 9) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 10) & _
exiftemp((offset + 2) + ((i – 1) * 12) + 11)
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11))
for j = 0 to ifddirectory(k)(ifd_idx_components) – 1
ifddirectory(k)(ifd_idx_value) = ifddirectory(k)(ifd_idx_value) & exiftemp(offset_to_tiff + ifddirectory(k)(ifd_idx_offsettovalue) + j)
next
end if
case m_string, m_undefined
bytespercomponent = 1
if ifddirectory(k)(ifd_idx_components) * bytespercomponent <= 4 then
ifddirectory(k)(ifd_idx_value) = _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10))) & _
chr(hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 11)))
else
ifddirectory(k)(ifd_idx_offsettovalue) = _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 8)) * 256 * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 9)) * 256 * 256 + _
hextodec(exiftemp((offset + 2) + ((i – 1) * 12) + 10)) * 256 + _