javax.imageio

Java- export to jar- i/o problems

最后都变了- 提交于 2019-12-19 12:36:06
问题 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

Java- export to jar- i/o problems

两盒软妹~` 提交于 2019-12-19 12:33:42
问题 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

Java- export to jar- i/o problems

落爺英雄遲暮 提交于 2019-12-19 12:33:41
问题 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

Java converting byte[] to image

爷,独闯天下 提交于 2019-12-19 10:05:43
问题 I know this seems like a common question but i have looked all over the internets, and tried many different tutorials and methods for doing this. I think i am close, but not sure. Also i am using Play Framework but it should be the same for java. here is my error javax.image.IIOException: I/O error reading PNG header! at com.sun.plugins.png.PNGImageReader.readHeader(Unknown Source) ... ... Caused by: java.io.EOFException at javax.imageio.stream.ImageInputStreamImpl.readFully(Unknown Source) .

Reading JPEGs: ImageIO.read() messes up color space

老子叫甜甜 提交于 2019-12-19 03:38:05
问题 I'm trying to read, rescale and save images within a Servlet. That's the relevant code: BufferedImage image = ImageIO.read(file); BufferedImage after = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); AffineTransform at = AffineTransform.getScaleInstance(factor, factor); AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); after = scaleOp.filter(image, null); ImageIO.write(after, "JPG", file)); The original file is a plain RGB-Jpeg, but when I

How do I flip an image horizontally flip with glReadPixels() Bufferedimage and out put with ImageIO?

自作多情 提交于 2019-12-18 08:53:38
问题 How do I flip an Screenshot image? I can't find my problem anywhere else. Example code: /* *@param fileLoc //Location of fileoutput destination *@param format //"png" *@param WIDTH //Display.width(); *@param HEIGHT //Display.height(); */ private void getScreenImage(){ int[] pixels = new int[WIDTH * HEIGHT]; int bindex; // allocate space for RBG pixels ByteBuffer fb = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3);//.order(ByteOrder.nativeOrder()); // grab a copy of the current frame contents

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

爱⌒轻易说出口 提交于 2019-12-18 06:12:37
问题 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 recommendation. Note - Image type of this image is 5 i.e BufferedImage.TYPE_3BYTE_BGR and i am using Java 7 Using Thumbnailator Thumbnails.of(fromDir.listFiles()) .size(thumbnailWidth, thumbnailHeight) .toFiles(Rename.SUFFIX_HYPHEN_THUMBNAIL);

Byte array to buffered image conversion slow

淺唱寂寞╮ 提交于 2019-12-18 05:55:41
问题 I have a simple server-side code that receives a byte array representing an image in JPEG format and returns the dimensions of the image. public String processImage(byte[] data) { long startTime = System.currentTimeMillis(); ByteArrayInputStream stream = new ByteArrayInputStream(data); BufferedImage bufferedImage; bufferedImage = ImageIO.read(stream); int height = bufferedImage.getHeight(); int width = bufferedImage.getWidth(); long endTime = System.currentTimeMillis(); return "height="

Create Layered Tif with Java for use in Photoshop

偶尔善良 提交于 2019-12-18 05:12:34
问题 I'm interesting in creating a layered tif with Java in a way that Photoshop will recognize the layers. I was able to create a multi-page tif, but Photoshop does not recognize the pages as layers. The pages are viewable with Acrobat though. Anyone know how Photoshop stores tif layer data and how that could be generated with Java? Thanks. 回答1: I have researched this for my TIFF ImageIO plugin, and as far as I understand, the way Photoshop stores layer information in TIFFs is completely

How to get an InputStream from a BufferedImage?

夙愿已清 提交于 2019-12-17 21:56:22
问题 How can I get an InputStream from a BufferedImage object? I tried this but ImageIO.createImageInputStream() always returns NULL BufferedImage bigImage = GraphicsUtilities.createThumbnail(ImageIO.read(file), 300); ImageInputStream bigInputStream = ImageIO.createImageInputStream(bigImage); The image thumbnail is being correctly generated since I can paint bigImage to a JPanel with success. Thank you. 回答1: If you are trying to save the image to a file try: ImageIO.write(thumb, "jpeg", new File(.