aspjpeg is a very powerful image processing component, pure English version. However, there are already free versions and cracked versions, but there are not many articles that introduce them in detail and in-depth. Even if there are, they only involve image thumbnails and image watermarks. Maybe it's because it's in pure English.
Using aspjepg you can mainly do:
Image thumbnail
Picture watermark
security code technology
Picture cutting
Picture merge
Database support
1. Picture thumbnails.
Check out the processed pictures.
2. Picture watermark.
.
3. Security code
.
The principle of Ping An Ma is similar to adding a watermark.
.
Image of generated security code.
4. Picture cutting
.
For a long time, people who don't know about aspjpeg thought that they couldn't use it for cutting.
In fact, there is such a method
crop x1,y1,x2,y2
Cut the x coordinate of the upper left corner of the rectangle and the y coordinate of the lower right corner of the rectangle.
I will give a demonstration below.
SetJpeg =
Server.CreateObject(Persits.Jpeg)
jpeg.open server.MapPath(/pic/1.gif)
jpeg.width=70
Jpeg.Height = Jpeg.OriginalHeight*70 / jpeg.Originawidth
jpeg.crop 0,0,70,52 Starting to cut is actually to remove the lower part that exceeds 52 pixels.
jpeg.save
server.MapPath(/temp_pic/small_1.gif) Save
5. Picture merging
.
Here we are going to add the logo image to the dodge_viper.jpg image
Set Photo =
Server.CreateObject(Persits.Jpeg)
PhotoPath = Server.MapPath(images)
& /dodge_viper.jpg
Photo.Open PhotoPath
Set Logo =
Server.CreateObject(Persits.Jpeg)
LogoPath = Server.MapPath(images)
& /clock.jpg
Logo.Open LogoPath .
Logo.Width = 70
Logo.Height = Logo.Width * Logo.OriginalHeight / Logo.OriginalWidth
.
Photo.DrawImage 0, 0, Logo .
Photo.SendBinary
The output method of sendBinary is used here. Of course, you can also save the changed dodge_viper.jpg first and then enter it. I personally don't like to use the sendBinary method because it is prone to errors when the network speed is slow. Not much in terms of speed either.
6. Database support
.
Not much to say here. In fact, it is the Binary method. As we all know, images can only be stored as binary files when stored in the database. So the code was written lazily. .
7. Introduction to more methods
.
Canvas.Line(Left, Top, Right, Bottom)
draw a straight line
Canvas.Ellipse(Left, Top, Right, Bottom)
draw an ellipse
Canvas.Circle(X, Y,
Radius)
draw a circle
Canvas.Bar(Left, Top, Right, Bottom)
Draw a rectangle with the code introduced on it
Canvas.Font.ShadowColor
text shadow color
Canvas.Font.ShadowXOffset As Long
Shadow X coordinate setting
Canvas.Font.ShadowYOffset As Long
Y coordinate setting
Canvas.Font.BkMode As String
text background.
'//------Pollener.com AspJpeg component preview and watermark generation------Start------
'Create preview image: call
CreateView (path to original file, preview file name and path)
Sub
CreateView(imagename,tempFilename)
'Define variables.
Dim
PreviewImageFolderName
Dim ogvbox,objFont
Dim Logobox,LogoPath
LogoPath
= Server.MapPath(images) & /shuiyin.gif
'//Add the path and file name of the image (mine is forum/images/shuiyin.gif).
Select Case
upload_ViewType
Case
0
'---------------------CreatePreviewImage---------------
setogvbox=
Server.CreateObject(CreatePreviewImage.cGvbox)
ogvbox.SetSavePreviewImagePath=Server.MapPath(tempFilename)
'Preview image storage path.
ogvbox.SetPreviewImageSize =SetPreviewImageSize
'Preview width.
ogvbox.SetImageFile = trim(Server.MapPath(imagename))
'The physical path of the original file of imagename.
'Create a preview image file.
If
ogvbox.DoImageProcess=false Then
Response.write generates preview image error:&
ogvbox.GetErrString
End If
Case
1
'---------------------AspJpegV1.2--------------
Set Logobox =
Server.CreateObject(Persits.Jpeg)
'//It is recommended not to use image and text watermarks at the same time. This code uses image watermarks.
Logobox.Open
LogoPath '//Read the added image.
'//Reset the size of the picture.
Logobox.Width = 186
'//Width value (pixels) of the image used as watermark.
Logobox.Height = 52
'//Height value (pixels) of the image used as watermark.
'//Add watermark.
Set ogvbox =
Server.CreateObject(Persits.Jpeg)
'//Read the original file to be processed.
ogvbox.Open
Trim(Server.MapPath(imagename))
If ogvbox.OriginalWidth and FileExtgif Then '//If you change this line to IF
ImageMode
Then you can also add watermarks to the uploaded GIF images, but those animated GIFs will only have the first frame after adding the watermark. You can handle it according to your needs.
'//About changing the font and text color.
'//ogvbox.Canvas.Font.Color
= &H0000FF '//The color of the watermark text, enter the color value after &H.
'//ogvbox.Canvas.Font.Size =
18 '//The size of the watermark text.
'//ogvbox.Canvas.Font.Family = Arial
'//The font name of the watermark text.
'//ogvbox.Canvas.Font.ShadowColor = &H000000
'//The shadow color of the watermark text.
'//ogvbox.Canvas.Font.ShadowXoffset = 1
'//The pixel value of the watermark text shadow shifted to the right. Enter a negative value to shift to the left.
'//ogvbox.Canvas.Font.ShadowYoffset = 1
'//The pixel value by which the watermark text shadow is shifted downwards. If you enter a negative value, it will be shifted to the right.
'//ogvbox.Canvas.Font.Quality = 3
'//The clarity of the watermark text ranges from 0 to 4. The change is not very large. It is recommended to use 2 or 3.
'//ogvbox.Canvas.Font.Bold = True
'//Whether the watermark text is bold, True=bold False=normal.
'ogvbox.Canvas.Print 10, 10,
ImageMode '//Starting coordinates (pixels) of the watermark text.
ogvbox.Canvas.Pen.Color =
&H000000 '//The border color of the picture after adding watermark.
ogvbox.Canvas.Pen.Width = 1
'//Increase the border width of the image after watermarking.
ogvbox.Canvas.Brush.Solid = False
'//Whether the border is filled with color, you can try it to see the effect when the value is True^o^
ogvbox.DrawImage ogvbox.width-186,
ogvbox.height-52, Logobox, 0.5 '//The starting coordinates of the watermark image, here is ogvbox.width-186,
ogvbox.height-52 means that the picture is in the lower right corner. Because the width of my picture is 186 and the height is 52, so if you write it like this, you can adjust it according to your own picture. 0.5 means transparency, here I mean translucency, 1 means opacity, you can also try 0.7 or 0.8 to see the effect.
ogvbox.Canvas.Bar
0, 0, ogvbox.Width, ogvbox.Height
'//Available range of watermark. What I mean here is that the watermark can be added anywhere from the upper left corner to the lower right corner of the entire image.
ogvbox.Save
Server.MapPath(imagename) '//Generate the image file with added watermark based on the above parameters.
End
If
ogvbox.Width = ImageWidth
ogvbox.height =
ImageHeight
'ogvbox.height =
ogvbox.Originalheight*ImageWidth/ogvbox.OriginalWidth
ogvbox.Sharpen 1, 120
ogvbox.Save
Server.MapPath(tempFilename) '//Generate a preview image of the image after adding watermark.
End
If
Set Logobox=Nothing
'//------Pollener.com
Preview and watermark generation of AspJpeg component ------End-----