mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
Merge branch 'dev' of ../p3 into dev
This commit is contained in:
commit
093b6ca73d
4 changed files with 22 additions and 4 deletions
|
@ -36,12 +36,16 @@ class PhotoGd extends PhotoDriver {
|
|||
}
|
||||
|
||||
$this->image = @imagecreatefromstring($data);
|
||||
|
||||
if ($this->image !== false) {
|
||||
$this->valid = true;
|
||||
$this->setDimensions();
|
||||
imagealphablending($this->image, false);
|
||||
imagesavealpha($this->image, true);
|
||||
}
|
||||
else {
|
||||
logger('image load failed');
|
||||
}
|
||||
}
|
||||
|
||||
protected function setDimensions() {
|
||||
|
@ -164,7 +168,7 @@ class PhotoGd extends PhotoDriver {
|
|||
|
||||
switch ($this->getType()){
|
||||
case 'image/webp':
|
||||
|
||||
|
||||
\imagewebp($this->image);
|
||||
break;
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ class PhotoImagick extends PhotoDriver {
|
|||
try {
|
||||
$this->image->readImageBlob($data);
|
||||
} catch(Exception $e) {
|
||||
logger('Imagick readImageBlob() exception:' . print_r($e, true));
|
||||
logger('Imagick read failed');
|
||||
// logger('Imagick readImageBlob() exception:' . print_r($e, true));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ function z_mime_content_type($filename) {
|
|||
'jpg' => 'image/jpeg',
|
||||
'gif' => 'image/gif',
|
||||
'bmp' => 'image/bmp',
|
||||
'webp' => 'image/webp',
|
||||
'ico' => 'image/vnd.microsoft.icon',
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
|
@ -628,7 +629,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
|||
$is_photo = 0;
|
||||
$gis = @getimagesize($src);
|
||||
logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA);
|
||||
if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
|
||||
if(($gis) && in_array($gis[2], [ IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_WEBP ])) {
|
||||
$is_photo = 1;
|
||||
if($gis[2] === IMAGETYPE_GIF)
|
||||
$def_extension = '.gif';
|
||||
|
@ -636,6 +637,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
|||
$def_extension = '.jpg';
|
||||
if($gis[2] === IMAGETYPE_PNG)
|
||||
$def_extension = '.png';
|
||||
if($gis[2] === IMAGETYPE_WEBP)
|
||||
$def_extension = '.webp';
|
||||
}
|
||||
|
||||
// If we know it's a photo, over-ride the type in case the source system could not determine what it was
|
||||
|
|
|
@ -34,10 +34,20 @@ function photo_factory($data, $type = null) {
|
|||
return null;
|
||||
}
|
||||
|
||||
$ignore_imagick = get_config('system', 'ignore_imagick');
|
||||
|
||||
$ignore_imagick = get_config('system','ignore_imagick');
|
||||
|
||||
if (class_exists('Imagick') && !$ignore_imagick) {
|
||||
$ph = new PhotoImagick($data, $type);
|
||||
|
||||
// As of August 2020, webp support is still poor in both imagick and gd. Both claim to support it,
|
||||
// but both may require additional configuration. If it's a webp and the imagick driver failed,
|
||||
// we'll try again with GD just in case that one handles it. If not, you may need to install libwebp
|
||||
// which should make imagick work and/or re-compile php-gd with the option to include that library.
|
||||
|
||||
if (! $ph->is_valid() && $type === 'image/webp') {
|
||||
$ph = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $ph) {
|
||||
|
|
Loading…
Reference in a new issue