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
3 answers

save resized image java

How do i save a resized image to a specific folder? private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { ImgChooser ic = new ImgChooser(); ImageIcon icon = new ImageIcon(me,"id…
Weddy
  • 543
  • 6
  • 10
  • 21
6
votes
2 answers

Including Images with an executable jar

I have been browsing Stackoverflow all day looking for how to do this and I have not been successful yet I am packaging a quick game I made into a executable jar but I didnt reference the images correctly I just referenced the files background =…
Mintybacon
  • 331
  • 2
  • 4
  • 11
5
votes
2 answers

Storing DPI and Paper Size information in a JPEG with Java

I have the following code: ImageIO.write(originalImage, OUTPUT_TYPE, resultOutput); This is an invocation of the following javax.imageio.ImageIO method: public static boolean write(RenderedImage im, String formatName, …
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
5
votes
3 answers

How to resize an image without loading into memory?

I'd like to check the dimensions of an image, and then size it down if the width exceeds a given threshold. When I load a 6MB JPEG image with ImageIO.read(), the BufferedImage allocates about 45MB of heap space. Is there a way to do a passthrough…
Boris Burtin
  • 811
  • 1
  • 7
  • 18
5
votes
2 answers

ImageIO.write not saving out as gif, but works for jpgs and pngs?

I suspect the solution here is probably really simple, but I'm stumped... // Create the buffered image. BufferedImage bufferedImage = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); // fill image data (works fine) ImageIO.write(bufferedImage,…
Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
5
votes
1 answer

Pink background colour in output TIFF when reading and writing some TIFF images with java ImageIO

I am attempting to merge a number of input TIFF files into a single multi-page output TIFF file using the open JDK 11 imageIO ImageReader and ImageWriter classes. My routine works correctly for almost all of my sample input files created from a…
5
votes
2 answers

Convert a 2D array of int ranging from 0-256 into a grayscale png?

How can I convert a 2D array of ints into a grayscale png. right now I have this: BufferedImage theImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB); for(int y = 0; y<100; y++){ for(int x = 0; x<100; x++){ …
wfbarksdale
  • 7,498
  • 15
  • 65
  • 88
5
votes
1 answer

Cannot run or jai_imageio or ImageIO.getImageReadersByFormatName cannot get Object

I'm running a program that using jai_imageio.jar and then validating if I can get ImageIO.getImageReadersByFormatName("tiff") for some reason the program is running on other server, But when I checkout / load it into my server it always cause an…
ace
  • 6,775
  • 7
  • 38
  • 47
5
votes
1 answer

ImageIO: ERROR - MetadataLib.dylib not found

I'm getting an odd error in my console when running my app sometimes: ImageIO: ERROR - MetadataLib.dylib not found I'm not sure what this is related to, but I am running AdMobs ads.
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
5
votes
2 answers

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 size calculation? If yes, to where exactly the image is…
Mike
  • 14,010
  • 29
  • 101
  • 161
5
votes
2 answers

How to set crop starting position with imgscalr?

I have tried to use imgscalr library with the following crop method: Scalr.crop(image, height, width); But it always crops starting at the left upper corner of the image. Can I tweak this behavior to start in the right bottom corner or center?
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
5
votes
1 answer

Split an image into parts

I know that there are a lot of topics about this, but none really fits into my problem. I need the attached image (link) divided into multiple sub-images and I search for the easiest way to do this. The image should be saveable. I tried…
codepleb
  • 10,086
  • 14
  • 69
  • 111
5
votes
1 answer

BufferedImage getRGB vs Raster getSample

I am trying to do some image processing in Java. I used ImageIO library for reading and writing images. I can read the image pixel value in two ways as follows (there might be other methods which do not know). Using BufferedImage's getRGB method: …
user1481317
5
votes
3 answers

Text is missing when converting pdf file into image in java using pdfbox

I want to convert a PDF page to image file. Text is missing when I convert a PDF page to image using java. The file which I want to convert 46_2.pdf after converting it shown me like 46_2.png Code: import java.awt.image.BufferedImage; import…
UdayKiran Pulipati
  • 6,579
  • 7
  • 67
  • 92
5
votes
2 answers

ImageIO is synchronized

I have a web application where users upload images. We validate the image data via ImageIO.read() and perform a few simple transformations on the resulting BufferedImage before saving it to disk. While performing load testing, we realized that when…
user1236874
  • 167
  • 3
  • 13