Skip to content

Commit

Permalink
2005-08-06 Pierre-Luc Paour <gallery@paour.com> (1.4.2-b24)
Browse files Browse the repository at this point in the history
	* GR can now find ImageMagick on its own on Windows, by looking in
	  the registry. Using a newer version of IM can speed up image
	  operations by a factor of 2! It is now recommended to
	  install IM independantly of GR to get this benefit.
	  This is all the more important for the applet.
  • Loading branch information
Pierre-Luc Paour committed Aug 6, 2005
1 parent 789f280 commit d2dd29f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2005-08-06 Pierre-Luc Paour <gallery@paour.com> (1.4.2-b24)

* GR can now find ImageMagick on its own on Windows, by looking in
the registry. Using a newer version of IM can speed up image
operations by a factor of 2! It is now recommended to
install IM independantly of GR to get this benefit.
This is all the more important for the applet.

2005-07-30 Pierre-Luc Paour <gallery@paour.com> (1.4.2-b23)

* Now using the new format for the remote controller URL in G2.
Expand Down
45 changes: 39 additions & 6 deletions com/gallery/GalleryRemote/util/ImageUtils.java
Expand Up @@ -41,6 +41,8 @@
import java.net.URLConnection;
import java.util.*;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
Expand Down Expand Up @@ -617,7 +619,7 @@ public static LocalInfo getLocalFilenameForPicture(Picture p, boolean full) {
URL u = null;
Dimension d = null;

if (full == false && p.getSizeResized() == null) {
if (!full && p.getSizeResized() == null) {
// no resized version
return null;
}
Expand Down Expand Up @@ -854,7 +856,27 @@ public static Dimension getPictureDimension(Picture p) {
imIgnoreErrorCode = p.getBooleanProperty("im.ignoreErrorCode", imIgnoreErrorCode);
Log.log(Log.LEVEL_INFO, MODULE, "imIgnoreErrorCode: " + imIgnoreErrorCode);

if (imPath.indexOf("/") == -1 && imPath.indexOf("\\") == -1) {
if (imPath.indexOf('/') == -1 && imPath.indexOf('\\') == -1
&& System.getProperty("os.name").toLowerCase().indexOf("windows") != -1) {
// we're on Windows with an abbreviated path: look up IM in the registry
StringBuffer output = new StringBuffer();
exec("reg query HKLM\\Software\\ImageMagick\\Current /v BinPath", output);

Pattern pat = Pattern.compile("^\\s*BinPath\\s*REG_SZ\\s*(.*)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
//Pattern pat = Pattern.compile("BinPath", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
Matcher m = pat.matcher(output.toString());
if (m.find()) {
imPath = m.group(1) + "\\" + imPath;

if (!imPath.endsWith(".exe")) {
imPath += ".exe";
}

Log.log(Log.LEVEL_INFO, MODULE, "Found ImageMagick in registry. imPath is now " + imPath);
}
}

if (imPath.indexOf('/') == -1 && imPath.indexOf('\\') == -1) {
Log.log(Log.LEVEL_CRITICAL, MODULE, "ImageMagick path is not fully qualified, " +
"presence won't be tested until later");
} else if (!new File(imPath).exists()) {
Expand Down Expand Up @@ -915,7 +937,7 @@ public static Dimension getPictureDimension(Picture p) {
jpegtranIgnoreErrorCode = p.getBooleanProperty("jp.ignoreErrorCode", jpegtranIgnoreErrorCode);
Log.log(Log.LEVEL_INFO, MODULE, "jpegtranIgnoreErrorCode: " + jpegtranIgnoreErrorCode);

if (jpegtranPath.indexOf("/") == -1 && jpegtranPath.indexOf("\\") == -1) {
if (jpegtranPath.indexOf('/') == -1 && jpegtranPath.indexOf('\\') == -1) {
Log.log(Log.LEVEL_CRITICAL, MODULE, "jpegtran path is not fully qualified, " +
"presence won't be tested until later");
}
Expand Down Expand Up @@ -1094,12 +1116,16 @@ public static java.util.List listFilesRecursive(File dir)
}

public static int exec(String cmdline) {
return exec(cmdline, null);
}

public static int exec(String cmdline, StringBuffer output) {
Log.log(Log.LEVEL_TRACE, MODULE, "Executing " + cmdline);

try {
Process p = Runtime.getRuntime().exec(cmdline);

return pumpExec(p);
return pumpExec(p, output);
} catch (InterruptedException e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
return -1;
Expand All @@ -1111,12 +1137,16 @@ public static int exec(String cmdline) {
}

public static int exec(String[] cmd) {
return exec(cmd, null);
}

public static int exec(String[] cmd, StringBuffer output) {
Log.log(Log.LEVEL_TRACE, MODULE, "Executing " + Arrays.asList(cmd));

try {
Process p = Runtime.getRuntime().exec(cmd);

return pumpExec(p);
return pumpExec(p, output);
} catch (InterruptedException e) {
Log.logException(Log.LEVEL_ERROR, MODULE, e);
return -1;
Expand All @@ -1127,7 +1157,7 @@ public static int exec(String[] cmd) {
return 1;
}

private static int pumpExec(Process p) throws InterruptedException, IOException {
private static int pumpExec(Process p, StringBuffer output) throws InterruptedException, IOException {
DataInputStream out = new DataInputStream(new BufferedInputStream(p.getInputStream()));
DataInputStream err = new DataInputStream(new BufferedInputStream(p.getErrorStream()));

Expand All @@ -1136,6 +1166,9 @@ private static int pumpExec(Process p) throws InterruptedException, IOException
String line = null;
while ((line = out.readLine()) != null) {
Log.log(Log.LEVEL_TRACE, MODULE, "Out: " + line);
if (output != null) {
output.append(line).append("\n");
}
}

while ((line = err.readLine()) != null) {
Expand Down
4 changes: 2 additions & 2 deletions defaults.properties
Expand Up @@ -245,6 +245,6 @@ updateUrlBeta=http://gallery.sourceforge.net/gallery_remote_version_check_beta.p
#
# --- Do not edit below this line ---
#
version=1.4.2-b23
releaseDate=2005/07/30
version=1.4.2-b24
releaseDate=2005/08/06
aboutText=Gallery Remote\n \n \nA part of the Gallery Open-Source Project\nhttp://gallery.sourceforge.net\n \n \nMaintained by:\n \nPierre-Luc Paour\n \n \nInitial version by Chris Smith\n \n \nContributors:\n \nTim Miller\nDolan Halbrook\nMarkus Cozowicz\nScott Gartner\nAmedeo Paglione\nChris Schwerdt\nSeth Ladd\n \n \nArtwork by Ross A. Reyman\n \n \nBundled software:\n \nImageMagick\nJava look and feel Graphics Repository icons\njpegtran, Guido Vollbeding's version\nMetadataExtractor
2 changes: 1 addition & 1 deletion imagemagick/im.properties.applet
Expand Up @@ -42,7 +42,7 @@ im.thumbnailResizeFormat=gif
im.previewResizeFormat=jpg

# jpeg quality
im.jpegQuality=80
im.jpegQuality=90

# ignore error code sent back by the executable
# there's a bug in the Linux Java VM that returns a failed code
Expand Down

0 comments on commit d2dd29f

Please sign in to comment.