Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nette\Utils\Image::resize alpha broken (black background) #202

Closed
josefsabl opened this issue Oct 7, 2019 · 3 comments
Closed

Nette\Utils\Image::resize alpha broken (black background) #202

josefsabl opened this issue Oct 7, 2019 · 3 comments

Comments

@josefsabl
Copy link

@josefsabl josefsabl commented Oct 7, 2019

Version:

GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.9.1
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 9 compatible
PNG Support enabled
libPNG Version 1.6.34
WBMP Support enabled
XPM Support enabled
libXpm Version 30512
XBM Support enabled
WebP Support enabled

But the same bug can be observed on a production machine with Ubuntu Linux:

GD Support enabled
GD headers Version 2.2.5
GD library Version 2.2.5
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.8.1
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 8
PNG Support enabled
libPNG Version 1.6.34
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
WebP Support enabled

Bug Description

This (czech language) looks to be an evergreen. I am able to reproduce it with the latest version of package with the EXACT flag and PNG type. However I am positive that I also saw this with WEBP (as I originally had the problem with WEBP and switched to PNG to fix it, it actually helped ! For some time though and now it appeared again!? WTF.)

Steps To Reproduce

\Nette\Utils\Image::fromFile(__DIR__ . '/input.png')
    ->resize(100, 100, \Nette\Utils\Image::EXACT)
    ->save(__DIR__ . '/output.png', null, \Nette\Utils\Image::PNG);

input - but also "not works" with other images so I guess it is not the problem with the file.

output

Expected Behavior

Image with transparency preserved.

Possible Solution

I traced the problem down to this line $this->image = imagecrop($this->image, $r);. Commenting it out fixes the alpha problem, but the image is not cropped, obviously :-)

@josefsabl

This comment has been minimized.

Copy link
Author

@josefsabl josefsabl commented Oct 7, 2019

I can confirm that this hack works. I am having this issue on Windows as well as in production on Linux Ubuntu.

@JanTvrdik

This comment has been minimized.

Copy link
Contributor

@JanTvrdik JanTvrdik commented Oct 7, 2019

What is you GD version and how is the GD installed (bundled / not-bundled)?

@josefsabl

This comment has been minimized.

Copy link
Author

@josefsabl josefsabl commented Oct 7, 2019

What is you GD version and how is the GD installed (bundled / not-bundled)?

I updated the initial post.

@dg dg closed this in 57a1ba9 Oct 21, 2019
dg added a commit that referenced this issue Oct 21, 2019
dg added a commit that referenced this issue Oct 21, 2019
dg added a commit that referenced this issue Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.