我从客户那里请求以.JIF格式发送图像。我有java应用程序,但是我不应该用google anithing来讨论如何转换成那个图像类型,我甚至很难将google anithing转换成".JIF“格式本身。
编辑:有人能建议如何在java中将Exif图像转换为JFIF吗?以及如何在这个JFIF图像中添加组件?(遗憾的是,试图使用jheader库时出现了非空指针异常,在google上没有更多的选择。)
发布于 2015-03-13 09:26:40
首先,您需要读取该图像,然后您必须将该图像写入您想要的维度和格式。您必须使用ImageIO类和读取图像来写入它们,使用Graphics2D类替换格式名以jif
File inputFile = new File(inputImagePath);
BufferedImage inputImage = ImageIO.read(inputFile);
// creates output image
BufferedImage outputImage = new BufferedImage(scaledWidth,
scaledHeight, inputImage.getType());
// scales the input image to the output image
Graphics2D g2d = outputImage.createGraphics();
g2d.drawImage(inputImage, 0, 0, scaledWidth, scaledHeight, null);
g2d.dispose();
// extracts extension of output file
String formatName = outputImagePath.substring(outputImagePath
.lastIndexOf(".") + 1);
// writes to output file
ImageIO.write(outputImage, formatName, new File(outputImagePath));https://stackoverflow.com/questions/29028564
复制相似问题