ASPJPEG is a shared software developed by Persits. The trial period is 30 days. You can download it at http://www.persits.com/asp;.exe. The latest version is 1.3.
ASPJPEG is a powerful image processing component that allows you to easily create thumbnails and add watermarks to images. The following describes how to use it:
You must first install the downloaded exe file.
1. Create a thumbnail for the image
<% \ 'Create an instance
Dim Jpeg, Path
Set Jpeg = Server. CreateObject ("Persits. Jpeg ")
\\\ 'Image location
Path = Server. MapPath ("images") & "\\\\ clock.jpg"
\ 'Open
Jpeg. Open Path
\\\' Set the thumbnail size (the proportion 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"
\\\' Unregister an instance
Set Jpeg = Nothing
%>
<P>
2. Add a watermark to an image
<%
Dim Jpeg
\ 'Create an instance
Set Jpeg = Server. CreateObject ("Persits. Jpeg ")
\\\' Open the Target Image
Jpeg. Open Server. MapPath ("images/dodge_viper.jpg ")
\\\' Add a text watermark
Jpeg. Canvas. Font. Color = & HFF0000 \ 'red
Jpeg. Canvas. Font. Family = ""
Jpeg. Canvas. Font. Bold = True
Jpeg. Canvas. Print 10, 10, "Copyright (c) Cnmaya.org"
\\\' Save the file
Jpeg. Save Server. MapPath ("images/dodge_viper_framed.jpg ")
\\\ 'Logout object
Set Jpeg = Nothing
%>
The last time I made an image watermark, the effect was very poor. I couldn't make the image transparent to the background. The background transparent gif will be automatically filled in white. With the function of removing a certain color, the image color is always not pure, and the effect is spotted. Today, the two are combined with a gif with a transparent background, and the watermark background is extracted!
Ogvbox. Canvas. Pen. Color = & H000000 \\' // border Color
Ogvbox. Canvas. Pen. Width = 1 \\' // Border Width
Ogvbox. Canvas. Brush. Solid = False \\' // specifies whether the color is filled in the border of the image.
Ogvbox. drawImage ogvbox. width-210, ogvbox. height-74, Logobox, 0.3, & HFFFFFF \ '// Add the coordinates of the position of the image (add the watermark image). I use the image size minus the watermark size and add the watermark to the bottom right corner. The order of parameters is horizontal, vertical, watermark image address, mercury transparency, and color extraction (& H indicates hexadecimal)
Ogvbox. Canvas. Bar 0, 0, ogvbox. Width, ogvbox. Height \ '// coordinates and size of the border line of the image
Ogvbox. Save Server. MapPath (imagename) \\' // generate a file
\ '// ------Pollener.com AspJpeg component preview and watermark generation ------ start ------
\ 'Create preview image: call CreateView (original file path, preview file name and Path)
Sub CreateView (imagename, tempFilename)
\ 'Defines variables.
Dim PreviewImageFolderName
Dim ogvbox, objFont
Dim Logobox, LogoPath
LogoPath = Server. MapPath ("images") & "\ shuiyin.gif" \ '// Add the path and file name of the image (My Forum \ images \ shuiyin.gif ).
Select Case upload_ViewType
Case 0
\ '--------------------- CreatePreviewImage ---------------
Set ogvbox = Server. CreateObject ("CreatePreviewImage. cGvbox ")
Ogvbox. SetSavePreviewImagePath = Server. MapPath (tempFilename) \ 'preview path.
Ogvbox. SetPreviewImageSize = SetPreviewImageSize \ 'preview image width.
Ogvbox. SetImageFile = trim (Server. MapPath (imagename) \ 'physical path of the original imagename file.
\ 'Create a preview image file.
If ogvbox. DoImageProcess = false Then
Response. write "preview Image Generation error:" & ogvbox. GetErrString
End If
Case 1
\ '--------------------- Asp;v1.2 ---------------
Set Logobox = Server. CreateObject ("Persits. Jpeg ")
\ '// We recommend that you do not use both image and text watermarks. This Code uses image watermarks.
Logobox. Open LogoPath \ '// read the added image.
\ '// Reset the image size.
Logobox. Width = 186 \ '// The Width of the image watermark (in pixels ).
Logobox. Height = 52 \ '// The Height of the image watermark (in pixels ).
\ '// 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 <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 add a watermark to the uploaded gif image, however, after the animated GIF is added with a watermark, there will be only the first watermark. Handle it as needed.
\ '// For modifying the font and text color.
\ '// Ogvbox. Canvas. Font. Color = & H0000FF \' // watermark text Color, followed by & H.
\ '// Ogvbox. Canvas. Font. Size = 18 \' // watermark text Size.
\ '// Ogvbox. Canvas. Font. Family = "Arial" \' // The Font name of the watermark text.
\ '// Ogvbox. Canvas. Font. ShadowColor = & H000000 \' // specifies the shadow color of the watermark text.
\ '// Ogvbox. Canvas. Font. ShadowXoffset = 1 \' // The pixel value of the right offset of the watermark text shadow. If a negative value is input, it is shifted to the left.
\ '// Ogvbox. Canvas. Font. ShadowYoffset = 1 \' // The pixel value of the downward offset of the watermark text shadow. If a negative value is input, the value is shifted to the right.
\ '// Ogvbox. Canvas. Font. Quality = 3 \' // watermark text definition, from 0 ~ 4. The conversion is not very large. We recommend using 2 or 3.
\ '// Ogvbox. Canvas. Font. Bold = True \' // whether the watermark text is in Bold, True = Bold, False = normal.
\ 'Ogvbox. Canvas. Print 10, 10, ImageMode \ '// start coordinate (pixel) of the watermark text ).
Ogvbox. Canvas. Pen. Color = & H000000 \ '// adds the border Color of the image after the watermark.
Ogvbox. Canvas. Pen. Width = 1 \ '// increase the Border Width of the image after the watermark.
Ogvbox. Canvas. Brush. Solid = False \ '// specifies whether the color is filled in the border. 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. Here I Am Going To ogvbox. width-186, ogvbox. height-52 indicates that the image is in the lower right corner. Because the image width is 186 and the height is 52, you can adjust it based on your image. 0.5 is transparency. Here I am translucent. 1 indicates opacity. You can try the effect of 0.7 or 0.8.
Ogvbox. Canvas. Bar 0, 0, ogvbox. Width, ogvbox. Height \ '// watermark available range. Here, the upper left corner to the lower right corner, that is, the entire image can be appended to any point.
Ogvbox. Save Server. MapPath (imagename) \ '// generate the image file after adding the 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) \ '// generates a preview image of the added watermark.
End If
Set Logobox = Nothing
\ '// ------Pollener.com AspJpeg component preview and watermark generation ------ end ------