Custom JSP taglib. Tag convertImage lets you proceed images. You can scale them to the given width and height, as well as rotate them. Taglib uses free open source library ImageJ for image processing. You have to download the latest ij.jar file right from ImageJ home page and save it in WEB-INF/lib directory. For example:
<%@ taglib uri="taglib.tld" prefix="im" %> <im:convertImage sourceFile="c:/pictures/picture.jpg" targetFile="c:/pictures/picture125x125.jpg" width="125" height="125"/> when you need to convert many files in your server side code you can combine convertImage tags into some package
(in order to save memory):
<%@ taglib uri="taglib.tld" prefix="im" %> <im:batchProcessing> <im:convertImage sourceFile="c:/pictures/picture1.jpg" targetFile="c:/pictures/picture1-125x125.jpg" width="125" height="125"/> <im:convertImage sourceFile="c:/pictures/picture2.jpg" targetFile="c:/pictures/picture2-125x125.jpg" width="125" height="125"/> ... </im:batchProcessing> Tag cropImage lets you extract a part of the given image. You can provide either coordinates for the top left corner (x,y) and (width,heght) or (width,height) only. In this case the extracted image will be centered (top left corner's coordinates will be calculated automatically). Why do we include this taglib into our suite? As we see, that it is a very common task when developers need to convert uploaded images or scale them depends on user's agent. We hope this taglib helps them with such tasks. Tags are: convertImage Converts image: scales it according to the given width and height, rotates it and saves in the new file or streams to the browser. Parameters are: 1) sourceFile Optional parameter. Describes a path to source file (tiff, jpg, gif, png)
cropImage Crops image: extracts part of it according to the given width and height, rotates it and saves in the new file or streams to the browser. Parameters are: 1) sourceFile Optional parameter. Describes a path to source file (tiff, jpg, gif, png)
getSize Retrieves width and height for the image. Parameters are: 1) sourceFile Optional parameter. Describes a path to source file (jpg, gif, png)
batchProcessing Body tag allows you to execute several convertImage tags in the one package. Parameters are: none for downloading: Library: imagetag.jar Description: taglib.tld See also Coldtags suite - the largest collection of custom JSP tags.
|
Also in Coldtags:
|