Reputation: 11
Below is the sample code that is giving error with the microsoft sample pictures (tulips.jpg) image
bufferedImage = Imaging.getBufferedImage(new file("Tulips.jpg"));
File imageFile = new File("outputfile.jpg");
final Map<String, Object> optionalParams = new HashMap<String, Object>();
Imaging.writeImage(bufferedImage, imageFile, ImageFormats.JPEG, optionalParams);
This code is giving "This image format (Jpeg-Custom) cannot be written." Any pointers would be of great help. I have searched stackoverflow, google - no help so far.
When I read the documentation it states that if the bufferedImage.getType()== TYPE_UNKNOWN, it gives this message but dont have a clue why it is giving UNKNOWN.
Thanks so much for your help.
Upvotes: 1
Views: 3825
Reputation: 308
Write to JPEG files is not supported by Apache Commons Imaging. You can see supported format information here: http://commons.apache.org/proper/commons-imaging/formatsupport.html (even JPEG read is not fully supported). However write to some other formats supported (e.g. you can change image format to PNG in your writeImage function call and it will work).
Moreover Apache Commons Imaging is not released yet, so I wouldn't recommend using it in a critical code.
As alternative you can take a look into JDK javax.imageio.ImageIO class (some examples: https://docs.oracle.com/javase/tutorial/2d/images/saveimage.html).
What exactly are you trying to achieve in your code?
Upvotes: 4