1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.onehippo.forge.gallerymagick.core.command;
17
18 import java.io.File;
19
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 abstract public class AbstractImageMagickCommandTest extends AbstractMagickCommandTest {
24
25 private static Logger log = LoggerFactory.getLogger(AbstractImageMagickCommandTest.class);
26
27 private static boolean _convertCommandAvailable;
28
29 static {
30 final String executableFromSysProp = ImageMagickCommand.getExecutableFromSystemProperty("convert");
31
32 if (executableFromSysProp != null) {
33 _convertCommandAvailable = new File(executableFromSysProp).exists();
34 } else {
35 if (!_convertCommandAvailable && new File("/bin/convert").isFile()) {
36 _convertCommandAvailable = true;
37 }
38 if (!_convertCommandAvailable && new File("/usr/bin/convert").isFile()) {
39 _convertCommandAvailable = true;
40 }
41 if (!_convertCommandAvailable && new File("/usr/local/bin/convert").isFile()) {
42 _convertCommandAvailable = true;
43 }
44 if (!_convertCommandAvailable && new File("/opt/local/bin/convert").isFile()) {
45 _convertCommandAvailable = true;
46 }
47 }
48 }
49
50 protected static boolean isImageMagickAvailable() {
51 if (_convertCommandAvailable) {
52 return true;
53 }
54
55 log.warn("Image Magick convert command not found.");
56 return false;
57 }
58 }