Merge pull request #623 from letterbomber/master
add ability to skip broken imagemagick on shared hosting
This commit is contained in:
commit
f08626fd70
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
function photo_factory($data, $type = null) {
|
function photo_factory($data, $type = null) {
|
||||||
$ph = null;
|
$ph = null;
|
||||||
|
$ignore_imagick = get_config('system', 'ignore_imagick');
|
||||||
if(class_exists('Imagick')) {
|
if(class_exists('Imagick') && !$ignore_imagick) {
|
||||||
|
logger('photo_factory: using Imagick', LOGGER_DEBUG);
|
||||||
require_once('include/photo/photo_imagick.php');
|
require_once('include/photo/photo_imagick.php');
|
||||||
$ph = new photo_imagick($data,$type);
|
$ph = new photo_imagick($data,$type);
|
||||||
}
|
}
|
||||||
@ -480,11 +481,11 @@ abstract class photo_driver {
|
|||||||
* Guess image mimetype from filename or from Content-Type header
|
* Guess image mimetype from filename or from Content-Type header
|
||||||
*
|
*
|
||||||
* @arg $filename string Image filename
|
* @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 = '') {
|
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;
|
$type = null;
|
||||||
if ($headers) {
|
if ($headers) {
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
@ -494,13 +495,16 @@ function guess_image_type($filename, $headers = '') {
|
|||||||
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
|
list($k,$v) = array_map("trim", explode(":", trim($l), 2));
|
||||||
$hdrs[$k] = $v;
|
$hdrs[$k] = $v;
|
||||||
}
|
}
|
||||||
|
logger('Curl headers: '.var_export($hdrs, true), LOGGER_DEBUG);
|
||||||
if (array_key_exists('Content-Type', $hdrs))
|
if (array_key_exists('Content-Type', $hdrs))
|
||||||
$type = $hdrs['Content-Type'];
|
$type = $hdrs['Content-Type'];
|
||||||
}
|
}
|
||||||
if (is_null($type)){
|
if (is_null($type)){
|
||||||
// FIXME!!!!
|
// FIXME!!!!
|
||||||
|
$ignore_imagick = get_config('system', 'ignore_imagick');
|
||||||
// Guessing from extension? Isn't that... dangerous?
|
// 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,
|
* Well, this not much better,
|
||||||
* but at least it comes from the data inside the image,
|
* 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) {
|
if($photo) {
|
||||||
$filename = basename($photo);
|
$filename = basename($photo);
|
||||||
$type = guess_image_type($photo,true);
|
$type = guess_image_type($photo);
|
||||||
|
|
||||||
if(! $type)
|
if(! $type)
|
||||||
$type = 'image/jpeg';
|
$type = 'image/jpeg';
|
||||||
|
Reference in New Issue
Block a user