aspjpeg is a very powerful image processing component. However, this software now has free versions and cracked versions, but there are few articles about them in detail. Even if there are, they also involve image abbreviations and image watermarks. So do you know how to use the aspjpeg component? Today, let the editor of the Foo New Technology Channel take you to learn more!
Using aspjepg can mainly do:
Picture thumbnail
Picture watermark
Security code technology
Picture cutting
Picture merge
Database support
1. Picture thumbnail.
View processed pictures.
2. Picture watermark.
.
3. Security code
.
The truth of the Safe Ma is similar to adding a watermark.
.
Generate a picture of the security code.
4. Picture cutting
.
People who don't know aspjpeg have always thought that they cannot use it to cut.
There is actually such a method
crop x1,y1,x2,y2
Cut the x-coordinate of the upper left corner of the rectangle, the x-coordinate of the lower right corner of the y-coordinate
I'll give a demonstration below
Set Jpeg =
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 Start cutting is actually removing the lower part of more than 52 pixels
jpeg.save
server.MapPath("/temp_pic/small_1.gif") Save
5. Picture merger
.
Here we want 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
Here we use the output method of sendBinary. Of course, you can also save the changed dodge_viper.jpg first, and then enter it. I personally don’t like using the sendBinary method, and it is easy to make mistakes when the internet speed is slow. Not very good at speed.
6. Database support
.
I won't say much 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 I'm lazy to write the code. .
7. 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 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 Preview and watermark generation of AspJpeg components------------------------------------------------------------------------------------------------
'Create a preview image: call
CreateView (the path of the original file, preview file name and path)
Sub
CreateView(imagename,tempFilename)
'Define the variable.
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
'--------------------------------------------
set ogvbox =
Server.CreateObject("CreatePreviewImage.cGvbox")
ogvbox.SetSavePreviewImagePath=Server.MapPath(tempFilename)
'Preview image storage path.
ogvbox.SetPreviewImageSize =SetPreviewImageSize
'Preview image width.
ogvbox.SetImageFile = trim(Server.MapPath(imagename))
'imagename physical path to the original file.
'Create a file for the preview diagram.
If
ogvbox.DoImageProcess=false Then
Response.write "Generate preview image error:"&
ogvbox.GetErrString
End If
Case
1
'-----------------------------------------------------------------------------------------------------------------------------
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.
'//Resize the image.
Logobox.Width = 186
'//The width value (pixel) of the image used as the watermark.
Logobox.Height = 52
'//The height value (pixel) of the image used as the watermark.
'//Add a watermark.
Set ogvbox =
Server.CreateObject("Persits.Jpeg")
'//Read the original file to be processed.
ogvbox.Open
Trim(Server.MapPath(imagename))
If ogvbox.OriginalWidth"" and FileExt"gif" Then '//If you change this line to IF
ImageMode""
Then you can also add a watermark to the uploaded GIF images, but after adding a watermark to those animation GIFs, you will only have the first frame left. Please handle it as appropriate according to your needs.
'//About modifying 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 shifts to the right, and if the negative value is entered, the left will shift.
'//ogvbox.Canvas.Font.ShadowYoffset = 1
'//The pixel value of the watermark text shadow shifts downward, and if the negative value is entered, the right will shift.
'//ogvbox.Canvas.Font.Quality = 3
'//The clarity of the watermark text, from 0 to 4, the transformation is not very large, it is recommended to use 2 or 3.
'//ogvbox.Canvas.Font.Bold = True
'//Is the watermark text in bold? True=bold False=normal.
'ogvbox.Canvas.Print 10, 10,
ImageMode '//The start coordinate (pixel) of the watermark text.
ogvbox.Canvas.Pen.Color =
&H000000 '//Add the border color of the picture after the watermark.
ogvbox.Canvas.Pen.Width = 1
'//Increase the border width of the image after the watermark.
ogvbox.Canvas.Brush.Solid = False
'//Whether the border is filled with color, you can try the effect when the value is True^o^
ogvbox.DrawImage ogvbox.width-186,
ogvbox.height-52, Logobox, 0.5 '//The starting coordinate of the watermark image, I am here ogvbox.width-186,
ogvbox.height-52 means that the picture is in the lower right corner. Because my picture is 186 wide and the height is 52, so you can adjust it according to your own picture by writing this way. 0.5 is transparency, I am translucent here, 1 means opaque, you can also try the effect of 0.7 or 0.8.
ogvbox.Canvas.Bar
0, 0, ogvbox.Width, ogvbox.Height
'//The range of watermark available. Here I mean that the upper left corner to the lower right corner, that is, the watermark can be added to any one of the entire picture.
ogvbox.Save
Server.MapPath(imagename) '//Create an 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 picture of the image after adding a watermark.
End
If
Set Logobox=Nothing
'//------Pollener.com
Preview and watermark generation of AspJpeg component-----------------------
The above is how to use the aspjpeg component. Interested friends can enter the wrong new technology channel for reference!