Repository navigation
Fix the documented range of the background filter transparency - #1667
Merged
Merged
Conversation
…ency The documentation had the range the wrong way round: 0 is the transparent end and 100 the opaque one, and omitting the option leaves the background opaque. The option is handed straight to the palette as the alpha of the background color, so the semantics are Imagine's. The filter had no test, so the direction is pinned by one now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@dbu you asked on #1654 whether the behaviour is the same across the Imagine drivers, since that decides between fixing the documentation and fixing the code. It is the same, so this fixes the documentation.
The reporter is right:
0is the transparent end and100the opaque one, the opposite of what the page says. Omitting the option leaves the background opaque.Measured on GD, running the filter and reading the alpha of a background pixel:
transparencyAnd the three drivers agree on the direction, since
BackgroundFilterLoaderhands the option straight topalette()->color($color, $alpha)and the semantics are Imagine's from there on:imagecolorallocatealpha(..., round(127 * (100 - $color->getAlpha()) / 100)), and GD's own alpha runs from 0 (opaque) to 127, so an alpha of 100 comes out opaque.$pixel->setColorValue(\Imagick::COLOR_ALPHA, $color->getAlpha() / 100), where the ImageMagick alpha channel is 1.0 for opaque.alpha transparency is not supportedfor a value below 100 on a palette without alpha, so 100 is the opaque end there too.So the value is an alpha, which reads as an opacity, despite the option being called
transparency. I said as much on the page rather than only flipping the two words, since the name will keep surprising people.The filter had no test at all, so the direction is pinned by one now. It uses the real GD driver, like
GrayscaleFilterLoaderTestand the twoFloatToIntCast...tests already do.One thing I could not check and would rather not write into the documentation:
Gmagick\Imagine::create()builds the canvas with$pixel->getcolor(false), without the alpha component, and only then callssetimagebackgroundcolor()with the full pixel. I do not have the extension to tell whether a partially transparent background actually comes out of it. If it does not, that is worth a note on the page, and you or someone with gmagick would know in a second.