Skip to content

Commit e0d145a

Browse files
authored
Merge pull request #60 from FredPraca/fix/ram-use
Fix image generation on Word documents
2 parents d58cb5d + b760939 commit e0d145a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/main/java/io/github/makbn/jthumbnail/core/thumbnailers/MPEGThumbnailer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public String[] getAcceptedMIMETypes() {
9696
};
9797
}
9898

99-
@SuppressWarnings("Duplicates")
10099
private BufferedImage getScaledBI(BufferedImage org) {
101100
Image tmp = org.getScaledInstance(thumbWidth, thumbHeight, Image.SCALE_SMOOTH);
102101
BufferedImage scaleBI = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_ARGB);

src/main/java/io/github/makbn/jthumbnail/core/thumbnailers/WordConverterThumbnailer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.spire.doc.Document;
1212
import com.spire.doc.documents.ImageType;
1313

14-
import java.awt.image.BufferedImage;
1514
import java.io.File;
1615
import java.io.IOException;
1716

@@ -48,12 +47,12 @@ public void generateThumbnail(File input, File output) throws ThumbnailException
4847

4948
log.trace("Document loaded, saving all pages to images");
5049

51-
// Convert the whole document into individual buffered images
52-
BufferedImage[] pages = doc.saveToImages(ImageType.Bitmap);
50+
// Convert the first page as image
51+
var firstPage = doc.saveToImages(0, ImageType.Bitmap);
5352

5453
log.trace("Pages saved, getting first page and scaling for thumbnail");
5554
ResizeImage resizer = new ResizeImage(thumbWidth, thumbHeight);
56-
resizer.setInputImage(pages[0]);
55+
resizer.setInputImage(firstPage);
5756

5857
log.debug("Writing {} thumbnail to {}", input.getName(), output.getAbsolutePath());
5958
resizer.writeOutput(output, FilenameUtils.getExtension(output.getName()));
@@ -66,6 +65,7 @@ public void generateThumbnail(File input, File output) throws ThumbnailException
6665
throw new ThumbnailException(e);
6766
} finally {
6867
doc.close();
68+
doc.dispose();
6969
}
7070
}
7171

0 commit comments

Comments
 (0)