I'm currently working with GM 1.3.35 on Raspberry Pi witch is working great for the purpose.
Meanwhile on my macOS (10.14.6 and 12.02) -colorize seems to be broken in latest version of GM 1.3.37.
I'm using exact same line such as below, but get different result on RPi with 1.3.35 and macOS with 1.3.37.
gm convert -modulate 140,0 -colorize 0,255,255 IN.jpg OUT.jpg
Example in attachment with same line as above.
- Left: Image as input
- Middle: Result from RPi with GM 1.3.35
- Right: Result from macOS with GM 1.3.37
Please provide the full output from 'gm -version' for the working and
non-working versions.
Perhaps the compiler and OpenMP used are different. For example,
GCC/GOMP vs Clang/OMP.
Regardless, I will investigate.
Bob
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt
Sure! Check attachments from both installations. Seems that OpenMP aren't installed with
1.3.37on macOS.Can you please attach the input JPEG file gzipped or a common archive format which will protect it from modification by SourceForge? The input file might be relevant.
I cropped your original from the PNG file and used that for testing.
I did find a bug but also decided that neither of the results are ok.
The documentation for -colorize says this:
Notice that it says that the value is a percentage of the range. That means the normal range is perhaps 0 to 100. So if you bump the value by 101% then the value needs to be fully saturated (maximum value). Due to a defect in the code the value was being "wrapped" (because it became a negative value stored as a positive) by the GCC compiler, but Clang is less forgiving about undefined behavior so it did something else. So the solution is to assure that saturating behavior works as expected given that the math is done using floating point arithmetic.
This means that the results from GraphicsMagick may be different than before.
To clarify, the expected range of the values provided -colorize are indeed 0-100 (a percentage) so 255 is out of range. But it will make it handle the out of range values by clipping.
Last edit: Bob Friesenhahn 2022-02-05
Mercurial changeset 16659:3207580e44c9 has fixes for this and the fix is in today's development snapshot.
I am marking this as fixed, although the result will be different than either GM build you have using the values you supplied.
@bfriesen: Thank you for clarify! I definitely overlooked the detail that
-colorizevalue should be in percentage. I was a bit overwhelmed of all details in documentation when I fiddled with my script and wrote wrong kind of the range.Now I've changed to percentage and get exact same result in both setup. Interesting way to discover this strange bug even it was wrong kind of the range, by mistake.
Thank you for your time, help and amazing work of GraphicsMagick.
Last edit: Stian Giltvedt 2022-02-07
On Mon, 7 Feb 2022, Stian Giltvedt wrote:
Thank you very much for reporting the problem.
Bob