javax.imageio

ImageIO.createImageInputStream Keeps Returning null

爷,独闯天下 提交于 2019-12-01 17:53:34
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 InputStream , but both returned null also. The documentation says that if no suitable ImageInputStreamSpi is found then the function will return null , but the file is a bog-standard JPEG, and surely Java comes with a service provider for such a format out of the box? Thanks for your time. /** * Reads in an image from a file and returns the image in a * {

ImageIO.write not working?

心已入冬 提交于 2019-12-01 16:52:30
问题 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: Instead of one '\\' write '\\\\'", "Save",JOptionPane.PLAIN_MESSAGE,savePane,null,"C:\\\\example.png"); BufferedImage image = new Robot().createScreenCapture(new Rectangle(110,130,put.getWidth()-3,put.getHeight())); ImageIO.write(image, "png", new File

Java- export to jar- i/o problems

倾然丶 夕夏残阳落幕 提交于 2019-12-01 14:04:40
I work on Eclipse (Juno with JDK7), and the program runs (on Eclipse) fine. My problematic lines are: URL imageURL = new URL("http://www.idautomation.com/ocr-a-and-ocr-b-fonts/new_sizes_ocr.png"); RenderedImage img = ImageIO.read(imageURL); File outputfile = new File("saved.png"); ImageIO.write(img, "png", outputfile); But when i export the project to a jar file and try to run it via windows (7- 64 bit) command line, the following error appears: Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect

Exception when trying to save images

瘦欲@ 提交于 2019-12-01 12:09:17
When starting my Java application, I get exceptions when trying to save images. In Eclipse, however, everything works fine. The application is built using fatjar and the necessary libraries (jar_imageio.jar and ij.jar) have been selected for export as well. I tried using ImageIO and ImageJ: a.) ImageIO: ImageIO.write(image, "jpg", new File(f)); Exception in thread "main" sun.misc.ServiceConfigurationError: javax.imageio.spi.ImageWriterSpi: Provider com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageWriterSpi could not be instantiated: java.lang.IllegalArgumentException: vendorName == null! at

Storing DPI and Paper Size information in a JPEG with Java

谁说胖子不能爱 提交于 2019-12-01 09:42:14
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, File output) throws IOException This turns an original BMP image into a JGP output. Is it possible to also store DPI and Paper Size information in the JPEG to aid in printing operations? Abdur Rahman Luckily, the java image I/O API lets you do just that. It also allows for setting the image metadata in a format-independent way. For example to specify the desired DPI, which was

Java Handling TIF Images

▼魔方 西西 提交于 2019-12-01 09:05:57
问题 My question is, what how can I successfully load a .tif file into an Image instance in Java? Let me give some more detail now. I have read a lot of the threads on stackoverflow on how to handle/convert TIF images in Java. I have tried a lot of the stackoverflow suggestions (I say suggestions, because rarely do the people asking come back and say something has worked for them). I am pretty sure I need to use the Java Advanced Imaging (JAI) library, but I don't think I know how to use it. Let

Problem converting PNG to JPG using Java (ImageIO.write()) [duplicate]

核能气质少年 提交于 2019-12-01 08:58:51
This question already has an answer here: Issue using ImageIO.write jpg file: pink background [closed] 6 answers I am using ImageIO.write() to convert PNG files to JPG. For some reason, my result image has a pink layer over it. I have searched far and wide for a solution but haven't found any. The code works for all other types of images except PNG. Quick reading of other SO answers tagged ImageIO led to this . The root cause can be a buggy reader. The proposed workaround is using different reader package. Edit Above link is broken, but this appears to be it. Edit The above links are broken,

How to exclude specific TIFF reader from ImageIO?

南楼画角 提交于 2019-12-01 08:54:42
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 can succeed or fail with exception - javax.imageio.IIOException: Invalid component ID 3 in SOS at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method) at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1236) at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1039) at com.sun.media

Exception when trying to save images

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 08:11:15
问题 When starting my Java application, I get exceptions when trying to save images. In Eclipse, however, everything works fine. The application is built using fatjar and the necessary libraries (jar_imageio.jar and ij.jar) have been selected for export as well. I tried using ImageIO and ImageJ: a.) ImageIO: ImageIO.write(image, "jpg", new File(f)); Exception in thread "main" sun.misc.ServiceConfigurationError: javax.imageio.spi.ImageWriterSpi: Provider com.sun.media.imageioimpl.plugins.jpeg

Java casting / classloader issues

ⅰ亾dé卋堺 提交于 2019-12-01 08:04:54
Here is the simplified version of the problem: SomeClass c = (SomeClass) obj.getSomeClassParent() not always but it happens sometimes to trigger exception org.somepackage.SomeClass can't be cast to org.somepackage.SomeClass How is this possible ? I suppose it has something to do with the fact that JAI imageio is native lib, but relay how can this happen ? I'm probably missing something but what ? I'm using JAI imageio version 1.1 dcm4che 2.0.21 DICOM lib Here is the original code ImageInputStream iis = ImageIO.createImageInputStream(src); Iterator<ImageReader> iter = ImageIO