Photoshop/GIMP like "Levels" using ImageMagick
Posted: 2017-08-09T03:29:40-07:00
The "Levels" command is well known to Photoshop or GIMP users, and quite useful.
ImageMagick supports the same function using the command line option (not discussing APIs). This is documented here
According to the docs, one can specify (not interested in gamma at this point).
The range for these parameters is 0 to QuantumRange, or from 0 to 100%. "QuantumRange" being the maximum possible value according to pixel depth. For 8bit/channel RGB images (the usual), it would be 255.0.
It also says:
This works fine, when using percentages:
When using actual values, like I would specify in Photoshop or GIMP, all I get is a white image:
Am I doing something wrong?
I've also looked here but all examples are using percentages.
How can I apply a "Levels" with ImageMagick, preferably without resorting to bc to perform floating point percentage calculations from my actual numerical values?
Thank you.
Tested with
ImageMagick supports the same function using the
Code: Select all
-level
According to the docs, one can specify
Code: Select all
-level black_point,white_point
The range for these parameters is 0 to QuantumRange, or from 0 to 100%. "QuantumRange" being the maximum possible value according to pixel depth. For 8bit/channel RGB images (the usual), it would be 255.0.
It also says:
Now here is my problem:If a % sign is present anywhere in the string, both black and white points are percentages of the full color range.
This works fine, when using percentages:
Code: Select all
convert SOME_IMAGE -level 10%,90% OUTPUT_IMAGE
Code: Select all
convert SOME_IMAGE -level 92,243 OUTPUT_IMAGE
I've also looked here but all examples are using percentages.
How can I apply a "Levels" with ImageMagick, preferably without resorting to bc to perform floating point percentage calculations from my actual numerical values?
Thank you.
Tested with
Version: ImageMagick 6.8.6-10 2016-05-30 Q16