public static ImageIcon load(String filename, Dimension d, int usage, boolean ignoreFailure) { if (!new File(filename).exists()) { return null; }  ImageIcon r = null; long start = System.currentTimeMillis();  if (!GalleryFileFilter.canManipulate(filename)) { return unrecognizedThumbnail; }  if (useIM) { ArrayList cmd = new ArrayList(); cmd.add(imPath);  if (filterName[usage] != null && filterName[usage].length() > 0) {  cmd.add("-filter"); cmd.add(filterName[usage]); }  cmd.add(filename);  cmd.add("-resize"); if (GalleryRemote._().properties.getBooleanProperty(PreferenceNames.SLIDESHOW_NOSTRETCH)) { cmd.add(d.width + "x" + d.height + ">"); } else { cmd.add(d.width + "x" + d.height); }  cmd.add("+profile"); cmd.add("*");  File temp = deterministicTempFile("thumb", "." + format[usage], tmpDir, filename + d);  if (!temp.exists()) { toDelete.add(temp);  cmd.add(temp.getPath());  int exitValue = exec((String[]) cmd.toArray(new String[0]));  if ((exitValue != 0 && !imIgnoreErrorCode && !ignoreFailure) || ! temp.exists()) { if (exitValue != -1 || ! temp.exists()) {  Log.log(Log.LEVEL_CRITICAL, MODULE, "ImageMagick doesn't seem to be working. Disabling"); stopUsingIM(); } } else { r = new ImageIcon(temp.getPath()); } } else { r = new ImageIcon(temp.getPath()); } }  if (!useIM && r == null) { r = loadJava(filename, d, GalleryRemote._().properties.getBooleanProperty(PreferenceNames.SLIDESHOW_NOSTRETCH)); }  long time = System.currentTimeMillis() - start; totalTime += time; totalIter++; Log.log(Log.LEVEL_TRACE, MODULE, "Time: " + time + " - Avg: " + (totalTime / totalIter));  return r;
public static ImageIcon load(String filename, Dimension d, int usage) { return load(filename, d, usage, false);
	public static ImageIcon load(String filename, Dimension d, int usage, boolean ignoreFailure) {		if (!new File(filename).exists()) {			return null;		}		ImageIcon r = null;		long start = System.currentTimeMillis();		if (!GalleryFileFilter.canManipulate(filename)) {			return unrecognizedThumbnail;		}		if (useIM) {			ArrayList cmd = new ArrayList();			cmd.add(imPath);			if (filterName[usage] != null && filterName[usage].length() > 0) {				//cmdline.append(" -filter ").append(filterName[usage]);				cmd.add("-filter");				cmd.add(filterName[usage]);			}			cmd.add(filename);			cmd.add("-resize");			if (GalleryRemote._().properties.getBooleanProperty(PreferenceNames.SLIDESHOW_NOSTRETCH)) {				cmd.add(d.width + "x" + d.height + ">");			} else {				cmd.add(d.width + "x" + d.height);			}			cmd.add("+profile");			cmd.add("*");			File temp = deterministicTempFile("thumb", "." + format[usage], tmpDir, filename + d);			if (!temp.exists()) {				toDelete.add(temp);				cmd.add(temp.getPath());				int exitValue = exec((String[]) cmd.toArray(new String[0]));				if ((exitValue != 0 && !imIgnoreErrorCode && !ignoreFailure) || ! temp.exists()) {					if (exitValue != -1 || ! temp.exists()) {						// don't kill IM if it's just an InterruptedException						Log.log(Log.LEVEL_CRITICAL, MODULE, "ImageMagick doesn't seem to be working. Disabling");						stopUsingIM();					}				} else {					r = new ImageIcon(temp.getPath());				}			} else {				r = new ImageIcon(temp.getPath());			}		}		if (!useIM && r == null) {			r = loadJava(filename, d, GalleryRemote._().properties.getBooleanProperty(PreferenceNames.SLIDESHOW_NOSTRETCH));		}		long time = System.currentTimeMillis() - start;		totalTime += time;		totalIter++;		Log.log(Log.LEVEL_TRACE, MODULE, "Time: " + time + " - Avg: " + (totalTime / totalIter));		return r;	}