Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
wfpl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
23c6415
)
refactored path_to_convert
author
Jason Woofenden
<jason183@herkamire.com>
Mon, 24 Sep 2007 04:48:59 +0000
(
00:48
-0400)
committer
Jason Woofenden
<jason183@herkamire.com>
Mon, 24 Sep 2007 04:48:59 +0000
(
00:48
-0400)
upload.php
patch
|
blob
|
history
diff --git
a/upload.php
b/upload.php
index
46f8b3c
..
05e1866
100644
(file)
--- a/
upload.php
+++ b/
upload.php
@@
-164,23
+164,23
@@
function save_uploaded_file($key, $path) {
function path_to_convert() {
if(!isset($GLOBALS['path_to_convert'])) {
function path_to_convert() {
if(!isset($GLOBALS['path_to_convert'])) {
- $convert = '/usr/local/bin/convert';
- if(!file_exists($convert)) {
- $convert = '/usr/bin/convert';
- }
- if(!file_exists($convert)) {
- $convert = `which convert`;
- }
- if($convert == '' || !file_exists($convert)) {
- die("can't find imagemagick's 'convert' program");
- }
-
- $GLOBALS['path_to_convert'] = $convert;
+ $GLOBALS['path_to_convert'] = _path_to_convert();
}
return $GLOBALS['path_to_convert'];
}
}
return $GLOBALS['path_to_convert'];
}
-
+
+function _path_to_convert() {
+ # relies on PHP's short-circuit mechanism
+ if(file_exists($convert = '/usr/local/bin/convert') ||
+ file_exists($convert = '/usr/bin/convert') ||
+ ($convert = `which convert` != '' && file_exists($convert))) {
+ return $convert;
+ } else {
+ die("can't find imagemagick's 'convert' program");
+ }
+}
+
# returns new filename with .png extension
function gif_to_png($filename, $new_filename = 'just change extension') {
# returns new filename with .png extension
function gif_to_png($filename, $new_filename = 'just change extension') {