Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

Fixed pdf2image conversion with imagemagick on PDFs having transparency

luccioman7c319c841e91
diff --git a/source/net/yacy/cora/util/Html2Image.java b/source/net/yacy/cora/util/Html2Image.java
index a8c96c84d..d3de36ade 100644
--- a/source/net/yacy/cora/util/Html2Image.java
+++ b/source/net/yacy/cora/util/Html2Image.java
@@ -168,7 +168,7 @@ public class Html2Image {
try {
// i.e. convert -density 300 -trim yacy.pdf[0] -trim -resize 1024x -crop x1024+0+0 -quality 75% yacy-convert-300.jpg
// note: both -trim are necessary, otherwise it is trimmed only on one side. The [0] selects the first page of the pdf
- String command = convert.getAbsolutePath() + " -density " + density + " -trim " + pdf.getAbsolutePath() + "[0] -trim -resize " + width + "x -crop x" + height + "+0+0 -quality " + quality + "% " + image.getAbsolutePath();
+ String command = convert.getAbsolutePath() + " -alpha remove -density " + density + " -trim " + pdf.getAbsolutePath() + "[0] -trim -resize " + width + "x -crop x" + height + "+0+0 -quality " + quality + "% " + image.getAbsolutePath();
List<String> message = OS.execSynchronous(command);
if (image.exists()) return true;
ConcurrentLog.warn("Html2Image", "failed to create image with command: " + command);
diff --git a/test/java/net/yacy/cora/util/Html2ImageTest.java b/test/java/net/yacy/cora/util/Html2ImageTest.java
index 7d994cd24..4274cd6df 100644
--- a/test/java/net/yacy/cora/util/Html2ImageTest.java
+++ b/test/java/net/yacy/cora/util/Html2ImageTest.java
@@ -26,7 +26,7 @@ public class Html2ImageTest {
public void testPdf2image() {
// collect pdf filenames in test directory
File pd = new File("test/parsertest");
- List<String> extensions = new ArrayList();
+ List<String> extensions = new ArrayList<>();
extensions.add("pdf");
FilenameFilter fileFilter = new ExtensionsFileFilter(extensions);
String[] pdffiles = pd.list(fileFilter);