[SOLVED] composite -blend 1% [and how to add "darken only"]?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
jkop
Posts: 10
Joined: 2011-09-27T07:27:05-07:00
Authentication code: 8675308

Re: composite -blend 1% [and how to add "darken only"]?

Post by jkop »

Thanks, how does one write such a loop, for example, with the following command

convert *.png +level 99%,100% \
-compose linear_burn -background white -flatten \
shadow_merge_result.png

?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: composite -blend 1% [and how to add "darken only"]?

Post by fmw42 »

jkop wrote:Thanks, how does one write such a loop, for example, with the following command

convert *.png +level 99%,100% \
-compose linear_burn -background white -flatten \
shadow_merge_result.png

?
No, that would not work.

You have to create a list of all your files and write a while or for loop to loop over each image and composite it with the previous result.

Are you on Unix or Windows?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: composite -blend 1% [and how to add "darken only"]?

Post by anthony »

If all the images (100 is not many) can be read into memory without problems, then no loop is needed, just read them all at once.

If the images are very large and the command becomes very slow, you can do it in batches, using the same command
just do say the first 20 images (or however many works for your computers memory), then that result and the next 20 images, and so on until you have done all the images.

The compose method is associative, meaning order of the images does not matter at all!

You can use the same image for the result at each stage as IM completely reads the images given as input, before opening (for over-write, if it already exists) the output image.

If you want to just do two at a time you can use the -composite operator (no need for -background then) to merge them together. Again order of merges does not matter.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jkop
Posts: 10
Joined: 2011-09-27T07:27:05-07:00
Authentication code: 8675308

Re: composite -blend 1% [and how to add "darken only"]?

Post by jkop »

Okay, thanks, I can process them in groups of 10 or the like. I'm on Linux :D
jkop
Posts: 10
Joined: 2011-09-27T07:27:05-07:00
Authentication code: 8675308

Re: composite -blend 1% [and how to add "darken only"]?

Post by jkop »

Hm, well for

convert *.png +level 99%,100% \
-compose linear_burn -background white -flatten \
shadow_merge_result.png

it doesn't seem to work to process say 5 groups of 20 images separately and then process the 5 results into one result. Processing 20 to 1 resultimage works fine, but processing 5 resultimages merely results in some washed out white image (it should disregard the white, not add it). I tried to remove the -background white option, but without luck. Am I missing something? :/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: composite -blend 1% [and how to add "darken only"]?

Post by anthony »

-background white is actually the default setting so removing it has not effect. I add it as a precaution.

Ah... in the final merge of 5 images, the images are already 'level' correctly. As such the washed out look would be because of a second 'level' operation being applied. the +level should only be applied to the initial pure black and white images.

Remove the +level 99%,100% from the final merger should fix the problem..

If you are doing a 'progressive' merge then the first line should be...

Code: Select all

   convert previous_result.png \( new_shadows_*.png +level 99%,100% \) \
                  ....
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jkop
Posts: 10
Joined: 2011-09-27T07:27:05-07:00
Authentication code: 8675308

Re: composite -blend 1% [and how to add "darken only"]?

Post by jkop »

That works!

Code: Select all

convert *.png -compose linear_burn -flatten shadow_merge_result.png
correctly superimposes the 5 partial superimpositions into one.


Thank you very much :)
Post Reply