Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert webp to jpeg, memory skyrocketed #1078

Closed
biubiue opened this issue Jan 12, 2025 · 2 comments
Closed

convert webp to jpeg, memory skyrocketed #1078

biubiue opened this issue Jan 12, 2025 · 2 comments

Comments

@biubiue
Copy link

biubiue commented Jan 12, 2025

Describe the bug
when convert webp to jpeg,webp only 540kb, jvm -Xms=512m,-Xmx1536m , oom ,then application restart

Version information

  1. The version of the TwelveMonkeys ImageIO library in use.
com.twelvemonkeys.imageio imageio-webp 3.12.0 com.twelvemonkeys.imageio imageio-jpeg 3.12.0 com.twelvemonkeys.servlet servlet 3.12.0
  1. The exact output of java --version (or java -version for older Java releases).
    openjdk version "17.0.4.1" 2022-08-12
    OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
    OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode, sharing)

  2. Extra information about OS version, server version, standalone program or web application packaging, executable wrapper, etc. Please state exact version numbers where applicable.

To Reproduce
Steps to reproduce the behavior:

  1. Compile the below sample code
  2. Download the sample image file
  3. Run the code with the sample file
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Example code
InputStream inputStream = null;
BufferedImage bufferedImage = null;
try {
URI uri = URI.create(imageUrl);
URL url = uri.toURL();
inputStream = url.openStream();
if (isImage) {
bufferedImage = ImageIO.read(inputStream);
if (bufferedImage == null) {
throw new IOException("read image fail");
}
ImageIO.write(bufferedImage, "jpeg", response.getOutputStream());
}else {
IoUtil.copy(inputStream, response.getOutputStream());
}
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
response.setHeader("Content-Disposition",
"attachment; filename=a.jpeg" );
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
} catch (Exception exception) {
log.error("handle image fail", exception);
} finally {
IoUtil.close(inputStream);
}

@haraldk
Copy link
Owner

haraldk commented Jan 13, 2025

Hi @biubiue

I can't reproduce, as your code isn't complete, and there is no test file included. But I believe this is a known issue (duplicate of #730).

@haraldk
Copy link
Owner

haraldk commented Jan 15, 2025

Closing for now. If you have further details on #730 you can comment there. Or if you think this is a separate issue, reopen and add sample files and further details.

@haraldk haraldk closed this as completed Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants