Image to byte[]

What is the best way to convert an object of type Image to byte[]. I would prefer not to write to disk.
Thanks,
Eric

what do you want in the byte[]?
The pixel data, or the object itself?
Pixel data, use PixelGrabber,
Object itself, use ObjectOutputStream, with an underlying ByteArrayOutputStream.

Similar Messages

  • Problem with getting resized image's bytes

    I've got a problem with getting correct bytes of a newly resized image. The flow is that I retrive an image from the filesystem. Due to the fact that it is large I resize it to a 50x50px thumbnail. I can display this thumbnail in #benchmark1 (see code below). Unfortunately something's wrong with my imageToBytes funtion which returns reasonably small size of image but is totally useless - I can't make an image of it anymore so at #benchmark2 the application either crashes or keeps freezing. I saved this byte array on my disk and tried to preview under Windows how does it look but I got a message "Preview unavailabe". I did some digging in the Internet and I supposed that it's because I don't use any jpg or png encoders to save the file. Actually I think that it's not the case, as the bytes returned from method imageToBytes look weird - I cannot even make a new image of them and display it without any saving in memory.
                                  byte[] bytes = FileHandler.readFile (
                                          FileHandler.PHOTOS_PATH, fileName);
                                  Image img2 = Image.createImage (bytes, 0, bytes.length);
                                  img2 = ImageHandler.getInstance ().resize (img2);
                                                    //#benchmark1
                                  bytes = ImageUtils.imageToBytes (img2);
                                  img2 = Image.createImage (bytes, 0, bytes.length);
                                                    //#benchmark2my imageToBytes function is as follows:
         public static byte[] imageToBytes (Image img)
              int[] imgRgbData = new int[img.getWidth () * img.getHeight ()];
              byte[] imageData = null;
              try
                   img.getRGB (imgRgbData, 0, img.getWidth (), 0, 0, img.getWidth (),
                           img.getHeight ());
              catch (Exception e)
              ByteArrayOutputStream baos = new ByteArrayOutputStream ();
              DataOutputStream dos = new DataOutputStream (baos);
              try
                   for (int i = 0; i < imgRgbData.length; i++)
                        dos.writeInt (imgRgbData);
                   imageData = baos.toByteArray ();
                   baos.close ();
                   dos.close ();
              catch (Exception e)
              return imageData;
    I've run totally out of any idea what's wrong, please help!
    Edited by: crawlie on Jul 17, 2010 6:21 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hey Crawlie,
    Please note that simply writing int values into ByteArrayOutputStream will not suffice. Please have a look at the following conversion from int pixel value into byte[4]:
    public static final byte[] intToByteArray(int value) {
            return new byte[] {
                    (byte)(value >>> 24),
                    (byte)(value >>> 16),
                    (byte)(value >>> 8),
                    (byte)value
    }Good Luck!
    Daniel

  • Create image from byte[]array on server side

    Hello everyone..
    I'm developing an application which will take snapshots from a mobile device, and send it to my pc via bluetooth. I have my own midlet which uses the phone camera to take the snapshot, i want to transfer that snapshot to my pc.
    The snapshot is taken is stored in an array byte.
    The image can be created on the phone itself with no problem using : image.createImage(byte[])
    my problem is that when i send the array byte via bluetooth, and receive it on the server, i cannot create the image using the :image.createImage() code
    The connection is good since i have tested by writing the content of the array in a text file.
    Piece of midlet code:
                try{
                     stream = (StreamConnection)Connector.open(url);
                     OutputStream ggt = stream.openOutputStream();
                     ggt.write(str);
                     ggt.close();
                }catch(Exception e){
                     err1  = e.getMessage();
                }where str is my array byte containing the snapshot
    And on my server side:
    Thread th = new Thread(){
                   public void run(){
                        try{
                             while(true){
                                  byte[] b = new byte[in.read()];
                                  int x=0;
                                  System.out.println("reading");
                                  r = in.read(b,0,b.length);
                                  if (r!=0){
                                       System.out.println(r);     
                                       img = Image.createImage(b, 0, r);
                                                            //other codes
                                       i get this error message:
    Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: javax.microedition.lcdui.ImmutableImage.decodeImage([BII)V
         at javax.microedition.lcdui.ImmutableImage.decodeImage(Native Method)
         at javax.microedition.lcdui.ImmutableImage.<init>(Image.java:906)
         at javax.microedition.lcdui.Image.createImage(Image.java:367)
         at picserv2$1.run(picserv2.java:70)
    Please anyone can help me here? is this the way to create the image on the server side? thx a lot

    here is exactly how i did it :
    while(true){
                                  byte[] b = new byte[in.read()];
                                  System.out.println("reading");
                                  r = in.read(b, 0, b.length);
                                  if (r!=0){
                                       Toolkit toolkit = Toolkit.getDefaultToolkit();
                                       Image img = toolkit.createImage(b, 0, b.length);
                                       JLabel label = new JLabel(new ImageIcon(img) );
                                       BufferedImage bImage = new BufferedImage(img.getWidth(label),img.getHeight(label),BufferedImage.TYPE_INT_RGB);
                                       bImage.createGraphics().drawImage(img, 0,0,null);
                                       File xd = new File("D:/file.jpg");
                                       ImageIO.write(bImage, "jpg", xd);
                                       System.out.println("image sent");
                             }Edited by: jin_a on Mar 22, 2008 9:58 AM

  • Reading an image in byte form

    hii guys
    i m trying to read an image and convert it to byte array and later to do some change in that byte array and later recreate a new image.
    For that i m using FileInputStream and FileOutputStream and its read and write methods
    but now i dont know how to append that byte and recreate that image.
    actually i want to do that , convert the image in byte array form and replacing some bytes of the image by my text msg bytes and recreate a new image.
    how an i do that.
    plz help me.
    its urgent.

    import java.io.*;
    class image
    public static void main(String[] arg) throws IOException
    String msg;
    int len,i;
    FileInputStream fin;
    FileOutputStream fout;
    try
    try
    fin=new FileInputStream("01.jpg");
    catch( Exception e)
    System.out.println("Input image not found");
    return;
    try
    fout=new FileOutputStream("001.jpg");
    catch( Exception e)
    System.out.println("output image cannt be created");
    return;
    catch(Exception e)
    System.out.println("output image cannt be created");
    return;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the secret msg :: ");
    msg=br.readLine();
    byte[] msg1=msg.getBytes();
    len=msg1.length;
    System.out.println(len);
    for(i=0;i<len;i++)
    System.out.println(msg1);
    try
    do
    byte by=(byte)fin.read();
    //System.out.print(" "+by);
    if(fin.available()>0)
    fout.write(by);
    }while(fin.available()>0);
    catch(Exception e)
    System.out.println("File error");
    fin.close();
    fout.close();
    till now i only imputed the sg , change it into byte form .
    now i want to replace the msg bytes into the image byte as :- 1 image byte ,1 msg byte, 1 image byte , 1 msg byte........ so on
    until the msg bytes are not finished.

  • Conversion of image into byte array

    I have a problem in converting .png image into bytestream, if anyone can help in this pls do so.....

    Hi,
    To convert an Image to bytes you can use the Image.getRGB() method.
    http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Image.html#getRGB(int[], int, int, int, int, int, int)
    -Henrik

  • Images, Thumbnails, byte[ ] and BLOB

    Hi guys,
    This is what I have to do:
    User selects image from disk and i'm putting it into DB (IBM DB2 8.0). That's clear. No problem.
    But I need that image as a thumbnail as well (I have to show images as thumbnails for each Item). I have a DB table IMAGE with 2 columns - IMAGE_FULL and IMAGE_THUMBNAIL.
    So I need to scale image(wich I have as byte array, or struts FormFile) and than put it into DB as Thumbnail.
    Or even if I don't have IMAGE_THUMBNAIL column, I have to get image as byte array from IMAGE_FULL column, scale it and show it in the browser.
    So, if I explained correctly and not very complicated way, can anyone give some ideas?
    Thanks in advance
    Gio

    For thumbnails, there's plenty of examples of resizing and saving images in the Java Programming forum, just do a search.
    For the database storage and retrieval... I had found some really good site with database examples, but I can't find it anymore.... but here's some code:
    // store
                   PreparedStatement pstmt = db.getConnection().prepareStatement(
                        "INSERT INTO TeeColor VALUES( ?, ? )" );
                   pstmt.setString(1, "yellow");
                   File fImage = new File("yellow.gif");
                   InputStream isImage = new FileInputStream(fImage);
                   pstmt.setBinaryStream(2, isImage, (int)fImage.length());
                   int res = pstmt.executeUpdate();
    // load
                   Statement stmt = db.getConnection().createStatement();
                   ResultSet rs = stmt.executeQuery(
                        "SELECT TCBlob FROM TeeColor WHERE TColor = 'Yellow'");
                   if(rs.next()) {
                        byte[] bytes = rs.getBytes("TCBlob");
                        JFrame f = new JFrame("test");
                        f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                        f.getContentPane().add(new JLabel(new ImageIcon(bytes)));
                        f.pack();
                        f.show();
                   }

  • Display image from byte array

    Hello Everybody,
    I need to display an image given in a byte array, how can I show this image in a JFrame?
    1. I tryied saving the image in a .jpg file,
         File file1 = new File("Path to my destination image");2. then I use a FileOutputStream to save the image in the path:
            FileOutputStream fos1 = new FileOutputStream(docu);
            fos1.write(ImageInbyteArray);
            fos1.close();3. Once I have the image in a file I'm trying to load it using a JButton, but the JButton doesn't display the image. I think that for some unknown (at least for me ;-) reason the file isn't still available to be used in the ImageIcon, this is my code:
            imgIconDocu = new ImageIcon("Path to my destination image");
            jBtnDocu = new JButton(imgIconDocu);What's wrong here?
    Thanks a lot

    Does the byte array contain a JPEG image? Where did
    you get the contents of the byte array?yes the array contains the JPEG image, I have a database in PostgreSQL, and the images are stored in blob in the database. I have to call a service in the server and in return it gives me the 3 images as byte arrays, that's the reason I only have the byte arrays. so I tryed saving the images as jpeg files in my hard disk to show them, but it appears that they are not available to show them in Swing after saving them. I can only show the images if I close my application and start it again :-(
    I tryed flushing and closing the FileOutputStream after the writting process (fos.write(bytearrayImage);
    fos.flush();
    fos.close();)
    Y also tryed:
    fos.write(bytearrayImage);
    fos.close();
    fos.flush();But it doesn't work either :-(
    What do you recommend me?.
    Thanks a lot,
    Johnny G L

  • Depth data convert to Image Bgr, Byte in a windows store project

    Hi,
    i use EmguCv to process depth data from Kinect v2. Now i want to do it in a windows store 8.1 app. In older project i use these code to convert from writable bitmap:
    BitmapEncoder encoder = new BmpBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(depthBitmap));
    MemoryStream ms = new MemoryStream();
    encoder.Save(ms);
    Bitmap b = new Bitmap(ms);
    Image<Bgr, Byte> openCVImg = new Image<Bgr, Byte>(b);
    I the project i miss the bitmap class, i search the whole day for a solution...
    Thx for any hlp
    René

    The answer with help from Canming Huang (Thx):
    private Image<Bgr, Byte> Array2IImage(byte[] pixelArray)
    GCHandle dataHandle = GCHandle.Alloc(pixelArray, GCHandleType.Pinned);
    try
    using (Image<Bgra, Byte> image = new Image<Bgra, byte>(this.pixelWidth, this.pixelHeight, this.pixelWidth * this.cbytesPerPixel, dataHandle.AddrOfPinnedObject()))
    return image.Convert<Bgr, Byte>();
    finally
    dataHandle.Free();

  • Image to byte array

    hello,
    how can i get an image in jar file as a byte[] or can i convert an image to byte[]?
    thx...

    To read a bytes from a jar file, use a JarInputStream. If you're just trying to read bytes from a jar, it doesn't make any difference whether it's an image or not.
    To get the bytes from an Image, you need to put more information in your question - are you talking about an image file, like a JPEG or TIFF? What do you want to do with it? Or are you talking about an Image object in Java? If so, which specific concrete subclass, and what do you want to do with it?

  • Get Image's bytes

    Hi people,
    I'm trying to get the bytes from an image. I know the complete path to that image, and I know the image's name also, so I pass the image's whole name as a String to a method wich will read the bytes. When I try to read the image's bytes I get the following meassures: width = -1, height = 0.
    This is the code I use:
      int err = imageReturn(path + "/" + img);
      byte[] b2bytes = b2.toByteArray();
    public int imageReturn(String imagePath){
        //path is c:\javi\image.jpg
        try{
            int w,h;
            Image img = null;
            img = Toolkit.getDefaultToolkit().getImage(imagePath);
            w = img.getWidth(null);
            h = img.getHeight(null);
    System.out.println("image size: " + w + "x" + h); //--> print's -1x0!!!
            BufferedImage finalImage = new BufferedImage(w, h, 
                                                BufferedImage.TYPE_INT_RGB);
            finalImage.createGraphics().drawImage(img, 0, 0, null);
            b2 = new ByteArrayOutputStream(); //global
            JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(b2);
            JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam
                                                               (finalImage);
            param.setQuality(1.0f, false);
            encoder.setJPEGEncodeParam(param);
            encoder.encode(finalImage);
            b2.close();
            return(0);
        }catch(Exception e){
            System.out.println(e.toString());
            return(-1);
    }//imageReturnAs you see, the goal is to get a byte[] with the image information. I don't know if there's any other way (simpler one) to solve it. Any help will be appreciated.
    Thanks all,
    Javi

    The problem really is withe the Image class, which was never intended for this sort of thing. If you use the ImageIO classes, you can get BufferedImages direct from jpg files, and then you have access to the underlying buffers:
    import java.io.*;
    import javax.imageio.*;
    import java.awt.image.*;
    public class FileOperations
        public static BufferedImage readImageFromFile(File file) throws IOException
            return ImageIO.read(file);
        public static void writeImageToFile(File file,BufferedImage bufferedImage) throws IOException
            ImageIO.write(bufferedImage,"JPG",file);
    }

  • To display an image in byte format in JSP

    hai gurus,
    I am using JSPDynpage.  My response from the websevice is retrieving image in byte format.
    so I thought to display like this in JSP
    String contentType = "image/jpeg";
                   res.setContentType(contentType);
                   //ServletOutputStream out = request.getServletResponse(true).getOutputStream();
                   res.setContentLength(data.length);
                   ServletOutputStream ostream = res.getOutputStream();
                   ostream.write(data);
                   ostream.flush();
    But it doesn't work
    It says that request object is predefined in the doContent.
    above code works fine the the abstractportalcomponent.
    let me know about this
    thanks
    venkata

    Hi, mmaybe you have more luck if you post it in the EP Content Developer or Java deloper forums.
    regards
    Marcel

  • Converting image into byte array

    Hi all,
    How to convert an integer array image into byte array ?
    here i have a image like this :
    private static int pixelArray[] = {
    0xff000000, 0xff000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
    0xff000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
    From this one i create image like this one :
    Image image = Image.createRGBImage(pixelArray, width, height, true);
    Now i want to convert that pixelArray into byte array ? how to do this
    additionally i want to send this byte array to servlet .
    thanks in advance.

    Hi,
    If you want to convert your int array to a byte array you should
    split each integer into 4 bytes to avoid losing information. You can
    rebuild your integer array later if you need to. I think this code
    will work (i havent tested it):
    byte[] pixel= new byte[pixelArray.length<< 2];
    for (int i= pixelArray.length- 1; i>= 0; i--) {
      int aux= i<< 2;  // i* 4 = i<< 2
      pixel[aux]=    (byte) (pixelArray>> 32);
    pixel[aux+ 1]= (byte) (pixelArray[i]>>> 16);
    pixel[aux+ 2]= (byte) (pixelArray[i]>>> 8);
    pixel[aux+ 3]= (byte) pixelArray[i];
    Greets.

  • How to change the image into byte and byte array into image

    now i am developing one project. i want change the image into byte array and then byte array into image.

    FileInputStream is = new FileInputStream(file);
    byte[] result = IOUtils.toByteArray(is);
    with apache common IO lib

  • MIDP 1.0: Image to byte[] or serializing...

    I would like to extract pixels from a MIDP 1.0 "Image" object through any means possible. I am currently under the impression that "Image.toString()" would just do something lame, like giving me a string like "Image@1234" that identifies the class and the instance -- which could in principle be used for mere instance comparison. Anyhow, if I could serialize an Image object to a file, and then read back the file in to a byte array, then I would be delighted. I want to stress that I don't care how convoluted the approach may be, as long as it is in plain-vanilla J2ME Java code for MIDP 1.0 and is capable of working on an actual device (as opposed to an emulator). Can I cast the Image to Object, and then somehow convert to byte[]? I don't care if I have to get down and dirty, hacking the platform-specific bytes of the full Object manifestation of the Image. Anyhow, I want to make it clear that any hard core hack, doing all kinds of things that would break on different VMs, etc, is totally fine. Messy is fine. I just want access to the binary data of the entire Image object, or, even better (but only icing on the proverbial cake), access to pixel data. If I can get the byte[] representation of Image, then I can hack the rest myself.

    My goal was do a capture of the way things actually rendered on a device, kind of like a "screen capture", only a little more indirect (since I don't think there is a way to get access to the pixels of the LCD). What I have to do is render to an off-screen Image object and then retrieve pixel data from it using the platform-dependent getPixels() supplied by Motorola. You're going to think I'm crazy, but I send this image data to a web server via POSTs, which get collected and stored as a single file on my web server. Voila! A screen capture of how things actually render to an Image object on an actual device.
    Everything works, except...
    I can't get the Motorola "getPixels()" method to work in their emulator, so I'm worried
    that it won't work on my Motorola T720 (something I haven't actually tried, though).
    I get a "Uncaught Exception: java/lang/Error" message from the T720 emulator
    when I run one of the Motorola demos (built using their scripts) when I add the
    following code to the Canvas paint() method:
    if (0 == iDidThis) {  iDidThis = 1;
    try
    {  javax.microedition.lcdui.Image   temp = Image.createImage( 120, 160 );
    int [] rgbData = new int [120*160];
    com.motorola.game.ImageUtil.getPixels ( temp, 0, 0, 1, 1, rgbData );
    System.out.println("Captured Data");
    catch( java.lang.ArrayIndexOutOfBoundsException e )
    {  e.printStackTrace();   } }
    This code runs only once, when the paint() method of the Canvas object is called for
    the first time. Okay, I get the error message, but the "Bounce" demo (to which I added
    the code block above) goes on to run just fine. (NOTE: The message "Captured Data"
    is NOT printed in this scenario.)
    I don't understand why the public static "com.motorola.game.ImageUtil.getPixels()"
    method causes the "java/lang/Error" exception. (By the way, if I comment out the
    call to this method, the code totally works without error, and I see the printed
    statement "Captured Data" in the command window associated with the emulator.)
    If my getPixels() call resulted in bad array access, then I would get the
    java.lang.ArrayIndexOutOfBoundsException exception. But apparently this is
    not what is going on.
    I am really rusty with J2ME, so I don't even know the meaning of "java/lang/Error".
    I assume it is different from a "class not found" exception, but I suspect that my
    problem has to do with a fault in the emulator trying to execute the code for the
    "com.motorola.game.ImageUtil.getPixels()" method.
    My Motorola emulator (v7.5) is from around December, 2002, so it may be really old, and
    maybe this was a known issue at that time that has since been resolved. I'm just never
    tried to use platform-specific J2ME APIs before, so I don't know if what I am observing
    is my fault, or is an emulator issue.
    I'd be grateful for any ideas about what might be going wrong and for ideas about
    possible solutions.

  • Thumbnail images, mysql, byte[ ]  - need some help

    I'm using the tech tip found on sun's site for "Creating Image Thumbnails" at http://java.sun.com/developer/TechTips/1999/tt1021.html#tip1
    I've looked over the code, and now I'm trying to mesh some of the code from that example with the code for my servlet program.
    My servlet takes a jpeg image submitted from an html form on a web page (all of which I'm testing on my localhost Tomcat server) and uploads it into my mysql database into a column of type BLOB. I do not upload a reference to a FILE, rather, I upload the BYTES that make up that image.
    I wanted to make the images into a thumbnail size PRIOR to uploading them into the db.
    My code snippet for my servlet that just uploads the file without modifying its size is:
    boolean isPart = FileUpload.isMultipartContent(req);
         if(isPart)
    DiskFileUpload upload = new DiskFileUpload(); // upload a file from the local disk.
    List items = upload.parseRequest(req); // Create a list of all uploaded files.
         Iterator it = items.iterator(); // Create an iterator to iterate through the list.
              while(it.hasNext())
         FileItem item = (FileItem)it.next();
         File f = new File(item1.getName()); // Create a FileItem object to access the file.
    byte[] bytes = new byte[(int)f.length()];
         FileInputStream fs = new FileInputStream(f);
         BufferedInputStream bis = new BufferedInputStream(fs);
         bis.read(bytes);
    PreparedStatement stmt = conn.prepareStatement("UPDATE car SET Image1 = ? where Account=1");
         stmt.setBytes(1, bytes);
         int i = stmt1.executeUpdate();
    Here is the code from the Tech Tip:
    import java.awt.Image;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.FileOutputStream;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    class Thumbnail {
    public static void main(String[] args) {
    createThumbnail(args[0], args[
    1], Integer.parseInt(args[2]));
    * Reads an image in a file and creates
    * a thumbnail in another file.
    * @param orig The name of image file.
    * @param thumb The name of thumbnail file.
    * Will be created if necessary.
    * @param maxDim The width and height of
    * the thumbnail must
    * be maxDim pixels or less.
    public static void createThumbnail(
    String orig, String thumb, int maxDim) {
    try {
    // Get the image from a file.
    Image inImage = new ImageIcon(
    orig).getImage();
    // Determine the scale.
         double scale = (double)maxDim/(
         double)inImage.getHeight(null);
    if (inImage.getWidth(
    null) > inImage.getHeight(null)) {
    scale = (double)maxDim/(
    double)inImage.getWidth(null);
    // Determine size of new image.
    //One of them
    // should equal maxDim.
    int scaledW = (int)(
    scale*inImage.getWidth(null));
    int scaledH = (int)(
    scale*inImage.getHeight(null));
    // Create an image buffer in
    //which to paint on.
    BufferedImage outImage =
    new BufferedImage(scaledW, scaledH,
    BufferedImage.TYPE_INT_RGB);
    // Set the scale.
    AffineTransform tx =
    new AffineTransform();
    // If the image is smaller than
    //the desired image size,
    // don't bother scaling.
    if (scale < 1.0d) {
    tx.scale(scale, scale);
    // Paint image.
    Graphics2D g2d =
    outImage.createGraphics();
    g2d.drawImage(inImage, tx, null);
    g2d.dispose();
    // JPEG-encode the image
    //and write to file.
    OutputStream os =
    new FileOutputStream(thumb);
    JPEGImageEncoder encoder =
    JPEGCodec.createJPEGEncoder(os);
    encoder.encode(outImage);
    os.close();
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(0);
    I will be changing the following line right off the bat:
    1 ) changing the argument passed to:
    Image inImage = new ImageIcon(bytes);
    I'm passing it my array
    bytes
    which I created in my upload servlet, it's holding the image.
    I don't want to write the newly thumbnail sized image to a JPEG stream as it is coded at the end of the program from Sun.
    Instead, I want to read the newly sized image into a
    byte[ ]
    array and then continue with my servlet program, and place the image into the db. I have a column of type BLOB waiting for it:)
    Does anyone know how to do this?

    Yes I have done this, do not have the code to hand, its in a real mess anyway, one of those things I got working and never got round to using...
    I based my code on some found here
    http://forum.java.sun.com/thread.jspa?forumID=20&threadID=505366
    Note, the above link shows how to add a watermark to an image as well.
    It does not show how to resize it (I was originally after the watermark bit) But I got it to resize by messing with the variables used to draw out the image.
    If you search the forums you will find this a common problem, but I was very impressed with the code posted in the above link, one of my favorites!

Maybe you are looking for