I was wondering if it is possible to create a Javascript (browser, not Node.js) script able to manipulate the shadow, midtone and highlight image levels of an image. This feature is available in image editors as Photoshop (see below).
I have found https://github.com/oliver-moran/jimp and this other question but I can’t figure it out.
My last hope is to run it on a server with Node.js and bindings to imagemagick, but running it for free on a browser is much better.
3
Answers
You mean something like this?
Using Imagemagick you can do
where bp is the shadow (black point) value, wp is the highlight (white point) value and gamma is the midpoint value. Note that the bp and wp values should be in the Quantumrange of your ImageMagick compile, e.g. for Q16, values range from 0 to 65535. For Q8, values range from 0 to 255. However, you can use percent values for bp and wp, which I find much easier. The gamma value is a float >0 where a value of 1 is no change. see http://www.imagemagick.org/script/command-line-options.php#level
Yes, you can control the levels with the following scriptlistner code:
Word of warning: you may have to adjust the gamma value (the input maybe between 0 and 1 as it hasn’t been adjusted from the Photoshop values of 9.99 and 0.10) But you should be able to add that into the function.