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.

javax.imageio
Filter by
Sorted by
Tagged with
-1 votes
0 answers
29 views

How to convert HEIC/HEIF format images to jpg/jpeg/png format using java based solution [closed]

I am looking for a java based solution to convert HEIC/HEIF to jpeg or jpg or png. Since ImageIO cannot read HEIF/HEIC format images my functionality is breaking. I have tried ImageMagick but it is ...
0 votes
0 answers
22 views

I am trying to read an JPEG image, which is of 32 bits pixels, but ImageIO.read(new File(path)).getColorModel() akways returns 24 bits

I am trying to read an JPEG image, which is of 32 bits pixels, but ImageIO.read(new File(path)).getColorModel() akways returns 24 bits and image get inverted or doesnt appear properly. Also Sanselan....
0 votes
1 answer
25 views

PNG file corrupted after calling ImageReader getHeigth

I got my png file corrupted after calling : BufferedImage im = ImageIO.read(inputStream); You will find the service life cycle below : InputStream inputStream = multipartFile.getInputStream(); ...
0 votes
1 answer
94 views

pdfbox 3.x, is it recommended to include jai-imageio when I am already using twelvemonkeys?

I am already using twelvemonkeys tiff and jpeg along with pdfbox 3.0.1 <dependency> <groupId>com.twelvemonkeys.imageio</groupId> <artifactId>...
1 vote
1 answer
77 views

Convert a PNG to Bitmap custom Hex String

This is opposite of this : create BITMAP image from hex String Java I need to take a PNG as input, and convert it into HEX String. The specification of how the Hex String is created is as below : ...
1 vote
0 answers
19 views

Create Two Row image from Text in Java

I already have a working API in java that takes text in request, and creates a PNG image from this text using custom fonts and returns a BASE64 encoded data of the image. Now, I need to modify this ...
133 votes
14 answers
256k views

How to get image height and width using java?

Is there any other way besides using ImageIO.read to get image height and width? Because I encounter an issue that locks up the thread. at com.sun.medialib.codec.jpeg.Decoder.njpeg_decode(Native ...
7 votes
2 answers
11k views

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 ...
-1 votes
1 answer
47 views

Scala ImageIO.read(byteArrayInputStream) IllegalArgumentException: Numbers of source Raster bands and source color space components do not match

I am using ImageIo to directly read ByteArrayInputStream but for some specific images, I am getting the error as shown below: IllegalArgumentException: Numbers of source Raster bands and source color ...
19 votes
1 answer
27k views

IllegalArgumentException: Numbers of source Raster bands and source color space components do not match For a color image Exception

The above answer that someone has suggest, converts my colored image to a black and white one. So it's not appropriate for my question. File file = new File("path"); BufferedImage ...
18 votes
3 answers
13k views

ImageIO.read illegal argument exception - raster bands/colour space components?

Apologies for the somewhat vague title, I can't work out what the keywords are here. The setup's quite simple, I'm opening an image with ImageIO.read(new File(filename)); This works for most files, ...
0 votes
0 answers
23 views

java.lang.NullPointerException: Cannot invoke "java.awt.image.BufferedImage.getSubimage(int, int, int, int)" because "this.tileSet" is null [duplicate]

I am trying to code a little RPG and I'm stuck at getting images to my game. I have a problem with loading a tileset. I wrote a tileSet class, but I the tileset is always null. Check my code, maybe ...
51 votes
6 answers
88k views

Unable to read JPEG image using ImageIO.read(File file)

I'm having problems reading this one JPEG file using ImageIO.read(File file) - it throws an exception with the message "Unsupported Image Type". I have tried other JPEG images, and they seem to work ...
0 votes
0 answers
16 views

Changing JFIF X and Y Resolution with Java [duplicate]

I have a JPEG image that need to set Metadata JFIF X and Y Resolution, but I don't know how I can do it. Please be Aware I don't need set Image Vertical and Horizental resolution! I need added Into ...
0 votes
1 answer
527 views

Getting java.io.IOException: closed whenever I close my program

Every time I run my program it runs fine. But when I close it after running the program for a few seconds, then I get the java.io.IOException: closed error. I've tried looking around and couldn't find ...
6 votes
2 answers
9k views

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 (...
9 votes
1 answer
14k views

Can't import javax.imageio.ImageIO in Android application

I want to save canvas object as image, and for this I want use ImageIO class. I'm using Eclipse, but when I try make import of this lib (import javax.imageio.ImageIO;) Eclipse is shows me an error "...
0 votes
1 answer
59 views

Update PNG metadata

I'm trying to add information to the metadata, I wrote the following code: ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next(); ImageWriteParam writeParam = writer....
63 votes
6 answers
45k views

ImageIO not able to write a JPEG file

I have a BufferedImage I'm trying to write to a jpeg file, but my Java program throws an exception. I'm able to successfully save the same buffer to a gif and png. I've tried looking around on Google ...
1 vote
1 answer
445 views

dependency conflicts with batik-transcoder and java 17

I'm trying to use the twelvemonkeys and batik to process svg files in java. <!-- https://mvnrepository.com/artifact/com.twelvemonkeys.imageio/imageio-batik --> <dependency> ...
0 votes
0 answers
131 views

Exporting TIFF takes a long time and creates big files

I'm using the "Twelve Monkeys" (Github) library to read a .tif/.tiff file in Java 8, add a logo and export the new image as a new .tif/.tiff file: try { BufferedImage buffLogo = ImageIO....
1 vote
0 answers
1k views

JAXBContext not working in Java 17.0.3 (It was working in java 11)

JAXBContext jaxbContext = JAXBContext.newInstance(Instances.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Instances instances = (Instances) ...
1 vote
2 answers
6k views

Exception "java.lang.IllegalArgumentException: image == null!" in ImageIO

I'm trying to write a png file from a bytes array. My application is throwing the following exception "java.lang.IllegalArgumentException: image == null!" in ImageIO I tested my solution using a ...
17 votes
3 answers
10k views

ImageIO.read( ) always rotates my uploaded picture

I want to create a web application that allow users to upload their image to the server. When they click send, their image will be uploaded to the server (multipart). Before saving, I want to make ...
1 vote
1 answer
1k views

Safely discarding ICC profile information in Java Image I/O

I'm using Java Image I/O with Java 11 to read a JPEG image, scale it by drawing a scaled version, and then writing it. (I am using this technique because it produces good results and the JAI subsample ...
0 votes
0 answers
89 views

Exception in thread "main" java.lang.IllegalArgumentException: input == null! when using ImageIO.read(this.getClass().getResource()

I got Exception in thread "main" java.lang.IllegalArgumentException: input == null! at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1400) at studentsystem.frame....
0 votes
1 answer
211 views

Reading a multipage TIFF file with ImageIO fails after deployment to kubernetes

I have a Java program that converts a multi-page file into separate image files. The code works perfectly fine when I run it locally, but when I deploy it into Kubernetes, it doesn't work at all. ...
0 votes
0 answers
139 views

Reading a tiled float32 BigTIFF using Twelvemonkeys java ImageIO

I want to read a specific GeoTIFF file, which is a BigTIFF containing a set of uncompressed 128x128 tiles of float32 data. My code snippet requests a small rectangle. It works with ordinary TIFFs, ...
0 votes
2 answers
147 views

Prevent loading a big image into `BufferedImage` when only the size of its compressed version is known

I have a service that receives URLs of already uploaded images: its task is to resize them and save them compressed, loading them like this: BufferedImage src = ImageIO.read(imgURL); There might be ...
0 votes
0 answers
41 views

How can I get my resources to export with my Jar File?

I am trying to export a Jar file including several images, fonts, etc. All of this works perfectly in intelliJ, works perfectly in Jar file on creating computer, but will not work on other computer. ...
0 votes
1 answer
1k views

BufferedImage Read from file using ObjectStream is null

Description Im reading Theme Objects from a file, the Theme class has a list of buffered images that is transient, but uses a custom read/write Object method that uses ImageIO's read and write. The ...
0 votes
0 answers
12 views

My jar can't find my images in my game but in the ide (eclipse) works just fine [duplicate]

so my jar can't find the images in my program but they are found by the IDE here is the error message. I also went into the jar and they are in the jar itself , the images are all there javax....
5 votes
2 answers
3k views

Is there any way in Java to take image width and height without transfer or download?

In order to get image's height we can use ImageIO.read(new URL("…")).getHeight(). My questions: Do I understand correctly that this method downloads the image to the local computer prior ...
0 votes
1 answer
377 views

How can I change the color profile of a BufferedImage without changing the pixel values?

I have a BufferedImage with an invalid color profile. I want to replace the color profile with an ICC_Profile without recomputing the pixel values in the image. How can I do that? In particular the ...
1 vote
0 answers
167 views

BufferedImage text poor quality with antialiasing and high DPI

I'm trying to write a String to a BufferedImage but it is either horribly pixelated (without antialiasing) or blurry (with antialiasing). I've tried increasing the DPI when I write the image to an ...
1 vote
0 answers
72 views

Transparency in the BMP image format Java

Is it possible to store a BufferedImage with transparency in the BMP image format? With 32 bits per pixel this information should be storable. I also don't need a fine gradation of transparency but ...
3 votes
2 answers
603 views

javax.media.NoDataSinkException

I am trying to convert Jpeg images into .mov video file package com.ecomm.pl4mms.test; import java.io.*; import java.util.*; import java.awt.Dimension; import javax.media.*; import javax.media....
0 votes
1 answer
214 views

Convert a PNG to PPM using ImageIO TwelveMonkey extension

I have a requirement to convert a PNG file to PPM file. In the same project, I have used TwelveMonkey extension to convert a PPM to PNG and it results perfectly. But when trying the other way round, ...
4 votes
2 answers
7k views

Does ImageIO.read() take EXIF orientation metadata into account?

In JPEG images, EXIF metadata is sometimes included and tells in what orientation the image should be shown. The question is, whether Java's ImageIO.read() takes EXIF into account while reading a ...
0 votes
1 answer
426 views

Merge images in Java

I am trying to merge two images in Java. The two photos must be positioned horizontally (the first to the left of the second). I think I have problems in the write method of the ImageIO class. import ...
0 votes
1 answer
378 views

Any Alternative to ImageIO.write to convert bufferedimage to GIF bytes (Faster than ImageIO)?

my problem is when using imageio.write i am seeing that is using hdd, also read about jDeli (but too expensive), Apache Commons, JAI that are much faster.... I wanna use the encoded bytes returned by ...
2 votes
0 answers
76 views

ImageIO with encrypted File cache

Problem: I read and write large multipage tiffs. During my test I have seen plain tiffs on disk. I know I can disable writing to disk with ImageIO.setUseCache(false) but then all data is in memory, ...
0 votes
1 answer
726 views

ImageIO.read unable to find .png-file

sorry if this has been asked quite a few times, I'm new here. I've used three different approaches to get a file to be loaded and nothing worked: Using Toolkit: Image image = Toolkit....
-1 votes
2 answers
632 views

How do you solve lagging in Java awt/swing image printing?

I am trying to make a simple game with Java swing/awt. I am have issue with lagging while printing and moving images on the screen. Here is my code below: import java.awt.*; import java.awt.event.*;...
0 votes
1 answer
403 views

Image object from BLOB?

I'm having trouble getting an image object from a BLOB stored in a mySQL table. Table "images" has values: "idImage" (int), "idArticle" (int), "image" (BLOB). ...
-2 votes
1 answer
185 views

Unreachable catch block for IIOException. This exception is never thrown from try statement and javax.imageio.IIOException: Can't read input file

Code that triggers "Unreachable catch block for IIOException. This exception is never thrown from try statement" int width = 0, height = 0; BufferedImage img = null; ...
0 votes
1 answer
56 views

variable name cannot be resolved but I have already created the variable [duplicate]

try { try { Image img = ImageIO.read(new File("target.png")); String imgpath = "target.png"; } catch (IOException e) { e.printStackTrace();} ...
0 votes
1 answer
787 views

create BITMAP image from hex String Java

I have a requirement to create a BMP image (black & white) from the hex string created through Excel Macro. I have next to zero experience working on this and need some help. Below is the Hex ...
2 votes
3 answers
7k views

How to change the image type of a BufferedImage which is loaded from file?

I'm trying to access the pixels in a BufferedImage which is loaded from a file using ImageIO.read(filePath), but I get this error: Exception in thread "Game" java.lang.ClassCastException: java.awt....
0 votes
2 answers
1k views

ImageIO.write not writing image into folder

I am working on a project in which I am trying to store all the pixels of a jpg image in an array, and then using that array to write a copy of the original image in a different folder. However, I do ...

1
2 3 4 5
22