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 AbstractGraphicsMagickCommandTest extends AbstractMagickCommandTest {
24
25 private static Logger log = LoggerFactory.getLogger(AbstractGraphicsMagickCommandTest.class);
26
27 private static boolean _gmCommandAvailable;
28
29 static {
30 final String executableFromSysProp = GraphicsMagickCommand.getExecutableFromSystemProperty();
31
32 if (executableFromSysProp != null) {
33 _gmCommandAvailable = new File(executableFromSysProp).exists();
34 } else {
35 if (!_gmCommandAvailable && new File("/bin/gm").isFile()) {
36 _gmCommandAvailable = true;
37 }
38 if (!_gmCommandAvailable && new File("/usr/bin/gm").isFile()) {
39 _gmCommandAvailable = true;
40 }
41 if (!_gmCommandAvailable && new File("/usr/local/bin/gm").isFile()) {
42 _gmCommandAvailable = true;
43 }
44 if (!_gmCommandAvailable && new File("/opt/local/bin/gm").isFile()) {
45 _gmCommandAvailable = true;
46 }
47 }
48 }
49
50 protected static boolean isGraphicsMagickAvailable() {
51 if (_gmCommandAvailable) {
52 return true;
53 }
54
55 log.warn("Graphics Magick command not found.");
56 return false;
57 }
58 }