I'm resizing a image and I need to return a InputStream object
public InputStream resize(InputStream input, int maxSize){
BufferedImage image = ImageIO.read(input);
double scale = (double) image.getWidth()/maxSize;
Image scaledImage = image.getScaledInstance( (int) (image.getWidth() * scale), (int) (image.getHeight() * scale), Image.SCALE_SMOOTH);
InputStream ret = (InputStream) scaledImage;//this is wrong cast
retrun ret;
}
how can I convert a Image to a InputStream?