Jonas
remigijus wrote:
It looks nice to have ability to make thumbnails without use of any external libraty. I like it. I found your ww action GenerateThumbnail, but could not find a class net.killingar.GenerateThumbnails which as expect does all the work. Can you please point, where it is.
----- Original Message ----- From: "boxed" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, January 11, 2004 8:11 AM Subject: Re: [OS-webwork] Any sugesstions fro image manipulation
remigijus wrote:
This question is not about ww, but I hope some suggestions will be
given.
I need some library for image processing on the server side. I want to make thumbnail image file from an image file uploaded by user.
I have this as part of my SKForum app, which is open source (public domain). Here's an example of the thumbnail gallery: http://archive.killingar.net/art/vs/ViewThumbnails.action
The source is available from my subversion server: http://subversion.killingar.net:8080/svn/forum/
Some source files you might find useful:
http://subversion.killingar.net:8080/svn/forum/WEB-INF/classes/net/killingar /actions/GenerateThumbnails.java
http://subversion.killingar.net:8080/svn/forum/WEB-INF/classes/net/killingar /actions/ListDirectory.java
http://subversion.killingar.net:8080/svn/forum/_common/list-dir/view_thumbna ils.jsp
(sorry about this one, the content type is wrong on the server, IE gets confused by that)
Generating thumbnails is a simple click of a link (a WW1.4 action), etc. I don't use JIMI since the standard API has a support for image file formats that I find totally sufficient.
Anders Hovm�ller
------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
/* */ package frolf.util;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import frolf.exception.FrolfException;
/**
* Util
* @author joer
* Created 17 Oct, 2003
*/
public class Image {
private static final Log log = LogFactory.getLog(Image.class);
public static byte[] thumbnail(byte[] org, int w, int h) throws FrolfException {
byte[] thumb = null;
ByteArrayInputStream instream = new ByteArrayInputStream(org);
ByteArrayOutputStream outstream;
BufferedImage image;
try {
int newH = h;
int newW = w;
image = ImageIO.read(instream);
float props = (float) image.getWidth() / (float) image.getHeight();
if (w <= 0) {
newW = (int) (props * (float) h);
} else if (h <= 0) {
newH = (int) ((float) w / props);
} else {
return null;
}
java.awt.Image thumbimg = image.getScaledInstance(newW, newH, BufferedImage.SCALE_SMOOTH);
BufferedImage img = new BufferedImage(newW, newH, BufferedImage.TYPE_INT_RGB);
img.createGraphics().drawImage(thumbimg, null, null);
outstream = new ByteArrayOutputStream();
if (!ImageIO.write(img, "jpg", outstream)) {
throw new FrolfException("Unable to write thumbnail to output stream");
}
thumb = outstream.toByteArray();
// No effect...
instream.close();
outstream.close();
}
catch (IOException ex) {
throw new FrolfException("IOException when thumbnailing", ex);
}
catch (FrolfException ex) {
throw ex;
}
return thumb;
}
}
