aboutsummaryrefslogtreecommitdiffstats
path: root/include/photo
diff options
context:
space:
mode:
authorhabeascodice <habeascodice@federated.social>2014-10-07 16:13:22 -0700
committerhabeascodice <habeascodice@federated.social>2014-10-07 16:13:22 -0700
commitc01a9839577a5fc3a8965713e206616edc586c74 (patch)
treec9aa6cf42c2146bf5cee0a11a37ba6c93ef401d3 /include/photo
parent6b40c2cd090d1c406b3e1cd7ad135baff21bfd54 (diff)
parentd94f6f7c53fbb01a76a6d3beb14968d02ebb3afa (diff)
downloadvolse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.tar.gz
volse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.tar.bz2
volse-hubzilla-c01a9839577a5fc3a8965713e206616edc586c74.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include/photo')
-rw-r--r--include/photo/photo_driver.php32
1 files changed, 24 insertions, 8 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index d9777b1c4..42997060b 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -3,11 +3,24 @@
function photo_factory($data, $type = null) {
$ph = null;
- if(class_exists('Imagick')) {
- require_once('include/photo/photo_imagick.php');
- $ph = new photo_imagick($data,$type);
+ $ignore_imagick = get_config('system', 'ignore_imagick');
+
+ if(class_exists('Imagick') && !$ignore_imagick) {
+ $v = Imagick::getVersion();
+ preg_match('/ImageMagick ([0-9]+\.[0-9]+\.[0-9]+)/', $v['versionString'], $m);
+ if(version_compare($m[1],'6.6.7') >= 0) {
+ require_once('include/photo/photo_imagick.php');
+ $ph = new photo_imagick($data,$type);
+ }
+ else {
+ // earlier imagick versions have issues with scaling png's
+ // don't log this because it will just fill the logfile.
+ // leave this note here so those who are looking for why
+ // we aren't using imagick can find it
+ }
}
- else {
+
+ if(! $ph) {
require_once('include/photo/photo_gd.php');
$ph = new photo_gd($data,$type);
}
@@ -480,11 +493,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 +507,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 +568,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';