There are two common ways to generate thumbnails:
First: small pictures scaled to a fixed size
The second type: zoom into equal proportions of small pictures
The disadvantage of the first method is that it distorts the picture, such as a slim mm becoming a fat mm
The disadvantage of the second method is that if the picture is displayed in a table, and the picture's width-height ratio is different from this one, it can't fill the entire table, leaving a void, not good-looking.
The method described here is " fixed scale cropping ," using the AspJpeg component, which means that the resulting thumbnail width ratio is fixed, but not distorted. If the width of the original image is greater than the set width and height ratio, it will automatically cut off the left and right side of the figure, if the original width of the original ratio is less than the set width and height ratio, will automatically cut off the upper and lower redundant graphs.
Function Makepic (sourcpic,newwidth,newheight,destpic) on
Error Resume Next
makepic=false
Set Jpeg = Server.CreateObject ("Persits.jpeg")
if ERR then
response. Write ("Error: Space not installed AspJpeg component")
Response.End end
if
jpeg.quality =
jpeg.open sourcpic
Jpeg. Preserveaspectratio = True ' equal to scaling
if jpeg. Originalwidth/jpeg. OriginalHeight > Newwidth/newheight Then ' too flat to cut off the left and right parts of the
jpeg. Height = Newheight
jpeg.crop CInt (jpeg. Width–newwidth)/2), 0,cint (JPEG. Width–newwidth)/2 +newwidth,newheight
Else ' is too high to cut off the upper and lower part of the
JPEG. Width = Newwidth
jpeg.crop 0,cint (jpeg. Height–newheight)/2), Newwidth,cint (JPEG. Height–newheight)/2) +newheight end
if
jpeg.save destpic
if err.number=0
then makepic=true Jpeg.close
Set jpeg=nothing end
function
The above is the introduction of ASP using AspJpeg fixed-scale clipping thumbnails of the implementation of the method, I hope to help you learn.