AspJpeg is a powerful image processing component based on the Microsoft IIS environment, and there are not many Chinese articles on the network for detailed and in-depth introduction, even if there is a general only involves picture thumbnails and image watermark, which is closely related to the English version.
Download the latest version of AspJpeg, more examples and detailed online object reference manual:
http://www.aspjpeg.com/
1, what is AspJpeg?
AspJpeg is a powerful image processing component based on the Microsoft IIS environment, and there are not many Chinese articles on the network for detailed and in-depth introduction, even if there is a general only involves picture thumbnails and image watermark, which is closely related to the English version.
AspJpeg can use very little code in your asp/asp. NET applications to create high-quality thumbnail images, supported image formats are: JPEG, GIF, BMP, TIFF, PNG
AspJpeg can do:
Picture Merge
Picture Cutting
Image effects
Database support
Verification Code Technology
Generate thumbnail pictures
To generate a watermark picture
GIF dynamic picture creation, modification
...
2, AspJpeg function Summary
* Support JPEG, GIF, BMP, TIFF and PNG format picture sources
* Pictures can come from disk, memory, or recordset (database)
* The adjusted picture can be saved to disk, memory, or HTTP stream
* Support three kinds of change size algorithm: Nearest neighbor, Bilinear, bicubic
* Can add pictures or text on top of the picture, support TrueType and type 1 fonts
* Word wrap, text alignment: Left, right, center, both ends, picture rotation
* Support drawing in painting
* Cut, flip, rotate, sharpen, grayscale adjustment
* Can adjust the compression ratio to get the best output effect and size
* Extract EXIF and IPTC meta data from JPEG images
* Save meta data when changing pictures
* IPTC Meta data additions and edits
* CMYK to RGB conversion
* Tan Filter (aging photo style)
* Read/write access to the image from an image
* PNG Alpha Channel support
* GIF transparent support
* Adjustment of brightness, contrast and saturation
* GIF output, transparency and animation save
* JPEG to GIF format conversion
3, AspJpeg system requirements
Windows Nt/2000/xp/2003/vista, and
IIS 4.0+ and Asp/asp.net, or
Visual Basic 5.0+, or
Visual C + + 5.0+, or
Any development environment supporting COM.
4, AspJpeg installation
New Installation:
* Download the 30-Day fully functional evaluation version to the official web site, divided into 32-bit version (Aspjpeg.exe, up to the current version of 2.0, file size: 1.75M, Last updated: 2008.01.28) and 64-bit version (Aspjpeg64.exe, up to the current version of 2.0, File size: 1.35M, Last updated: 2008.02.25, no documents included)
* Perform download of aspjpeg.exe or Aspjpeg64.exe
* When prompted to enter a serial number, enter a valid serial number, the representative will use the 30-day evaluation version, you can change the registration table RegKey for registration
* If the installation location disk format is NTFS, there may be access rights issues, you need to manually set the anonymous user has read Aspjpeg.exe permissions.
Update Installation:
If you have previously installed a different version of the AspJpeg component, you will need to uninstall the original component before you install the new version.
First stop iis:net stop iisadmin/y
Uninstalling Legacy Components: regsvr32/u path/aspjpeg.dl (Path is the installation route)
Restart Iis:net Start w3svc
Then do a new installation or copy the AspJpeg.dll file in the bin directory to the installation directory for manual installation:
Program Code Program code
regsvr32 path/aspjpeg.dll (path for installation)
If you do not enter a serial number or update installation during normal setup, you will need to register the following entries in the registry, for convenience you can save the following code directly as a Key.reg document and import the registry:
Program Code Program code
Windows Registry Editor Version 5.00
[Hkey_local_machine\software\persits Software\aspjpeg\regkey]
@= "17361-38566-42221"
In addition, you can set the registration code by the RegKey property of the AspJpeg object through the code layer, as follows:
View Plaincopy to Clipboardprint?
1. Set Jpeg = Server.CreateObject ("Persits.jpeg")
2. Jpeg.regkey = "12345-67890-12345"
3...
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.regkey = "12345-67890-12345"
...
. REGKEY Specifies the registry, if this property is not set the AspJpeg component will look for a specified registration code in the system registry.
5. How do I create a aspjpeg instance?
Program Code Program code
Set Jpeg = Server.CreateObject ("Persits.jpeg")
6, how to view the expiration time (whether registration success)?
View Plaincopy to Clipboardprint?
1. Set Jpeg = Server.CreateObject ("Persits.jpeg")
2. Response.Write Jpeg.expires
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Response.Write Jpeg.expires
If this property returns 9/9/9999 it means that a permanent registration code is being used.
Otherwise: installation date plus 1-month period
7. How do I create thumbnail images with aspjpeg components?
View Plaincopy to Clipboardprint?
1. <%
2. Set Jpeg = Server.CreateObject ("persits.jpeg") ' Create AspJpeg object instance
3. Path = Server.MapPath (".. /images/apple.jpg ")" Set Picture path
4. Jpeg.open Path ' Open picture
5. ' Adjust width and height to original 50%
6. Jpeg.width = JPEG.ORIGINALWIDTH/2
7. Jpeg.height = JPEG.ORIGINALHEIGHT/2
8. Jpeg.save Server.MapPath ("apple_small.jpg") ' Save pictures to disk
9. Jpeg.Close:Set Jpeg = Nothing
%>
<%
Set Jpeg = Server.CreateObject ("persits.jpeg") ' Create AspJpeg object instance
Path = Server.MapPath (".. /images/apple.jpg ")" Set Picture path
Jpeg.open Path ' Open picture
' Adjust width and height to original 50%
Jpeg.width = JPEG.ORIGINALWIDTH/2
Jpeg.height = JPEG.ORIGINALHEIGHT/2
Jpeg.save Server.MapPath ("apple_small.jpg") ' Save pictures to disk
Jpeg.Close:Set Jpeg = Nothing
%>
8, how to create a picture watermark with the AspJpeg component?
View Plaincopy to Clipboardprint?
1. <%
2. Set Jpeg = Server.CreateObject ("Persits.jpeg")
3. Jpeg.open Server.MapPath ("2.jpg")
4. ' Start writing text
5. Jpeg.Canvas.Font.Color = &000000 ' red color
6. Jpeg.Canvas.Font.Family = "Courier New" font
7. Jpeg.Canvas.Font.Bold = True ' whether bold
8. Jpeg.Canvas.Print, "Copyright (c) XYZ, Inc."
9. ' Print coordinates x print coordinates y need to print the characters
10. ' The following is a border treatment of the picture
Jpeg.Canvas.Pen.Color = &h000000 ' Black color
Jpeg.Canvas.Pen.Width = 2 ' brush width
Jpeg.Canvas.Brush.Solid = False ' is bold processing
Jpeg.Canvas.Bar 1, 1, jpeg.width, jpeg.height
15. ' Start x coordinate start y coordinate input length input height
Jpeg.save Server.MapPath ("1.jpg") ' Save
%>
<%
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.open Server.MapPath ("2.jpg")
' start writing
JPEG. Canvas.Font.Color = &000000 ' red color
Jpeg.Canvas.Font.Family = ' Courier New ' ' font
Jpeg.Canvas.Font.Bold = true ' Bold
Jpeg.Canvas.Print, "Copyright (c) XYZ, in C. "
Print coordinates x print coordinates y need to print characters
' The following is border processing of a picture
Jpeg.Canvas.Pen.Color = &H000000 ' Black color
Jp eg. Canvas.Pen.Width = 2 ' brush width
Jpeg.Canvas.Brush.Solid = false ' bold processing
Jpeg.Canvas.Bar 1, 1, jpeg.width, Jpeg.height
' start x coordinates start y coordinate input length input height
jpeg.save server.mappath ("1.jpg") &nbs p; ' Save
%>
9, how to use aspjpeg components for picture merging?
AspJpeg 1.3+ enables you to place images on top of all other via the method DrawImage. To must create two instances of the AspJpeg objects and populate both of them with images via calls T o Open (or openbinary). When calling Canvas.drawimage, the 2nd instance of AspJpeg is passed as a argument to-I, along with the X and Y Offsets (in pixels):
With this method, you must create two AspJpeg instance objects
View Plaincopy to Clipboardprint?
1. <%
2. Set JPEG1 = Server.CreateObject ("Persits.jpeg")
3. Set JPEG2 = Server.CreateObject ("Persits.jpeg")
4. Jpeg1.open Server.MapPath ("T.jpg")
5. Jpeg2.open Server.MapPath ("T1.jpg")
6. Jpeg1.Canvas.DrawImage, Jpeg2 ' optional arguments omitted
7. Jpeg1.save Server.MapPath ("Tt.jpg")
8.%>
<%
Set JPEG1 = Server.CreateObject ("Persits.jpeg")
Set JPEG2 = Server.CreateObject ("Persits.jpeg")
Jpeg1.open Server.MapPath ("T.jpg")
Jpeg2.open Server.MapPath ("T1.jpg")
Jpeg1.Canvas.DrawImage, Jpeg2 ' optional arguments omitted
Jpeg1.save Server.MapPath ("Tt.jpg")
%>
10, how to use aspjpeg components for picture cutting?
AspJpeg 1.1+ is also capable of cutting out edges from, or cropping, the resultant thumbnails via the method crop (x0, y0, x1, y1). The size of the cropped image is specified by the coordinates of Upper-left and lower-right corners within the Resulta NT thumbnail, not the original large image.
View Plaincopy to Clipboardprint?
1. <%
2. Set Jpeg = Server.CreateObject ("Persits.jpeg")
3. Jpeg.open Server.MapPath ("T.jpg")
4. jpeg. Crop, JPEG. WIDTH-20, JPEG. Height-10
5. Jpeg.save Server.MapPath ("Tt.jpg")
6. Response.Write ("7.%>
<%
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.open Server.MapPath ("T.jpg")
Jpeg. Crop, JPEG. WIDTH-20, JPEG. Height-10
Jpeg.save Server.MapPath ("Tt.jpg")
Response.Write ("%>
11. How to create the verification code with the AspJpeg component?
The principle of creating a CAPTCHA is similar to creating a watermark.
View Plaincopy to Clipboardprint?
1. <%
2. Function make_randomize (max_len,w_n) ' max_len generation length, w_n:0 may contain letters, 1: Only for numbers
3. Randomize
4. For Intcounter=1 to Max_len
5. Whatnext=int ((1-0+1) *rnd+w_n)
6. If Whatnext=0 Then
7. upper=122
8. lower=97
9. Else
upper=57
lower=48.
. End If
Strnewpass=strnewpass & chr (int (upper-lower+1) *rnd) +lower)
Next
Make_randomize=strnewpass
End Function
17.
18. ' Create a picture of the security code.
Random_num=make_randomize (4,1) ' generates a 4-digit security Code
Session ("Random_num") =random_num ' for the call session, no session of the security code is completely meaningless. Oh.
21st.
Set Jpeg = Server.CreateObject ("persits.jpeg") ' Invoke component
Jpeg.open Server.MapPath ("t.jpg") ' Open the prepared picture
Jpeg.Canvas.Font.Color = &hffffff
Jpeg.Canvas.Font.Family = "Arial Black"
Jpeg.Canvas.Font.Bold = False
Jpeg.Canvas.PrintText 0,-2, Random_num
Jpeg.save Server.MapPath ("tt.jpg") ' Save
%>.
<%
function make_randomize (max_len,w_n) ' max_len generation length, w_n:0 may contain letters, 1: Only for numbers
Randomize
For Intcounter=1 to Max_len
Whatnext=int ((1-0+1) *rnd+w_n)
If Whatnext=0 Then
upper=122
lower=97
Else
upper=57
lower=48
End If
Strnewpass=strnewpass & Chr (int ((upper-lower+1) *rnd) +lower)
Next
Make_randomize=strnewpass
End Function
' Create a picture of the security code.
Random_num=make_randomize (4,1) ' generates a 4-digit security Code
Session ("Random_num") =random_num ' to call session, no session of the security code is completely meaningless. Oh.
Set Jpeg = Server.CreateObject ("persits.jpeg") ' Invoke component
Jpeg.open Server.MapPath ("t.jpg") ' Open the prepared picture
Jpeg.Canvas.Font.Color = &hffffff
Jpeg.Canvas.Font.Family = "Arial Black"
Jpeg.Canvas.Font.Bold = False
Jpeg.Canvas.PrintText 0,-2, Random_num
Jpeg.save Server.MapPath ("tt.jpg") ' Save
%>
12, how to let the AspJpeg component support database?
The picture is stored in the database can only be stored in binary data, here is the AspJpeg binary method, the following two AspJpeg user manual for example, please refer to the AspJpeg user manual:
View Plaincopy to Clipboardprint?
1. ' Open the image from memory
2. Opening Images from Memory
3. <% ' Using ADO, open database with an image blob
4. strconnect = "Driver={microsoft Access DRIVER (*.mdb)};D bq=" & Server.MapPath (".. /db/aspjpeg.mdb ")
5. Set rs = Server.CreateObject ("Adodb.recordset")
6. SQL = "Select Image_blob from images2 where id =" & Request ("id")
7. Rs. Open SQL, StrConnect, 1, 3
8. Set Jpeg = Server.CreateObject ("Persits.jpeg")
9. ' Open image directly from recordset
Jpeg.openbinary rs ("Image_blob"). Value
One. ' Resize
A. jpeg. width = Request ("width")
' Set new height, preserve original aspect ratio
JPEG. Height = jpeg. OriginalHeight * jpeg. Width/jpeg. OriginalWidth
Jpeg.sendbinary
Rs. Close
%>
18.
19. ' Output to memory
<%
21st....
Set rs = Server.CreateObject ("Adodb.recordset")
Rs. Open "Images", StrConnect, 1, 3
Rs. AddNew
RS ("Image_blob"). Value = Jpeg.binary
-Rs. Update
27...
%>
' Open the image from memory
Opening Images from Memory
<% ' Using ADO, open database with an image blob
strconnect = "Driver={microsoft Access DRIVER (*.mdb)};D bq=" & Server.MapPath (".. /db/aspjpeg.mdb ")
Set rs = Server.CreateObject ("Adodb.recordset")
SQL = "Select Image_blob from images2 where id =" & Request ("id")
Rs. Open SQL, StrConnect, 1, 3
Set Jpeg = Server.CreateObject ("Persits.jpeg")
' Open image directly from recordset
Jpeg.openbinary rs ("Image_blob"). Value
' Resize
Jpeg. width = Request ("width")
' Set new height, preserve original aspect ratio
Jpeg. Height = jpeg. OriginalHeight * jpeg. Width/jpeg. OriginalWidth
Jpeg.sendbinary
Rs. Close
%>
' Output to memory
<%
...
Set rs = Server.CreateObject ("Adodb.recordset")
Rs. Open "Images", StrConnect, 1, 3
Rs. AddNew
RS ("Image_blob"). Value = Jpeg.binary
Rs. Update
...
%>
13, AspJpeg components to create GIF animation?
View Plaincopy to Clipboardprint?
1. <%
2. Set Jpeg = Server.CreateObject ("Persits.jpeg")
3. Set Gif = Jpeg.gif ' Obtain GIF management object
4.
5. marketshare = 6 ' initial market share of hypothetical XYZ company
6. ' Create a 5-frame animated GIF
7. For i = 1 to 5
8. Gif.addframe 300, 200, 0, 0
9.
Gif.pencolor = 10
Gif.brushcolor = 10
Gif.drawbar 0, 0, 300, 200
13.
Gif.pencolor = 201
gif.fontfamily = "Courier"
Gif.printtext, "XYZ, Inc Market Share"
Gif.printtext, 2002 + I
18.
' Draw pie chart
Gif.pencolor = 0
Gif.brushcolor = 30
Gif.drawpie, 130, 0, marketshare * 360/100
Gif.brushcolor = 20
Gif.drawpie, 130, Marketshare * 360/100, 360
25.
Num. Gif.pencolor = 210
Gif.printtext, marketshare & "%"
marketshare = marketshare * 2-3 ' market share almost doubles every year!
"Increase delay on" the last frame
If i = 5 then Gif.delay = 3 sec
Next
"Save"
Gif.save Server.MapPath ("Chart.gif")
%>