Skip to content

Commit

Permalink
Solve minor comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andru Stefanescu <als209@cam.ac.uk>
  • Loading branch information
andru47 committed Aug 16, 2021
1 parent da9e7d9 commit 2cca80c
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private void writeThumbnailForSVG(File initialSVG, File thumbnailSVG) {

Dimension getImageDimension(byte[] givenImage) {
Dimension dimension = new Dimension();
try (ByteArrayInputStream bais = new ByteArrayInputStream(givenImage)) {
BufferedImage image = ImageIO.read(bais);
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(givenImage)) {
BufferedImage image = ImageIO.read(inputStream);
dimension.height = image.getHeight();
dimension.width = image.getWidth();
} catch (IOException e) {
Expand Down Expand Up @@ -241,13 +241,13 @@ String getPNGFromSVG(File givenSVG) {
TranscoderInput transcoderInput = new TranscoderInput();
TranscoderOutput transcoderOutput = new TranscoderOutput();

try (FileInputStream fis = new FileInputStream(givenSVG);
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
transcoderInput.setInputStream(fis);
transcoderOutput.setOutputStream(baos);
try (FileInputStream inputStream = new FileInputStream(givenSVG);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
transcoderInput.setInputStream(inputStream);
transcoderOutput.setOutputStream(outputStream);

transcoder.transcode(transcoderInput, transcoderOutput);
return BaseEncoding.base64().encode(baos.toByteArray());
return BaseEncoding.base64().encode(outputStream.toByteArray());
} catch (FileNotFoundException e) {
log.error("Error while reading the initial svg file.");
} catch (IOException e) {
Expand Down

0 comments on commit 2cca80c

Please sign in to comment.