欢迎光临
我们一直在努力

用JPEG文件EXIF信息ASP版本(3)-ASP教程,ASP应用

建站超值云服务器,限时71元/月

dim offset_to_ifd0

dim offset_to_app0

dim offset_to_app1

dim offset_to_tiff

dim offset_to_sos

dim length_of_app0

dim length_of_app1

dim offset_to_next_ifd

dim ifddirectory

ifddirectory = array(0)

dim offset_to_exifsubifd

dim imagefile

dim isloaded

dim exiftemp

exiftemp = array(0)

const ifd_idx_tag_no = 0

const ifd_idx_tag_name = 1

const ifd_idx_data_format = 2

const ifd_idx_components = 3

const ifd_idx_value = 4

const ifd_idx_value_desc = 5

const ifd_idx_offsettovalue = 6

function lookupexiftag(which)

dim item

for each item in exiflookup

if exiflookup(item) = which then

lookupexiftag = item

exit function

end if

next

lookupexiftag = which

end function

function getexifbyname(exiftag)

if isloaded = false and imagefile <> "" then

loadimage (imagefile)

elseif isloaded = false and imagefile = "" then

exit function

end if

dim i

for i = 0 to ubound(ifddirectory) – 1

if ifddirectory(i)(ifd_idx_tag_name) = exiftag then

getexifbyname = ifddirectory(i)(ifd_idx_value)

exit for

end if

next

end function

sub loadimage(picfile)

if imagefile = "" then

imagefile = picfile

if imagefile = "" then

exit sub

end if

end if

openjpgfile imagefile

if inspectjpgfile = false then

isloaded = false

exit sub

end if

if isintel then

offset_to_ifd0 = _

hextodec(exiftemp(offset_to_app1 + 17)) * 256 * 256 * 256 + _

hextodec(exiftemp(offset_to_app1 + 16)) * 256 * 256 + _

hextodec(exiftemp(offset_to_app1 + 15)) * 256 + _

hextodec(exiftemp(offset_to_app1 + 14))

else

offset_to_ifd0 = _

hextodec(exiftemp(offset_to_app1 + 14)) * 256 * 256 * 256 + _

hextodec(exiftemp(offset_to_app1 + 15)) * 256 * 256 + _

hextodec(exiftemp(offset_to_app1 + 16)) * 256 + _

hextodec(exiftemp(offset_to_app1 + 17))

end if

debug.print "offset_to_ifd0: " & offset_to_ifd0

isloaded = true

getdirectoryentries offset_to_tiff + offset_to_ifd0

makesenseofmeaninglessvalues

end sub

function inspectjpgfile()

dim i

if exiftemp(0) <> "ff" and exiftemp(1) <> "d8" then

inspectjpgfile = false

else

for i = 2 to ubound(exiftemp) – 1

if exiftemp(i) = "ff" and exiftemp(i + 1) = "e0" then

offset_to_app0 = i

exit for

end if

next

if offset_to_app0 = 0 then

inspectjpgfile = false

end if

length_of_app0 = _

hextodec(exiftemp(offset_to_app0 + 2)) * 256 + _

hextodec(exiftemp(offset_to_app0 + 3))

for i = 2 to ubound(exiftemp) – 1

if exiftemp(i) = "ff" and exiftemp(i + 1) = "e1" then

offset_to_app1 = i

exit for

end if

next

if offset_to_app1 = 0 then

inspectjpgfile = false

end if

offset_to_tiff = offset_to_app1 + 10

length_of_app1 = _

hextodec(exiftemp(offset_to_app1 + 2)) * 256 + _

hextodec(exiftemp(offset_to_app1 + 3))

if chr(hextodec(exiftemp(offset_to_app1 + 4))) & chr(hextodec(exiftemp(offset_to_app1 + 5))) & _

chr(hextodec(exiftemp(offset_to_app1 + 6))) & chr(hextodec(exiftemp(offset_to_app1 + 7))) <> "exif" then

inspectjpgfile = false

exit function

end if

inspectjpgfile = true

end if

end function

function isintel()

if exiftemp(offset_to_tiff) = "49" then

isintel = true

else

isintel = false

end if

end function

function writeexiftojpg(exifdata, filename)

dim fso, fso2, file, i

const adtypebinary = 1

const adtypetext = 2

const adsavecreateoverwrite = 2

if isloaded = false and imagefile <> "" then

loadimage (imagefile)

elseif isloaded = false and imagefile = "" then

exit function

end if

create stream object

dim binarystream

set binarystream = createobject("adodb.stream")

specify stream type – we want to save binary data.

binarystream.type = adtypebinary

open the stream and write binary data to the object

binarystream.open

binarystream.write bytearray

set fso = createobject("scripting.filesystemobject")

create text stream object

dim textstream

set textstream = fso.createtextfile(filename & ".tmp")

for i = 0 to (offset_to_app0 + 2 + length_of_app0 – 1)

textstream.write hex2ascii(exiftemp(i))

next

textstream.write hex2ascii(exifdata)

for i = (offset_to_app0 + 2 + length_of_app0) to ubound(exiftemp)

textstream.write hex2ascii(exiftemp(i))

next

set fso2 = server.createobject("scripting.filesystemobject")

if fso2.fileexists(filename) then

set file = fso2.opentextfile(filename, forreading, false, tristatefalse)

i = 0

while not file.atendofstream

if i > ubound(exiftemp) then

binarystream.write file.read(1)

textstream.write file.read(1)

end if

i = i + 1

wend

file.close

set file = nothing

else

response.write("file does not exist")

end if

set fso2 = nothing

set fso = nothing

save binary data to disk

binarystream.savetofile filename & ".tmp", adsavecreateoverwrite

end function

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用JPEG文件EXIF信息ASP版本(3)-ASP教程,ASP应用
分享到: 更多 (0)