ASPJPEG is shareware produced by Persits. The trial period is 30 days. You can download it here: http://www.persits.com/aspjpeg.exe. The latest version number is 1.3
ASPJPEG is a very powerful image processing component. You can use it to easily create thumbnails of pictures and add watermarks to pictures. Here is a brief introduction to how to use it:
You first need to execute the downloaded exe file to install the component
1. Create thumbnails for images
<% ///' Create instance
Dim Jpeg,Path
Set Jpeg = Server.CreateObject(Persits.Jpeg)
///' The location of the picture
Path = Server.MapPath(images) & ////clock.jpg
///' Open
Jpeg.Open Path
///' Set the thumbnail size (the ratio is set to 50% here)
Jpeg.Width = Jpeg.OriginalWidth / 2
Jpeg.Height = Jpeg.OriginalHeight / 2
///' Save the thumbnail to the specified folder
Jpeg.Save Server.MapPath(images) & ////clock_small.jpg
///' Log out instance
Set Jpeg = Nothing
%>
<IMG SRC=images/clock.jpg><P>
<IMG SRC=images/clock_small.jpg>
2. Add watermark function to pictures
<%
DimJpeg
///' Create instance
Set Jpeg = Server.CreateObject(Persits.Jpeg)
///' Open the target image
Jpeg.Open Server.MapPath(images/dodge_viper.jpg)
///' Add text watermark
Jpeg.Canvas.Font.Color = &HFF0000///' Red
Jpeg.Canvas.Font.Family = Song Dynasty
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Print 10, 10, Copyright (c) Cnmaya.org
///' Save file
Jpeg.Save Server.MapPath(images/dodge_viper_framed.jpg)
///' Unregister object
Set Jpeg = Nothing
%>
I made a picture watermark last time, but the effect was very poor. I couldn't make the picture have a transparent background. If I use a transparent background gif, it will automatically fill it with white. When using the function to remove a certain color, the color of the picture is always impure and the resulting effect is spotty. I had an idea today and combined these two, using a gif with a transparent background and extracting the watermark background color, and it worked!
ogvbox.Canvas.Pen.Color = &H000000 ///'// Color of border
ogvbox.Canvas.Pen.Width = 1 ///'// The thickness of the border
ogvbox.Canvas.Brush.Solid = False ///'// Whether to fill the picture border with color
ogvbox.DrawImage ogvbox.Width-210, ogvbox.Height-74, Logobox ,0.3,&HFFFFFF ///'// Add the position coordinates of the image (add a watermark image), I subtract the watermark size from the image size, and add the watermark to Lower right corner. The order of parameters is: horizontal coordinates, vertical coordinates, watermark image address, mercury transparency, extraction color (&H means hexadecimal)
ogvbox.Canvas.Bar 0, 0, ogvbox.Width, ogvbox.Height ///'// The position coordinates and size of the picture border line
ogvbox.Save Server.MapPath(imagename) ///'// Generate file
/'//------Preview and watermark generation of Pollener.comAspJpeg component------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---------------
set ogvbox = 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 /'//The width value (pixels) of the image used as a 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<Cint(ImageWidth) or ogvbox.Originalheight<Cint(ImageHeight) Then
F_Viewname=
Set ogvbox = Nothing
Exit Sub
Else
IF ImageMode<> and FileExt<>gif 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 remain after adding the watermark. This is the first frame. Please 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 offset to the right. If you enter a negative value, it will offset to the left.
/'//ogvbox.Canvas.Font.ShadowYoffset = 1 /'//The pixel value by which the watermark text shadow is offset downward. If you enter a negative value, it will be offset 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 /'//Add watermark to the border color of the picture.
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, ogvbox.width-186, ogvbox.height-52 means that the image 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
/'//------Preview and watermark generation of Pollener.comAspJpeg component------End------