[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scaling a jpeg on a web server
Hello,
Does anyone have any experience resizing or manipulating jpeg images
on a web server? I'm trying to scale an uploaded image but I get the
following error in production:
java.lang.InternalError: Can't connect to X11 window server using
':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at
sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:126)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnviron
ment.java:62)
at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:70)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:130)
at java.awt.Toolkit$2.run(Toolkit.java:712)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:703)
at java.awt.Image.getScaledInstance(Image.java:129)
at
net.brainMaze.common.image.Imaging.jpegResize(Imaging.java:87)
this is the code that works locally(my computer) but not on a server:
BufferedImage bimg = null;
try{
Image sImage = bImage.getScaledInstance(newWidth, newHeight,
Image.SCALE_SMOOTH);
bimg = null;
if(sImage instanceof BufferedImage){
bimg = (BufferedImage)sImage;
}
else{
int[] pixels = new int[newWidth * newHeight];
PixelGrabber pg = new PixelGrabber(sImage, 0, 0,
newWidth,
newHeight, pixels, 0, newWidth);
try{
pg.grabPixels();
}
catch(Exception ie){
log.error("", ie);
}
bimg = new BufferedImage(newWidth, newHeight,
BufferedImage.TYPE_INT_RGB);
bimg.setRGB(0, 0, newWidth, newHeight, pixels, 0,
newWidth);
}
}
it would appear that there is no computer monitor or display to
initialize so the default toolkit fails. Is there a way to scale an
image without using the Toolkit? I can't find any libraries that don't
use the it.
Any suggestions would be greatly appreciated.
Michael