diff options
author | nostupidzone <letterbomber@nomail.nostupid.zone> | 2014-10-07 09:54:27 -0700 |
---|---|---|
committer | nostupidzone <letterbomber@nomail.nostupid.zone> | 2014-10-07 09:54:27 -0700 |
commit | 60a89670f64c372122a154b0e5b601fed7d6bcbd (patch) | |
tree | 6f1d5191295148bbcd3d81eb57564143355a566b /include | |
parent | 21eae4df9c45d836c50bae79b251597968f43967 (diff) | |
download | volse-hubzilla-60a89670f64c372122a154b0e5b601fed7d6bcbd.tar.gz volse-hubzilla-60a89670f64c372122a154b0e5b601fed7d6bcbd.tar.bz2 volse-hubzilla-60a89670f64c372122a154b0e5b601fed7d6bcbd.zip |
add ability to skip broken imagemagick on shared hosting
Diffstat (limited to 'include')
-rw-r--r-- | include/photo/photo_driver.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index d9777b1c4..e8afac119 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -2,8 +2,9 @@ function photo_factory($data, $type = null) { $ph = null; - - if(class_exists('Imagick')) { + $ignore_imagick = get_config('system', 'ignore_imagick'); + if(class_exists('Imagick') && !$ignore_imagick) { + logger('photo_factory: using Imagick', LOGGER_DEBUG); require_once('include/photo/photo_imagick.php'); $ph = new photo_imagick($data,$type); } @@ -480,11 +481,11 @@ abstract class photo_driver { * Guess image mimetype from filename or from Content-Type header * * @arg $filename string Image filename - * @arg $fromcurl boolean Check Content-Type header from curl request + * @arg $headers string Headers to check for Content-Type (from curl request) */ function guess_image_type($filename, $headers = '') { - logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG); + logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG); $type = null; if ($headers) { $a = get_app(); @@ -494,13 +495,16 @@ function guess_image_type($filename, $headers = '') { list($k,$v) = array_map("trim", explode(":", trim($l), 2)); $hdrs[$k] = $v; } + logger('Curl headers: '.var_export($hdrs, true), LOGGER_DEBUG); if (array_key_exists('Content-Type', $hdrs)) $type = $hdrs['Content-Type']; } if (is_null($type)){ // FIXME!!!! + $ignore_imagick = get_config('system', 'ignore_imagick'); // Guessing from extension? Isn't that... dangerous? - if(class_exists('Imagick') && file_exists($filename) && is_readable($filename)) { + if(class_exists('Imagick') && !$ignore_imagick) { + logger('using imagemagick', LOGGER_DEBUG); /** * Well, this not much better, * but at least it comes from the data inside the image, @@ -552,7 +556,7 @@ function import_profile_photo($photo,$xchan,$thing = false) { if($photo) { $filename = basename($photo); - $type = guess_image_type($photo,true); + $type = guess_image_type($photo); if(! $type) $type = 'image/jpeg'; |