Hi
I have pieced a string of commands together to make kind of a fake hdr look. It looks like this (from Bash):
workfile=IMG_5368.JPG
convert -negate -colorspace gray -resize 10% -resize 1000% "$workfile" - | composite -dissolve 85% - "$workfile" - | composite -compose Soft_Light - "$workfile" IMG_5368_processed.JPG
Btw. the files involved are:
Original: http://simonmikkelsen.dk/files/im/IMG_5368.JPG
Tmp (see later): http://simonmikkelsen.dk/files/im/IMG_5368_tmp.JPG
Result: http://simonmikkelsen.dk/files/im/IMG_5 ... cessed.JPG
However, when I do the final Soft_Light it seems there are some rounding errors. On the result file, look at the shadows at the ceiling inside of the garage. Instead of being gray tones, they are dark red and dark yellow/green. The first I think off is rounding errors, but maby I'm doing something wrong? If I do the soft light composite in The Gimp, there are no problems - I get nice smooth gray tones.
The tmp-file is made via
convert -negate -colorspace gray -resize 10% -resize 1000% "$workfile" - | composite -dissolve 85% - "$workfile" IMG_5368_tmp.JPG
so the result file can also be made via:
composite -compose Soft_Light IMG_5368_tmp.JPG IMG_5368.JPG IMG_5368_processed.JPG
I'm using version 6.3.7 06/04/09 Q16
Best regards,
Simon Mikkelsen, Denmark
Rounding error when using composite soft_light for fake hdr
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Rounding error when using composite soft_light for fake
Before we go any further. Use IM correctly, applying opertions in command line ordertryl wrote:workfile=IMG_5368.JPG
convert -negate -colorspace gray -resize 10% -resize 1000% "$workfile" - | composite -dissolve 85% - "$workfile" - | composite -compose Soft_Light - "$workfile" IMG_5368_processed.JPG
See IM Examples, Basics.
http://www.imagemagick.org/Usage/basics/
As such the above should be...
Code: Select all
workfile=IMG_5368.JPG
convert "$workfile" -negate -colorspace gray -resize 10% -resize 1000% - | composite -dissolve 85% - "$workfile" - | composite -compose Soft_Light - "$workfile" IMG_5368_processed.JPG
See Complex Image Processing and Debugging
http://www.imagemagick.org/Usage/basics/#complex
Something like....
Code: Select all
convert IMG_5368.JPG \
\( -clone 0 -negate -colorspace gray -resize 10% -resize 1000% \) \
\( -clone 0,1 -compose dissolve -define compose:args=85% -composite \) \
\( -clone 0,2 -compose Soft_Light \) \
-delete 0--2 IMG_5368_processed.JPG
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Rounding error when using composite soft_light for fake
Hi anthony
Thanks for the great answer - it took me a lot of time to digest everything, including reading a lot of your Image Magick guide.
to get it to work. I'm not sure, because IM is not easy to fully understand, the final -composite will do the actual compositing, while -compose soft_light will just set the parameters that -composite will use to work. Please correct me if I'm wrong.
Using your (compound?) command and not my own piped, it will run about 20 sec faster on a 12 mega pixel image on my slow/ computer. That sums up to a lot this Saturday, where it will have just one night to process about 1000 pictures from a local fun run.
That command did not work with my old version 6.3.7 06/04/09 Q16, so I downloaded version 6.6.4-9 2010-10-11 Q16 and compiled it with
I haven't had the time to recompile without one or both of those two, but from the documentation using something like that might be used for fixing too low precision.

Thanks for the great answer - it took me a lot of time to digest everything, including reading a lot of your Image Magick guide.
As far as I can read this should not change the way Image Magick operates, but it will make my script compatible with version 7, which will not be as forgiving as version 6.anthony wrote: Before we go any further. Use IM correctly, applying opertions in command line order
See IM Examples, Basics.
http://www.imagemagick.org/Usage/basics/
Just if someone else should find this thread on Google, I had to change the 2nd last line toanthony wrote: You can also do compositions all in one command!
See Complex Image Processing and Debugging
http://www.imagemagick.org/Usage/basics/#complex
Something like....Code: Select all
convert IMG_5368.JPG \ \( -clone 0 -negate -colorspace gray -resize 10% -resize 1000% \) \ \( -clone 0,1 -compose dissolve -define compose:args=85% -composite \) \ \( -clone 0,2 -compose Soft_Light \) \ -delete 0--2 IMG_5368_processed.JPG
Code: Select all
\( -clone 0,2 -compose Soft_Light -composite \) \
Using your (compound?) command and not my own piped, it will run about 20 sec faster on a 12 mega pixel image on my slow/ computer. That sums up to a lot this Saturday, where it will have just one night to process about 1000 pictures from a local fun run.
That command did not work with my old version 6.3.7 06/04/09 Q16, so I downloaded version 6.6.4-9 2010-10-11 Q16 and compiled it with
Code: Select all
--with-quantum-depth=32 --enable-hdri=yes
Now you sound like one of my math teachers at unianthony wrote: As your your actual problem -- simply the above to the actual problem!!!!

- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Rounding error when using composite soft_light for fake
convert IMG_5368.JPG \
\( -clone 0 -negate -colorspace gray -resize 10% -resize 1000% \) \
\( -clone 0,1 -compose dissolve -define compose:args=85% -composite \) \
\( -clone 0,2 -compose Soft_Light \) \
-delete 0--2 IMG_5368_processed.JPG
You are right. There is a typo where -composite should be added to the
\( -clone 0,2 -compose Soft_Light -composite \) \
It is an easy thing to leave out. I catch myself doing that from time to time.
I don't think your hdri or Q32 will make much difference with a JPG image. I think it was just that your old version of IM was too old and some of the compose options have been added or upgraded since then. Also the -compose dissolve -define compose:args=85% -composite approach to dissolve is relatively new usage with convert rather than with composite
see http://www.imagemagick.org/script/compose.php
I think -define compose:args and -set option:compose:args are pretty much the same. I am not sure why Anthony is using the former.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Rounding error when using composite soft_light for fake
They are the same. and I have taken to using the -define form as it is simplier. Many areas of IM examples has already been modified, though typically they list both methods.fmw42 wrote:I think -define compose:args and -set option:compose:args are pretty much the same. I am not sure why Anthony is using the former.
It also makes it obvious that your are defining a global "Artifact" that are used purly for internal IM operations, rather than a per image "Properity". Artifacts are NOT saved with images, though many properties can. MIFF for example will save all defined properties.
However the -define form can NOT use 'percent escapes' while the special -set option:... form can.
I have been trying to write up basic information about image attributes, settings, properties, and global defines in IM Examples, Basics.
http://www.imagemagick.org/Usage/basics/#attributes
But it is a complex topic.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Rounding error when using composite soft_light for fake
Good to know!However the -define form can NOT use 'percent escapes' while the special -set option:... form can.
That will be most welcome. Agreed it is complex, but long overdue -- any notes will be helpfulI have been trying to write up basic information about image attributes, settings, properties, and global defines in IM Examples, Basics.
http://www.imagemagick.org/Usage/basics/#attributes
But it is a complex topic.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Rounding error when using composite soft_light for fake
I have done more work on IM Examples in that area, and actually converts command line into actual image examples. Including the important example of converting a per-image 'properity' (set) into global 'artifact' (define) so that you can generate a label from the properity.

Code: Select all
convert -size 100x label:Anthony \
-set option:my_pointsize '%[label:pointsize]' \
-size 100x label:'at %[my_pointsize]pt' \
-append properity_tricky.gif

Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Rounding error when using composite soft_light for fake
anthony wrote:I have done more work on IM Examples in that area, and actually converts command line into actual image examples. Including the important example of converting a per-image 'properity' (set) into global 'artifact' (define) so that you can generate a label from the properity.
Code: Select all
convert -size 100x label:Anthony \ -set option:my_pointsize '%[label:pointsize]' \ -size 100x label:'at %[my_pointsize]pt' \ -append properity_tricky.gif
Pretty neat.