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
15
votes
2 answers

Write dpi metadata to a jpeg image in Java

I am trying to programatically set the dpi metadata of an jpeg image in Java. The source of the image is a scanner, so I get the horizontal/vertical resolution from TWAIN, along with the image raw data. I'd like to save this info for better print…
dasp
  • 909
  • 4
  • 13
  • 21
15
votes
12 answers

java.lang.IllegalArgumentException: input == null! when using ImageIO.read to load image as bufferedImage

This is a question that has been asked like 100 times on this site, but I have looked at all of them and even though they all were solved, none of the solutions worked for me. Here's what my code looks like: public Button1(Client client, String…
tyler
  • 589
  • 2
  • 5
  • 9
15
votes
4 answers

Using BufferedImage and ImageIO classes in my Android Activity

I am developing an Android App that can do Gamma correction of an image stored in phone. My activity can get the image location, but i cant use the BufferedImage class and ImageIO class in my Application. I get the following error in Eclipse IDE…
humandroid
  • 311
  • 1
  • 3
  • 12
14
votes
3 answers

Convert Byte Array to image in Java - without knowing the type

Sounds simple right? Use ImageIO.read(new ByteArrayInputStream(bytes)); Here's the wrinkle. For some reason it is detecting a jpeg as a bmp, and that is the first ImageReader returned when I call ImageInputStream iis =…
PHeath
  • 1,157
  • 3
  • 13
  • 12
13
votes
6 answers

How can I save a PNG with a tEXt or iTXt chunk from Java?

I am currently using javax.imageio.ImageIO to write a PNG file. I would like to include a tEXt chunk (and indeed any of the chunks listed here), but can see no means of doing so. By the looks of com.sun.imageio.plugins.png.PNGMetadata it should be…
Martin Cowie
  • 2,788
  • 7
  • 38
  • 74
13
votes
3 answers

Can I tell what the file type of a BufferedImage originally was?

In my code, I have a BufferedImage that was loaded with the ImageIO class like so: BufferedImage image = ImageIO.read(new File (filePath); Later on, I want to save it to a byte array, but the ImageIO.write method requires me to pick either a GIF,…
Thunderforge
  • 19,637
  • 18
  • 83
  • 130
13
votes
6 answers

Invalid PNG Image file: iDOT doesn't point to valid IDAT chunk

I have some HTML content pages in an app and I'm using a UIWebView to display them. Some of these pages have a PNG image in them that is generating the following message in the debug console in xcode: ImageIO: PNG invalid PNG file: iDOT doesn't…
kinadian
  • 238
  • 1
  • 3
  • 11
13
votes
4 answers

Convert BufferedImage into byte[] without I/O

Hi I have a BufferedImage instance in memory and want to convert it into byte[] to encode as base64 string without I/O operation for performance consideration. I was using the following API: ByteArrayOutputStream baos = new ByteArrayOutputStream…
user1344933
  • 131
  • 1
  • 4
12
votes
2 answers

Increasing screen capture speed when using Java and awt.Robot

Edit: If anyone also has any other recommendations for increasing performance of screen capture please feel free to share as it might fully address my problem! Hello Fellow Developers, I'm working on some basic screen capture software for myself. As…
EthanLWillis
  • 930
  • 4
  • 14
  • 27
11
votes
1 answer

Convert a tiff into a buffered image (Java)

I need to convert a tiff file into a BufferedImage. I wrote the following code: String filepath = "C:\\tiffFolder\\"; String filename = "myTiffImage.tif"; File myFile = new File (filepath + filename); BufferedImage img = ImageIO.read(myFile); I…
Daniele Milani
  • 553
  • 2
  • 7
  • 26
11
votes
3 answers

Using ImageIO.write() to create a JPEG creates a 0 byte file

I am trying to write a method that takes an image, and saves a 100 by 100 thumbnail of that image. However, when I save the file, it comes out as an unreadable 0 byte image (with the error "Error interpreting JPEG image file (Improper call to JPEG…
Thomas Preston
  • 697
  • 1
  • 7
  • 19
11
votes
1 answer

How to read pixel color in a java BufferedImage with transparency

I am reading pixel color in a BufferedImage as follows: ..... InputStream is = new BufferedInputStream(conn.getInputStream()); BufferedImage image = ImageIO.read(is); int color = image.getRGB(x, y); int red = (colour & 0x00ff0000) >> 16; int …
Richard H
  • 38,037
  • 37
  • 111
  • 138
11
votes
1 answer

ImageIO can't read input file

public static void imRes(String pat) { try { BufferedImage bckimg = ImageIO.read(new File("c:/s/deneme.jpg")); File s = new File(pat); BufferedImage im = ImageIO.read(s); BufferedImage im1 =…
s.alem
  • 12,579
  • 9
  • 44
  • 72
11
votes
2 answers

With "ImageIO.write()" API call I get NullPointerException

With ImageIO.write() API call, I get NullPointerException when I pass a non-existent path like "\\abc\abc.png". I pass the non-existent path purposely to test something but instead of getting FileNotFoundException, I get NPE. Why is that?…
Nayan Soni
  • 1,001
  • 3
  • 12
  • 22
11
votes
2 answers

Creating progressive jpeg on iOS with ImageIO produces blocky results on device

I'm trying to create a progressive jpeg from a UIImage object, this is the code i'm NSMutableData *data = [NSMutableData data]; NSString *path = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Caches/test.jpg"]; CFURLRef url =…
Jorge Cohen
  • 1,512
  • 10
  • 34
1 2
3
72 73