Questions tagged [javax.imageio]

The Java Image I/O API (the javax.imageio package) contains the basic classes and interfaces for reading/writing BufferedImages and RenderedImages from/to image files and streams.

The Java Image I/O API (the javax.imageio package) contains the basic classes and interfaces for reading/writing BufferedImages and RenderedImages from/to image files and streams.

Many common image I/O operations may be performed using the static methods of the ImageIO class.

The package contains classes describing the contents of image files, including metadata and thumbnails (IIOImage); for controlling the image reading process (ImageReader, ImageReadParam, and ImageTypeSpecifier) and image writing process (ImageWriter and ImageWriteParam); for performing transcoding between formats (ImageTranscoder), and for reporting errors (IIOException).

All implementations of javax.imageio provide the following standard image format plug-ins: JPEG, PNG, BMP, WBMP and GIF.

The javax.imageio package has been available since Java (J2SE) 1.4.

1092 questions
10
votes
6 answers

Faster alternative to ColorConvertOp

I have a method converting BufferedImages who's type is TYPE_CUSTOM to TYPE_INT_RGB. I am using the following code, however I would really like to find a faster way of doing this. BufferedImage newImg = new BufferedImage( src.getWidth(), …
Matt MacLean
  • 19,410
  • 7
  • 50
  • 53
10
votes
1 answer

javax.imageio.ImageIO file format constants

In javax.imageio.ImageIO there is a method #write(RenderedImage im, String formatName, OutputStream output) that accepts a "stringly-typed" format developer wants image to be written to. There is an inner class called CanEncodeImageAndFormatFilter…
Xobotun
  • 1,121
  • 1
  • 18
  • 29
10
votes
2 answers

Reading a progressively encoded 9000x9000 JPEG in Java takes 1 minute

When using javax.imageio.ImageIO to load a large-resolution (9000x9000) JPEG from disk, it takes more than 1 minute in my scala application. I tried creating a Java-only project, but it still takes too long - around 30 seconds. This is how I load…
the21st
  • 1,012
  • 1
  • 10
  • 24
10
votes
1 answer

Java: Detecting image format, resize (scale) and save as JPEG

This is the code I have, it actually works, not perfectly but it does, the problem is that the resized thumbnails are not pasting on the white Drawn rectangle, breaking the images aspect ratio, here is the code, could someone suggest me a fix for…
BoDiE2003
  • 1,349
  • 6
  • 28
  • 41
10
votes
3 answers

Fastest way to read/write Images from a File into a BufferedImage?

What is the fastest way to read Images from a File into a BufferedImage in Java/Grails? What is the fastest way to write Images from a BufferedImage into a File in Java/Grails? my variant (read): byte [] imageByteArray = new…
user2722142
10
votes
1 answer

ImageIO.write not working?

I'm writing a 3D paint and I found a problem in java. In one part of the code it's working: try { ImageIcon savePane=new ImageIcon("save.png"); String FilePath= (String)JOptionPane.showInputDialog(null,"Enter file path and name\n Warning:…
10
votes
4 answers

Loading animated gif from JAR file into ImageIcon

I'm trying to create a ImageIcon from a animated gif stored in a jar file. ImageIcon imageIcon = new ImageIcon(ImageIO.read(MyClass.class.getClassLoader().getResourceAsStream("animated.gif"))); The image loads, but only the first frame of the…
Steve K
  • 19,408
  • 6
  • 52
  • 50
10
votes
5 answers

Why Java ImageIO flattens JPEG colors

When I read certain JPG files, colors are flattened. Here is a simple example that reads a jpg and just writes the same image to another file. import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class…
ketorin
  • 1,034
  • 2
  • 12
  • 21
10
votes
1 answer

iPhone iOS saving data obtained from UIImageJPEGRepresentation() fails second time: ImageIO: CGImageRead_mapData 'open' failed

I'm running into a weird issue with my UIImage manipulation. I'm doing a dropbox sync, and have to store my images as local files. To do so, I save them using the UIImagePNGRepresentation(image) or UIImageJPEGRepresentation(image, 0.66) Here's my…
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
9
votes
1 answer

ImageIO: JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?

I get this error by downloading an image by HTTP. I have looked at the answer here but even the valid images don't return YES from the function. Any other ideas? The code to get the image is simple enough. This happens in a background…
jmosesman
  • 716
  • 1
  • 11
  • 24
9
votes
2 answers

How to send images through sockets in java?

I am writing a client-server program and I want that to send an image. The code is the following: //RECEIVER while(true){ try{ socket = server.accept(); out = new ObjectOutputStream(socket.getOutputStream()); …
enemy
  • 101
  • 1
  • 1
  • 3
9
votes
4 answers

Could not initialize class javax.imageio.ImageIO

I'm trying to deploy a Spring web app to a Tomcat 7 running on a production environment on Windows Azure (tried Ubuntu and Windows Datacenter VM). Sadly, I get an error while generating thumbnails in use with ImageIo (stack trace below). During…
Nando
  • 813
  • 2
  • 8
  • 18
9
votes
4 answers

java imageio memory leak

I have two Java applications that both use a ton of memory, and both use ImageIO.write(). So far, that is the only thing I have found in common between the two. One resizes images in a loop. The other downloads images in a loop and saves them to…
cutmancometh
  • 1,677
  • 3
  • 20
  • 28
9
votes
3 answers

Convert and display image from byte array

I'm making a program, which gets data about an image in byte array from a server. I'm converting this data into 24bit BMP format (whether its jpeg, png, bmp or 8-24-32bpp). First, I'm saving it to my HD, and then I'm loading it into a JLabel's Icon.…
bajla
  • 163
  • 2
  • 2
  • 12
8
votes
1 answer

Is javax.imageio.ImageIO broken? It imports some images as rotated

Below you will see a picture of beatiful pastry called "simit" from Turkey. It is taken from iPad 2, therefore it is a JPEG with dimensions 720*960. The problem is, when I use javax.imageio.ImageIO.read method, the image it strangely imports is to…
ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214