6

I'm currently using intervention/image to resize images and save them as JPG.

I have the same code running locally in Windows and remotely in Ubuntu 20.20.

In Windows it does the conversion PNG to JPG converting the transparent background into white. However, in Ubuntu, is adding black noise on top of the white background.

The code I run is:

$resize = Image::make($img)->encode('jpg');
$resize->height() > $resize->width() ? $width = null : $height = null;
$resize->resize($width, $height, function ($constraint) {
    $constraint->aspectRatio();
});

Should I add something else before the encode in order to ensure that the transparency makes white?

enter image description here

Inigo EC
  • 2,178
  • 3
  • 22
  • 31

1 Answers1

-1

From: image.intervention.io/getting_started/configuration

Memory Settings
Image manipulation in PHP is a very memory consuming task. Since most tasks in PHP don't exhaust default memory limits, you have to make sure your PHP configuration is able to allocate enough memory to handle large images.
The following php.ini directives are important.

memory_limit
Sets a maximum amount of memory in bytes that a script is allowed to allocate. Resizing a 3000 x 2000 pixel image to 300 x 200 may take up to 32MB memory.

You may verify your php.ini for Ubuntu, also you way try to change the image library to gd or imagick.

loic.lopez
  • 2,013
  • 2
  • 21
  • 42