I’ve been making an image rescaler that uses the ImageIO library in Java to convert them to a buffered image. Unfortunately it doesn’t recognise every type of JPEG that I may pass to it and so I need to “convert” these other types. The way I’m converting them is to take an existing APP0 tag from a standard JFIF JPEG and what I want to do is on the 3rd byte into the file insert 18 bytes of data (the FFE0 marker and the 16 byte APP0 tag) and then I want to add the rest of the file to the end of that.
So to generalise, what’s the most efficient way to add/insert bytes of data mid way through a stream/file?
Thanks in advanced,
Alexei Blue.
This question is linked to a previous question of mine and so I’d like to thank onemasse for the answer given there.
Java JPEG Converter for Odd Image Types
Thanks for the suggestion guys, I used a FilterInputStream at first but then saw there was no need to, I used the following piece of code to enter my APP0 Hex tag in:
And in the desired converter method:
Hope this helps anyone having the a similar problem 🙂