WebP: Reading from InputStream with unknown length does not decode (produces black image)
See original GitHub issueVersion information 3.8.2
** The exact output of java --version
(or java -version
for older Java releases).
openjdk version “11.0.3” 2019-04-16 LTS
OpenJDK Runtime Environment Corretto-11.0.3.7.1 (build 11.0.3+7-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.3.7.1 (build 11.0.3+7-LTS, mixed mode)
Describe the bug
First of all, thank you for creating a very useful library.
My problem is:
https://github.com/haraldk/TwelveMonkeys/issues/672#issue-1204081521 Similar to the problem above. (only for webp )
In my case, I want to immediately save the image uploaded by the client. It’s not reading a file, it’s saving a byte[] or InputStream as an image file.
Because in my case I am using Spring framework,
From org.springframework.web.multipart.MultipartFile. For example
BufferedImage image = ImageIO.read(multipartFile.getInputStream());
However, the result is that a black image is extracted.
https://github.com/haraldk/TwelveMonkeys/issues/672#issue-1204081521 Seeing the above case, I temporarily solved it like this:
// Once uploaded, save the image as a file to disk.
FileCopyUtils.copy(multipartFile.getBytes(), file);
// Read back the file saved to disk. for image processing
BufferedImage image = ImageIO.read(file);
// Process the image and save it again.
This works fine, but it’s an unnecessary process. It will take more time.
BufferedImage image = ImageIO.read(multipartFile.getInputStream());
Is there any way to solve the above at once?
thank you!
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Hi,
I’m currently on summer holiday with my family, but I’ll try to make a new release when I’m back in the office.
In the mean time, please try one of the later snapshot-builds, to see if they fix the problem for you. 😀
– Harald K
Hey @haraldk! I’m having the same issue reported by gjrjf. I see you fixed it on Apr 22nd (https://github.com/haraldk/TwelveMonkeys/commit/9fe87fe10d692c5b9142e0c8f00f4118c07fc49e). However, the latest TwelveMonkeys release is from Feb 22nd. Are you planning to release a new version of TweveMonkeys any time soon? Can I help somehow? I’m very interested in this fix.