aimeos / aimeos-laravel

Laravel ecommerce package for ultra fast online shops, scalable marketplaces, complex B2B applications and #gigacommerce
https://aimeos.org/Laravel
MIT License
7.26k stars 1.05k forks source link

Unable to scale image #415

Closed parsester closed 3 years ago

parsester commented 3 years ago

Environment

  1. Version 2021.07
  2. OS: Linux CentOS 7
  3. Web Server: NGINX 1.20
  4. Laravel v8.53.1 (PHP v8.0.11)

Describe the bug I try to add image media to the product and get error saving data and when check logs, i have "Unable to scale image" error.

why this happen?

this is full error: trace.txt

2021-10-11_18-08-58

aimeos commented 3 years ago

Seems like a GD problem, check here: https://github.com/aimeos/aimeos-core/blob/2021.04/lib/mwlib/src/MW/Media/Image/Standard.php#L231-L233

parsester commented 3 years ago

GD problem

ok, but php-gd-8.0.11 installed, what is this problem and what can I do?

aimeos commented 3 years ago

You have to find out why imagescale() returns an error. Maybe the image type isn't supported

parsester commented 3 years ago

You have to find out why imagescale() returns an error. Maybe the image type isn't supported

image type is jpg

when I remove IMG_BICUBIC mode from imagescale like as the below, it's correct and save image. if( ( $result = imagescale( $this->image, $scaleWidth, $scaleHeight ) )...

what can I do?

aimeos commented 3 years ago

The IMG_BICUBIC constant is supported by PHP: https://www.php.net/manual/en/function.imagescale.php Maybe it's not supported by our underlying GD installation.

You can try to install Imagick PHP extension in addition so this is used for scaling.

parsester commented 3 years ago

The IMG_BICUBIC constant is supported by PHP: https://www.php.net/manual/en/function.imagescale.php Maybe it's not supported by our underlying GD installation.

You can try to install Imagick PHP extension in addition so this is used for scaling.

I use PHP 8.0.11 by xampp in local development system, and everything is ok and images scale success. so I check phpinfo in both (local and server) and find that in local result is GD Version | bundled (2.1.0 compatible) and in server result is GD library Version | 2.3.3

another difference is in local webserver is apache and in server use nginx with php-fpm

Could this be the reason?

is necessary to use IMG_BICUBIC mode for imagescale?

parsester commented 3 years ago

also in during time to waiting for your answer, I downgrade php version of my server to php 7.4 but anything not change and still I get error from imagescale... after downgrade and install php 7.4, GD version still is 2.3.3 and not change. GD is more common and is installed on most hosts and is better to use it for projects instead of Imagick. if is not necessary to use IMG_BICUBIC and default mode IMG_BILINEAR_FIXED is work, please change it, and also please check aimeos yourself to sure work with GD version 2.3.3...

aimeos commented 3 years ago

GD is our fallback if Imagick isn't available, even if Imagick is preferrable because it doesn't have problems wen scaling images with transparent backgrounds. Thus, it's good if using most compatible settings for GD and we removed the mode from imagescale() now. The change is available in dev-master and 2021.10.x-dev.

parsester commented 3 years ago

GD is our fallback if Imagick isn't available, even if Imagick is preferrable because it doesn't have problems wen scaling images with transparent backgrounds. Thus, it's good if using most compatible settings for GD and we removed the mode from imagescale() now. The change is available in dev-master and 2021.10.x-dev.

thanks @aimeos please check https://github.com/aimeos/aimeos-core/blob/2021.10/lib/mwlib/src/MW/Media/Image/Standard.php#L286-L288

you remove IMG_BICUBIC from resize method but still IMG_BICUBIC has been used in watermark method. and return same error. please remove it from this line.

aimeos commented 3 years ago

Thanks for the hint. Now, this occurence has been remove too