imageio « Media File « Java I/O Q&A

1. How to use ImageIO to save multiple BufferedImages to a file

I tried both of the following options: <1>

BufferedImage Buffered_Image;
MemoryCacheImageOutputStream MemoryCache_OutputStream=new MemoryCacheImageOutputStream(new FileOutputStream("C:/",false));

while (notFinished)  // Main recording loop.
   Buffered_Image=robot.createScreenCapture();         // Capture Screen ...

2. Why the jpg file I converted from a gif file isn't crisp and clear?

I use the following code to convert a gif file to a jpg file, it works but the result jpg file isn't the same quality as the original gif file, why ...

3. Java/ImageIO Getting Image Dimension without reading the entire file?

is there a way to get the dimension of an image without reading the entire file ?

System.out.println(img.getWidth()+" "+img.getHeight());

4. Can't read and write a TIFF image file using Java ImageIO standard library

I don't know what to do with TIFF images, but I can't read or write any of them using straight Java standard ImageIO library. Any thoughts? Thanks.

5. Java/ImageIO Validate format before reading the entire file?

I'm developing a Web application that will let users upload images. My concern is the file´s size, specially if they are invalid formats. I'm wondering if there´s a way in java (or ...

6. problem using ImageIO.write jpg file

i using below code to write a jpg file:

String url="!!449400070.jpg";
String to="D:/temp/result.jpg";
ImageIO.write( URL(url)),"jpg", new File(to));
but I get the result.jpg is a pink background image: alt text how to fix this problem? can ...

7. Image IO Problem

for (int i = 0; i < width; i++) {
      for (int j = 0; j < height; j++) {

8. stitch images together in java

I'm trying to stitch some images together using java. I have a bunch of images I'd like to stitch together and they are all the same dimensions so it's really ...

9. Trying to create a file to save an image Java

I get the following exception when trying to create a file on windows 7 using Java. An example of a path is "C:/g-ecx/images-amazon/com/images/G/01/gno/images/orangeBlue/navPackedSprites-US-22.V183711641.png". If I hard code in a path it ...

10. Reading images using; causes java.lang.OutOfMemoryError: Java heap space

I am using a ImageIO API to write a PNG file. This code is called in a loop and causes an OutOfMemory error. Is there anyway the following code can be ...

11. Java ImageIO: can't read input file

I don't know why this isn't working, but the program says it can't read the input file. This is also being run in Ubuntu, by the way: Here is the sample code:

URI ...

12. javax.imageio

13. ImageIO error

Hello I have written an application and used a code example to write a buffered image to an image to a byteArrayOutput stream. The error that I get is a sun.misc.serviceConfigurationError.javax.imageit.spiImageOutputStream. Really I don't understand this error!?!? what is this telling me is the main question. Everything works fine when I run it as an application but when I run it ...

14. Writing to gif file with ImageIO

15. ImageIO exception

c = server.acceptAndOpen(); OutputStream out = c.openOutputStream(); // The connection is established and working Robot robot = new Robot(); BufferedImage image = robot.createScreenCapture(new Rectangle(0,0,50,50)); ImageIO.write(image,"jpeg",out); //Writes to outputStream //This code is supposed to be in the Client app.. but for now I am //testing it in the server to see if it works BufferedImage image2 =; ImageIO.write(image2,"jpeg", new File("latest.jpeg")); The ...

16. Class ImageIO

17. ImageIO.write returns false

bb turns out to be false in the following code, but a blank image is still created. That behavior confused me enough, but what is getting me now is how to use ImageIO.write to write a tif file to the file system? java.awt.image.BufferedImage image = frame.getImage(false); File outFile = new File( "test4.tif"); boolean bb = ImageIO.write(image, "tif", outFile); System.out.println(outFile.length() + " ...

18. problem with

19. AS400 ImageIO write hangs

20. Exception with

Thank you Nitesh. You were correct that it is probably a problem with creating and not recovering memory. I finally determined that the problem was happening when I closed the dialog with the x button on the right upper corner; If i close the dialog using dispose() I have no problems. Why dispose() is not executed when I closed the dialog ...

21. Using ImageIO to read a bmp file

22. ImageIO trouble

Hi again, I have some mysterious trouble when trying to read images files. public static BufferedImage readImage(String imagePath) throws IOException { BufferedImage buffImg = null; File f = new File(imagePath); System.out.println(f.getPath()); System.out.println(f.exists()); try { buffImg =; } catch (Exception e) { System.out.println("Exception"); } finally { if (buffImg == null) System.out.println("Image is null"); else { System.out.println("image is not null"); } } ...

23. ImageIO and .exists can't find file.

public static Bitmap font = loadBitmap("/img/font.png", 1); public static Bitmap SideLine = loadBitmap("/img/SL.png",1); public static Bitmap UpperLine = loadBitmap("/img/UL.png", 1); public static Bitmap loadBitmap(String fileName, int o1) { try { boolean exists = (new File("filename")).exists(); if (exists) { if (Settings.DebugLVL >= 3) System.out.println("PDB.class - File " + fileName + " found."); BufferedImage img =; int w = img.getWidth(); int h ...

24. Why doesn't imageIO.Write save the file to the intended filename?

Correctly, the code does produce 209 image files. But they are not numbered 0 to 208 (by the way I used System.err.Print to verify that the correctly numbered fiilenames are being fed into ImageIO.Write). Oddly enough, the first 10 files are numbered 10 to 19. Then the numbers jump up to 110, proceed to 199, then jump up to 1100 and ...

25. I can't seem to read any file with ImageIO

I am a rank beginner with Java, so I use a lot of code snippets I find online, and look every move up in the API docs. However, I am just trying to load a simple gif of png to use as a decoration on a panel, and it never succeeds. I successfully create a File from the file, a little ...

28. ImageIO File size

29. Did ImageIO reduce the size of my picture file?

Hi, I have used the code below to attempt to write a picture file into the DB BufferedImage originalImage = File("c: test.jpg")); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(originalImage, "jpg", baos); baos.flush(); byte[] fileBytes = baos.toByteArray(); // save fileBytes into DB where the column accept BLOB type value. I have used the code below to attempt to read from the DB ...