in my web application i neet to change the size of some pictures and i use the below method for resizing pictures. when i run the application under windows there is no problem but when i run it under my vps (linux) the mehtod does not work (the method returns null).
i would like to know if it is the problem with linux and is there any solution for it.
public static byte[] getImage(byte[] imageBytes, String format, int
previewWidth, int previewHeight) {
ByteArrayOutputStream result = new ByteArrayOutputStream();
int newWidth = previewWidth;
int newHeight = previewHeight;
try{
ByteArrayInputStream byteInput = new ByteArrayInputStream(imageBytes);
BufferedImage image = ImageIO.read(byteInput);
if (image.getWidth() <= previewWidth && image.getHeight() <=
previewHeight) // picture is so small that it fits as preview itself
return imageBytes;
BufferedImage newImage = new BufferedImage(newWidth, newHeight,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = (Graphics2D) newImage.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g2d.drawImage(image, 0, 0, newWidth, newHeight, 0, 0, image.getWidth(),
image.getHeight(), new JFrame());
g2d.dispose();
ImageIO.write(newImage, format, result);
} catch (Exception ex){}
return result.toByteArray();
}