Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into 3.1-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
NielBuys committed May 10, 2024
2 parents 372475e + 757829f commit 06399d2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
1 change: 1 addition & 0 deletions application/config/mimes.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
'mj2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'mjp2' => array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
'png' => array('image/png', 'image/x-png'),
'webp' => 'image/webp',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'heic' => 'image/heic',
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"require": {
"php": ">=7.4"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
},
"scripts": {
"test:coverage": [
"@putenv XDEBUG_MODE=coverage",
Expand Down
1 change: 1 addition & 0 deletions system/language/english/imglib_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
$lang['imglib_gif_not_supported'] = 'GIF images are often not supported due to licensing restrictions. You may have to use JPG or PNG images instead.';
$lang['imglib_jpg_not_supported'] = 'JPG images are not supported.';
$lang['imglib_png_not_supported'] = 'PNG images are not supported.';
$lang['imglib_webp_not_supported'] = 'WEBP images are not supported.';
$lang['imglib_jpg_or_png_required'] = 'The image resize protocol specified in your preferences only works with JPEG or PNG image types.';
$lang['imglib_copy_error'] = 'An error was encountered while attempting to replace the file. Please make sure your file directory is writable.';
$lang['imglib_rotate_unsupported'] = 'Image rotation does not appear to be supported by your server.';
Expand Down
28 changes: 27 additions & 1 deletion system/libraries/Image_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public function initialize($props = array())
else
{
// Is there a file name?
if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $this->new_image))
if ( ! preg_match('#\.(jpg|jpeg|gif|png|webp)$#i', $this->new_image))
{
$this->dest_image = $this->source_image;
$this->dest_folder = $this->new_image;
Expand Down Expand Up @@ -954,6 +954,10 @@ public function image_process_netpbm($action = 'resize')
$cmd_in = 'pngtopnm';
$cmd_out = 'ppmtopng';
break;
case 18 :
$cmd_in = 'webptopnm';
$cmd_out = 'ppmtowebp';
break;
}

if ($action === 'crop')
Expand Down Expand Up @@ -1480,6 +1484,13 @@ public function image_create_gd($path = '', $image_type = '')
}

return imagecreatefrompng($path);
case 18:
if ( ! function_exists('imagecreatefromwebp'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_webp_not_supported'));
return FALSE;
}
return imagecreatefromwebp($path);
default:
$this->set_error(array('imglib_unsupported_imagecreate'));
return FALSE;
Expand Down Expand Up @@ -1540,6 +1551,19 @@ public function image_save_gd($resource)
return FALSE;
}
break;
case 18:
if ( ! function_exists('imagewebp'))
{
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_webp_not_supported'));
return FALSE;
}

if ( ! @imagewebp($resource, $this->full_dst_path))
{
$this->set_error('imglib_save_failed');
return FALSE;
}
break;
default:
$this->set_error(array('imglib_unsupported_imagecreate'));
return FALSE;
Expand Down Expand Up @@ -1572,6 +1596,8 @@ public function image_display_gd($resource)
break;
case 3 : imagepng($resource);
break;
case 18 : imagewebp($resource);
break;
default: echo 'Unable to display the image';
break;
}
Expand Down

0 comments on commit 06399d2

Please sign in to comment.