- Member | 6
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.
- 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)
- Is it somehow possible to keep the transparency when using imagecrop()?
- 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)
- Member | 6
so, have you found answers to your questions? maybe there's someone who can chime in? please update or answer anybody! thanks a lot in advance!
Hi, I got no answers to the original problem, so I guess the solution is to avoid Image::crop and using the “else branch” of it (https://api.nette.org/…age.php.html#393) instead.
I ended up not using crop directly anyway, because i needed 1) white instead of transparent background 2) the ability to create “cutouts” bigger than the original image (like a square containg the whole wide picture).
Last edited by redwormik (2018-07-31 22:19)
- Member | 184
I have the same problem with imagecrop() as you write, and I think the problem is with “not bundled” GD library. On my localhost with PHP 7.2 (with bundled GD) it works properly, but on production server with PHP 7.2 from deb.sury.org (with external GD) I got black color instead of transparent…