What I tell you today is the knowledge of ASP to add watermarks to the picture .. My ASP learns very badly ..
ASP to add watermarks to the picture requires components ... Commonly used aspjpeg and the Chinese developed WSIMAGE ... The former is free for 30 days ... The latter is completely free ... Of course we have to use the products of Chinese people. ..hey-hey..
The component can download http://aknife.ys168.com (download version 3.0) at http://aknife.ys168.com
Method of registration components:
Enter "regsvr32 [dll path]" under the command prompt
Adding watermarks to the picture is nothing more than getting the picture size, and then write the watermark ..asp code just plays the role of a control component. Use code to explain everything.
One: Get the picture size (here is represented by pixel values. Friends who learn Photoshop should understand)
| The following is the code fragment: <% set obj = server.createObject ("wsimage.Resize") '' -call component obj.loadSoucepic Server.mAppath ("25.jpg") '' '' "Open the picture, the picture name is 25.jpg obj.getsourceinfo iWidth, IHEIGHT response.write "Picture width:" & iwidth & "<br>" "" Get the width of the picture response.write "Picture height:" & ipight & "<br>" "" Get the picture height strerror = obj.errorinfo if Strerror <> "" THEN response.write obj.errorinfo end if obj.free set obj = nothing %> '' --------------------------------------------------------------------------------------------- ----------------- Two: Add text watermark <% set obj = server.createObject ("wsimage.Resize") obj.loadSoucepic Server.mAppath ("25.jpg") '' obj.quality = 75 obj.txtMarkfont = "Chinese color cloud" '' Set watermark text font obj.txtMarkbond = false '' Set the thickness of the watermark text obj.markrotate = 0 '' 'Rotating angle of watermark text obj.txtMarkheigh = 25 '' 'Hydaline text height obj.addtxtMark Server.MAPPATH ("TXTMARK.JPG"), "Take you away from the country", & h00ff00 &, 10, 70 Strerror = obj.errorinfo '' to generate pictures name, text color is watermark in the location of the picture if Strerror <> "" THEN response.write obj.errorinfo end if obj.free set obj = nothing %> '' --------------------------------------------------------------------------------------------- ----------------- Three: Add pictures water marks <% set obj = server.createObject ("wsimage.Resize") obj.loadSoucepic Server.mAppath ("25.jpg") '' obj.loadimgmarkpic server.mappath ("Blend.bmp") '' obj.quality = 75 obj.addimgmark server.mappath ("IMGMARK.JPG"), 315, 220, & hffffffff, 70 Strerror = obj.errorinfo '' to generate pictures name, text color is watermark in the location of the picture if Strerror <> "" THEN response.write obj.errorinfo end if obj.free set obj = nothing %> '' --------------------------------------------------------------------------------------------- ----------------- In fact, adding watermarks to the picture is as simple as. Then I said that the other two main usage of the wsimage.dll component. Including:: including: Cut the picture and generate the thumbnail of the picture. I still have to get used to it, use code to add injects to explain: Cut the picture: <% set obj = server.createObject ("wsimage.Resize") obj.loadSoucepic Server.mappath ("25.jpg") obj.quality = 75 Obj.cropImage Server.MAPPATH ("" 25_crop.jpg "), 100,10,200,200 '' 'define cutting and generating picture names strerror = obj.errorinfo if Strerror <> "" THEN response.write obj.errorinfo end if obj.free set obj = nothing %> Detailed note: The cutimage method of WSImage is used to reduce the picture. When the definition of generating pictures is defined, 100,10 is the tailoring point in the upper left corner, that is, the left is 100 pixels on the left side of the picture, and the top 10 pixels at the top. Broadband and height. '' --------------------------------------------------------------------------------------------- ----------------- Generate pictures of pictures: <% set obj = server.createObject ("wsimage.Resize") obj.loadSoucepic Server.mAppath ("25.jpg") '' obj.quality = 75 obj.outputspic server.mappath ("" 25_s.jpg "), 0.5,0.5,3 '' '' The name of the definition diagram is the size of the size strerror = obj.errorinfo if Strerror <> "" THEN response.write obj.errorinfo end if obj.free set obj = nothing %> |
There are four export methods:
(1) Obj.outputspic server.mappath ("25_s.jpg"), 200,150,0
200 is the output width, 150 is the output high. This output form is forced output width and height, which may cause image deformation.
(2) Obj.outputapic Server.mappath ("25_S.jpg"), 200,0,1
With 200 output width, the output high will be scaled with column.