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

Reading images using ImageIO.read(file); 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 fixed to avoid the OutOfMemory error? Or is the only option to increase the JVM heap size? File…
arjunurs
  • 1,062
  • 2
  • 17
  • 29
6
votes
1 answer

How to convert any image to JPG?

I am receiving a MultipartFile Spring object from rest controller. I am trying to convert any inage file to JPG image but I just need the byte array to save it on mongoDb I found this code to do that public boolean convertImageToJPG(InputStream…
TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
6
votes
3 answers

Compress JPG make the image turn green

When I try to compress the a jpg image, most of the time it work perfectly, however some jpg image turn green after the compression. Here is my code public void compressImage(String filename, String fileExtension) { BufferedImage img = null; …
Thang Pham
  • 38,125
  • 75
  • 201
  • 285
6
votes
1 answer

ImageIO.createImageInputStream Keeps Returning null

Hey all, Whenever I try to get an ImageInputStream object using ImageIO.createImageInputStream it simply returns null with no exceptions, warnings or errors. I have tried passing different data types to the function, a simple File, and an…
Sean Kelleher
  • 1,952
  • 1
  • 23
  • 34
6
votes
1 answer

JAI ImageIO NoClassDefFoundError for RawImageInputStream

I am very confused with this issue. I am using 1.3.0 version on jai-imageio-core please check the dependecy below and I am at complete loss to figure out from the jar how can one class file (RawImageReaderSpi) is loaded in JVM but…
Rocky
  • 391
  • 7
  • 20
6
votes
1 answer

How to exclude specific TIFF reader from ImageIO?

Stack: Java - 1.8.0_91 Scala - 2.11.8 Library - it.geosolutions.imageio-ext imageio-ext-tiff 1.1.15 We are reading lots of old TIF images and for some reason read is highly inconsistent - for some reasons on a different run reading the same image…
mavarazy
  • 7,562
  • 1
  • 34
  • 60
6
votes
1 answer

Blur an image using java.util.concurrent, however, the resulting image is entirely black

I'm new to Java and is trying to learn the concept of high level concurrency. I saw this code at Java Tutorial Oracle. However, when I run the code, the IDE output an image that is entire black. Why is this happening? And also, how is the compute()…
Thor
  • 9,638
  • 15
  • 62
  • 137
6
votes
0 answers

Java - Correct way to scale an image

Context I'm reviewing some legacy Java code that's used in a server-side application to scale images. Until recently it has predominately been used with input images that possessed resolutions of 1024x768 or below, and in this context it seems to…
aroth
  • 54,026
  • 20
  • 135
  • 176
6
votes
2 answers

Pink/Reddish tint while resizing jpeg images using java thumbnailator or imgscalr

I am trying to convert an image (url below) using two libraries (thumbnailator and imgscalr. My code works on most of the images except a few which after conversion have a pink/reddish tint. I am trying to understand the cause and would welcome any…
rohtakdev
  • 956
  • 1
  • 13
  • 16
6
votes
1 answer

Java 8 ImageIO reads JPEG incorrectly in Linux

I'm trying to read user-uploaded JPEG image (arbitrary) to create thumbnail in server app. System works just fine in Windows7 / Oracle Java 8u11 but I have problem with color model under CentOS on server: original image is:…
6
votes
2 answers

How to make ImageIO read from InputStream :Java

I have created executable jar file(using Eclipse) , there are a set of image (.png) files that is to be inculded in the jar. So I have added a source folder with all the images inside /images folder in the project . Code has to access these file to…
2FaceMan
  • 443
  • 2
  • 18
  • 34
6
votes
2 answers

Compression of PNG using JAI (Java Advanced Imaging)

I am using javax.imageio API and JAI for compressing different types of images. It works fine for JPEG using JPEGImageWriter and GIF using GIFImageWriter. But it is not supporting for PNG compression using PNGImageWriter which throws an exception…
Gnaniyar Zubair
  • 8,114
  • 23
  • 61
  • 72
6
votes
2 answers

Combining images where BG is a JPEG causes unexpected results

Why does combining images where BG is a JPEG cause unexpected results? This is a follow-up to my answer in Overlaying of 2 images doesnt work properly. The source posted there (using a BG image created in memory) looks like this: The BG image is…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
6
votes
2 answers

Unable to open resources in directories which end with an exclamation mark (!)

The getResourceAsStream-method returns null whenever running the executable jar in a directory which ends with a exclamation mark. For the following example, I have a Eclipse project the following directory structure: src\ (Source Folder) main\…
Velth
  • 1,108
  • 3
  • 15
  • 29
6
votes
2 answers

Eclipse missing imports (javax.media.* and com.sun.media.*)

I have this old java applet that i need to debug, yet i have some problems with import. The import javax.media.* cannot be resolved. The import com.sun.media.* cannot be resolved After some research i tried adding this external libs to the project…
no9
  • 6,424
  • 25
  • 76
  • 115