dspace-api: comment ImageMagick filters

Add some comments to document the functionality of the ImageMagick
thumbnail filters. This will help others understand it later when
we need to re-factor them.
This commit is contained in:
Alan Orth
2023-05-18 09:47:06 +03:00
parent a4105bdcb0
commit 7ebb5290fc
2 changed files with 9 additions and 0 deletions

View File

@@ -22,7 +22,9 @@ public class ImageMagickPdfThumbnailFilter extends ImageMagickThumbnailFilter {
File f2 = null; File f2 = null;
File f3 = null; File f3 = null;
try { try {
// Step 1: get an image from our PDF file, with PDF-specific processing options
f2 = getImageFile(f, verbose); f2 = getImageFile(f, verbose);
// Step 2: use the image above to create the final resized and rotated thumbnail
f3 = getThumbnailFile(f2, verbose); f3 = getThumbnailFile(f2, verbose);
byte[] bytes = Files.readAllBytes(f3.toPath()); byte[] bytes = Files.readAllBytes(f3.toPath());
return new ByteArrayInputStream(bytes); return new ByteArrayInputStream(bytes);

View File

@@ -116,6 +116,13 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
return f2; return f2;
} }
/**
* Return an image from a bitstream with specific processing options for
* PDFs. This is only used by ImageMagickPdfThumbnailFilter in order to
* generate an intermediate image file for use with getThumbnailFile. It
* is unfortunate that this means we convert from PDF to JPEG to JPEG,
* which incurs generation loss.
*/
public File getImageFile(File f, boolean verbose) public File getImageFile(File f, boolean verbose)
throws IOException, InterruptedException, IM4JavaException { throws IOException, InterruptedException, IM4JavaException {
File f2 = new File(f.getParentFile(), f.getName() + ".jpg"); File f2 = new File(f.getParentFile(), f.getName() + ".jpg");