@Override @Nonnull public File pngFile(@Nonnull final BufferedImage rawImage, final File file) { @Nullable final BufferedImage stdImage = Util.maximumSize(rawImage, getMaxImageSize()); try { if (stdImage != rawImage) { @Nonnull final String rawName = file.getName().replace(".png", "_raw.png"); ImageIO.write(rawImage, "png", new File(file.getParent(), rawName)); } ImageIO.write(stdImage, "png", file); } catch (IOException e) { throw new RuntimeException(e); } return file; }
@Override @Nonnull public File pngFile(@Nonnull final BufferedImage rawImage, final File file) { @Nullable final BufferedImage stdImage = Util.maximumSize(rawImage, getMaxImageSize()); try { if (stdImage != rawImage) { @Nonnull final String rawName = file.getName().replace(".png", "_raw.png"); ImageIO.write(rawImage, "png", new File(file.getParent(), rawName)); } ImageIO.write(stdImage, "png", file); } catch (IOException e) { throw new RuntimeException(e); } return file; }
@Override @Nonnull public File jpgFile(@Nonnull final BufferedImage rawImage, final File file) { @Nullable final BufferedImage stdImage = Util.maximumSize(rawImage, getMaxImageSize()); if (stdImage != rawImage) { try { @Nonnull final String rawName = file.getName().replace(".jpg", "_raw.jpg"); ImageIO.write(rawImage, "jpg", new File(file.getParent(), rawName)); } catch (IOException e) { throw new RuntimeException(String.format("Error processing image with dims (%d,%d)", rawImage.getWidth(), rawImage.getHeight()), e); } } try { ImageIO.write(stdImage, "jpg", file); } catch (Throwable e) { log.warn(String.format("Error processing image with dims (%d,%d)", stdImage.getWidth(), stdImage.getHeight()), e); } return file; }
@Override @Nonnull public File jpgFile(@Nonnull final BufferedImage rawImage, final File file) { @Nullable final BufferedImage stdImage = Util.maximumSize(rawImage, getMaxImageSize()); if (stdImage != rawImage) { try { @Nonnull final String rawName = file.getName().replace(".jpg", "_raw.jpg"); ImageIO.write(rawImage, "jpg", new File(file.getParent(), rawName)); } catch (IOException e) { throw new RuntimeException(String.format("Error processing image with dims (%d,%d)", rawImage.getWidth(), rawImage.getHeight()), e); } } try { ImageIO.write(stdImage, "jpg", file); } catch (Throwable e) { log.warn(String.format("Error processing image with dims (%d,%d)", stdImage.getWidth(), stdImage.getHeight()), e); } return file; }