I want to rotate an jpeg image lossless.
My code works with success but is with loss:
ByteArrayInputStream inputstream = new ByteArrayInputStream(imgByteArraySource);
BufferedImage oldBufferedImage = ImageIO.read(inputstream);
BufferedImage newBufferedImage = rotate(oldBufferedImage, degrees);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(newBufferedImage, "jpg", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
I found an old post on this site: Lossless JPEG Rotate (90/180/270 degrees) in Java?
Maybe there is a better solution. I'm not very confident about the media-util library (it is old, and it is packaged in a .exe file).
Has someone an idea? Is there a new and better way to do this?
Thanks in advance.
Bobby