Download savepic.asp
<%
'---------------------------------------return the IMAGE FORMAT--------------------
function Checkimageformat (checkdata)
'--return:a,b,c (A is image format; B is height pixels; C is width pixels; D is color depth)
Flag=0 ' ' 0 is not jpg/gif/png image; 1 is Jpg/gif/png
'-------------------------------------------------------check jpg----------------
If Flag=0 Then
TEMPSTR=LEFTB (checkdata,10)
TSTR=CHRB (255) &CHRB (216) &CHRB (255) &CHRB (224) &CHRB (0) &CHRB (a) &CHRB (a) &CHRB (70) &CHRB (&CHRB) (70)
If StrComp (tempstr,tstr,0) =0 Then
msgstr01= "JPG"
Lngsize = Len (checkdata)
Flgfound = 0
Strtarget = ChrB (255) & ChrB (216) & ChrB (255)
Flgfound = INSTRB (Checkdata, Strtarget)
Lngpos = Flgfound + 2
Exitloop = False
Do While exitloop = False and Lngpos < lngsize
Do While ASCB (MidB (Checkdata, Lngpos, 1)) = 255 and Lngpos < lngsize
Lngpos = lngpos + 1
Loop
If ASCB (MidB (Checkdata, Lngpos, 1)) < or ASCB (MidB (Checkdata, Lngpos, 1)) > 195 Then
Lngmarkersize = LngConvert2 (MidB (checkdata, Lngpos + 1, 2))
Lngpos = lngpos + lngmarkersize + 1
Else
Exitloop = True
End If
Loop
I_height = LngConvert2 (MidB (Checkdata, Lngpos +4, 2))
I_width = LngConvert2 (MidB (Checkdata, Lngpos +6, 2))
I_depth = 2 ^ (ASCB (MidB (checkdata, Lngpos + 8, 1)) * 8)
Msgstr02= "," & I_height & "," & I_width
flag=2
Else
Flag=0
End If
End If
'--------------------------------------------------check gif--------------------------------
If Flag=0 Then
TEMPSTR=LEFTB (checkdata,6)
TSTR=CHRB (&CHRB) (&CHRB) &CHRB (97) &CHRB (a)
TSTR2=CHRB (&CHRB) &CHRB (&CHRB) &CHRB (97) &CHRB (a)
If StrComp (tempstr,tstr,0) =0 or StrComp (TEMPSTR,TSTR2) =0 Then
msgstr03= "GIF"
I_width=lngconvert (MidB (checkdata,7,2))
I_height=lngconvert (MidB (checkdata,9,2))
I_depth = 2 ^ ((ASCB (MidB (Checkdata, 1)) and 7) + 1)
Msgstr04= "," & I_height & "," & I_width
flag=2
Else
Flag=0
End If
End If
'---------------------------------------------------check PNG------------------------------
If Flag=0 Then
TEMPSTR=LEFTB (checkdata,4)
TSTR=CHRB (137) &CHRB (&CHRB) &CHRB (71)
If StrComp (tempstr,tstr,0) =0 Then
msgstr05= "PNG"
I_width = LngConvert2 (MidB (Checkdata, 19, 2))
I_height = LngConvert2 (MidB (Checkdata, 23, 2))
I_depth = Lngconvert (MidB (Checkdata, 25, 2))
Select Case ASCB (right (i_depth,1))
Case 0
I_depth = 2 ^ (ASC (Left (i_depth, 1))
G