GraphicsMagick (gm) does not know the "-brightness-contrast" option (but imagemagick convert does).

Comments

kjauslin created an issue. See original summary.

mondrake’s picture

Category: Bug report » Feature request

Please see the README file for information of which effects are supported in GraphicsMagick.

This is not a bug but a feature request. Not sure if there's any option that can provide that in GraphicsMagick, though.

kjauslin’s picture

StatusFileSize
new1.06 KB

Attached a small patch using the '-level' argument. It's not entirely the same, but is working quite well as a first fix.

kjauslin’s picture

Oh yeah, sorry, I forgot to check. I implemented a first draft in the patch (since I need this functionality in a gm project). But I'm not sure it should maybe be a separate level filter.

mondrake’s picture

Status: Active » Needs work
Issue tags: +Needs tests

Thanks @kjauslin - can you update the tests, too? Actually the tests need to be run locally for ImageMagick/GraphicsMagick as the DrupalCI bots do not have graphics packages installed.

Not sure we need a separate effect for this if the results are comparable.

mondrake’s picture

+++ b/src/Plugin/ImageToolkit/Operation/imagemagick/Contrast.php
@@ -25,7 +25,18 @@ class Contrast extends ImagemagickImageToolkitOperationBase {
+      $toolkit = $this->getToolkit();
+

$toolkit is not used, so we do not need this line

kjauslin’s picture

StatusFileSize
new1.72 KB

I don't have testing setup right now, but adjusted the ContrastTest (and removed the $toolkit) - with a little bit of luck it might work ;-) Depends a little bit on how similar the level filter really is to brightness-contrast I think.

mondrake’s picture

Status: Needs work » Needs review
mondrake’s picture

Seems OK, running locally

$ sudo -u www-data ../vendor/bin/phpunit ../modules/image_effects/tests/src/Functional/Effect/ContrastTest.php --verbose

PHPUnit 4.8.35 by Sebastian Bergmann and contributors.

Runtime:        PHP 7.0.20-1~bpo8+1
Configuration:  /[...]/core/phpunit.xml

....

Time: 4.74 minutes, Memory: 4.00MB

OK (4 tests, 59 assertions)
mondrake’s picture

Title: Contrast filter not working with GraphicsMagick toolkit » Enable 'Contrast' effect to work with GraphicsMagick
Issue tags: -Needs tests

Will wait for more reviews/RTBC before committing this.

mondrake’s picture

StatusFileSize
new1.71 KB

Rerolled.

mondrake’s picture

Status: Needs review » Needs work

Actually, this does not work for negative contrast values:

gm convert -level '0x-50' -quality 75 'core/modules/image/sample.png' '/[...]/sites/default/files/styles/contrast/public/core/modules/image/sample.png'

raises

Option '-level' requires an argument or argument is malformed.

kjauslin’s picture

StatusFileSize
new974 bytes

Adjust patch to work with image_effects 2.3

mondrake’s picture

Status: Needs work » Closed (outdated)

Closing any stale issue with latest comment over 5 years old.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.