First of all, we know that the picture on the page is the following code:
<img src = pic.gif border = 0 width = 300 height = 260>
SRC is the picture path, Border controls the width of the picture, width is the length of the picture, and height is the height of the picture. The generation of a narrow diagram is actually zooming in the original size. But in order to be as distortion as possible, we will be scaled proportional. As a result, the length and width size of the picture has also become the focus of a deflection diagram.
The following is the step of writing without components to generate a thumbnail:
1. Get the picture size without components
Before I learned ASP, I saw an article using the ASCII code to obtain picture size without components. Later, I tried it and found that when obtaining the size of the JPG class, it was not always displayed correctly. After checking it online, many websites reproduced this program, but no one pointed out the defects of this program, let alone solve the solution. The defect method. Later, Google was later found an article that introduced the size of the picture size using adodb.stream. According to the method of introducing it, the code inside was tried. The
Use adodb.stream to obtain the general class of picture size
| The following is the code fragment: <% '/////////// GPS: get imprure size ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////gons '///////////// Use adodb.stream to get the picture size ////////////// '//////// cited by leon (Xinqing) August 11, 2005 /////////// Class GPS Dim aso Private sub class_initialize Set aso = CreateObject (Adodb.stream) aso.mode = 3 aso.type = 1 aso.open End sub Private sub class_terminate set aso = Nothing End sub Private function bin2str (bin) Dim i, str For i = 1 to lenb (bin) clow = midb (bin, i, 1) if ascb (clow) <128 then Str = Str & Chr (ASCB (CLOW)) Else I = i 1 if i <= lenb (bin) then str = str & chr (ASCW (MIDB (Bin, I, 1) & CLOW)) end if Next Bin2str = str End function Private function num2str (num, base, lens) 'GPS (2005-8-11) dim Ret RET = While (num> = base) RET = (NUM MOD BASE) & Ret num = (num -num mod base)/base wend NUM2STR = Right (String (Lens, 0) & Num & Ret, Lens) End function Private function str2num (str, base) 'GPS (2005-8-11) dim Ret RET = 0 for i = 1 to len (STR) RET = RET *Base Cint (MID (STR, I, 1)) next Str2num = RET End function Private function binval (bin) 'GPS (2002-8-11) 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 Private function binval2 (bin) 'GPS (2002-8-11) dim Ret RET = 0 for i = 1 to lenb (bin) RET = RET *256 ASCB (MIDB (BIN, I, 1)) next Binval2 = RET End function '/// The following is the call code /// Function GetimageSize (Filespec) 'GPS (2002-8-11) DIM RET (3) ASO.LoadfromFile (Filespec) bflag = ASO.READ (3) Select Case Hex (Binval (BFLAG)) case 4E5089: aso.read (15) RET (0) = PNG RET (1) = binval2 (ASO.READ (2)) aso.read (2) RET (2) = binval2 (ASO.READ (2)) case 464947: aso.read (3) RET (0) = GIF RET (1) = binval (ASO.READ (2)) RET (2) = binval (ASO.READ (2)) case 535746: aso.read (5) bindata = ASO.READ (1) SCONV = Num2str (ASCB (Bindata), 2, 8) nbits = str2num (left (SCONV, 5), 2) SCONV = MID (SCONV, 6) While (Len (SCONV) <nbits*4) bindata = ASO.READ (1) SCONV = SCONV & Num2str (ASCB (Bindata), 2, 8) wend RET (0) = SWF RET (1) = int (ABS (STR2NUM (MID (SCONV, 1*Nbits 1, Nbits), 2) -Str2num (MID (SCONV, 0*NBITS 1, Nbits), 2))/20) RET (2) = int (ABS (STR2NUM (MID (SCONV, 3*Nbits 1, Nbits), 2) -Str2num (MID (SCONV, 2*Nbits 1, Nbits), 2)/20) case FFD8ff: DO do: p1 = binval (ASO.READ (1)): Loop While P1 = 255 and Not Aso.eos if p1> 191 and P1 <196 the exit do else.read (binval2 (ASO.READ (2))-2) do: p1 = binval (ASO.READ (1)): Loop While P1 <255 and Not ASO.EOS Loop While True aso.read (3) RET (0) = JPG RET (2) = binval2 (ASO.READ (2)) RET (1) = binval2 (ASO.READ (2)) case else: if left (bin2str (bflag), 2) = bm then aso.read (15) RET (0) = BMP RET (1) = binval (ASO.READ (4)) RET (2) = binval (aso.read (4)) else RET (0) = end if end select RET (3) = Width = & Ret (1) & Height = & Ret (2) & GetImageSize = RET End function End class %> |
Copy the above code to generate GPS.ASP files, so that the general class of the picture size without components is OK.
2. Now we first design a Showimg.asp page to display a tap map and related information. The specific design is as follows:
picture:
Image format: