Nette\Utils\Image::crop – imagecrop() transparency issue

15 days ago

redwormik
Member | 5
+
0
-

Hello,

I have an issue with Nette\Utils\Image::crop and underlying imagecrop(). I was not able to preserve PNG transparency when using either of them. No solution I found online worked. When I crop “manually” (like in https://api.nette.org/…age.php.html#396), the transparency is preserved.

Configuration:

  • nette/utils v2.4.8
  • GD library Version 2.2.5, GD headers Version 2.2.3, libPNG Version 1.2.54
  • PHP 7.1.9 (7.1.9–1+ubuntu16.04.1+deb.sury.org+1)
  1. Is it somehow possible to keep the transparency when using imagecrop()?
  2. Should Nette\Utils\Image::crop preserve transparency (either with imagecrop or using the old version)? If yes, I would be happy to prepare a pull request.

EDIT: This issue is also related to using Nette\Utils\Image::resize with the EXACT flag as it creates and immediately crops the image (without a way to manipulate it before cropping).

Last edited by redwormik (2017-11-02 11:08)