Use VBScript and ADODB. Steam to obtain the image length and width in some formats

Source: Internet
Author: User

Function Bytes2bStr (vin)
If lenb (vin) = 0 then
Bytes2bStr = ""
Exit function
End if
''Binary conversion to string
Dim BytesStream, StringReturn
Set BytesStream = Server. CreateObject ("ADODB. Stream ")
BytesStream. Type = 2
BytesStream. Open
BytesStream. WriteText vin
BytesStream. Position = 0
BytesStream. Charset = "gb2312"
BytesStream. Position = 2
StringReturn = BytesStream. ReadText
BytesStream. close
Set BytesStream = Nothing
Bytes2bStr = StringReturn
End Function
Function BinVal (bin)
Dim I
Dim ret: ret = 0
For I = lenb (bin) to 1 step-1
Ret = ret * 256 + ascb (midb (bin, I, 1 ))
Next
BinVal = ret
End Function
Function BinVal2 (bin)
Dim I
Dim ret: ret = 0
For I = 1 to lenb (bin)
Ret = ret * 256 + ascb (midb (bin, I, 1 ))
Next
BinVal2 = ret
End Function
Function getImageWH (fdata)
'One real parameter fdata: binary image data (as for how to read the binary data of an image, you don't have to say -_-!)
'Return value is an array with three elements in the image format. length and width.
Dim ret (2), bFlag, fsize, ADOS
Fsize = clng (lenb (fdata) 'get the data size
If fsize = 0 then Exit Function
Set ADOS = Server. CreateObject ("ADODB. Stream ")
ADOS. Type = 1
ADOS. Mode = 3
ADOS. Open
ADOS. Write fdata
ADOS. Position = 0
'Write Text object read image width and type
ADOS. Position = 0' reset data start Position
BFlag = ADOS. read (3)
If isNull (bFlag) then

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.