Page 1 of 2
How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-01-21T15:24:53-07:00
by chaoscarnage
Lets say I have image test.png and i have 3 more images I wish to screen and multiply onto one main image. How would i go about doing that?
convert test.png -compose Multiply image1.png -compose Screen image2.png -compose Multiply image3.png result.png
Does not appear how it would in a program like Photoshop. It looks like I'm just failing at chaining the commands.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-01-21T15:32:49-07:00
by snibgo
First, learn how to composite just two images. It works like this:
Code: Select all
convert img1 img2 -compose {METHOD} -composite out
"-compose" is merely a setting, that says what method will be used. Note that "-composite" is required. Without that keyword, you won't get a composite.
Note also that we need two inputs
before the "-composite".
Does that answer your question?
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-01-21T15:55:17-07:00
by chaoscarnage
So would
Code: Select all
convert img1 img2 -compose Multiply -composite img3 -compose Screen -composite img4 -compose Multiply -composite out
be the correct way to chain them together?
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-01-21T17:10:12-07:00
by snibgo
Breaking it down: this reads two images into the image list. Then it replaces both with the multiplication, so then we have one image in the list. Then you add img3 to the list, so we have two images in the list, and you "Screen" them together, and that replaces both of its inputs. Then you add img4 to the list, and multiply that by the previous result, so that leaves you with a single image, which you save.
We can think of this with temporary results that are stored in memory:
img1 img2 Multiply => t1
t1 img3 Screen => t2
t2 img4 Multiply =>out
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-01-21T20:14:21-07:00
by anthony
If you are composing multiple images together
with the same compose method then you can also use the laying operators to do this...
http://www.imagemagick.org/Usage/layers/#compose
The only tricky part about this is that the first image (the background color) needs to be selected to be white, black, or transparent, so as to not effect results.
There is also another 'trick', that is rarely used.
You can
-set compose a different compose method onto each individual image!
If the per-image 'compose' setting has been set, than that is used instead of the 'global' -compose setting.
This is present to allow the handling of PSD layered images, where different images can be layered differently!
That is...
Code: Select all
convert -background none \
image1.png -set compose over \
\( image2.png -set compose dst-over \) \
-flatten result.png
Then image1.png will be composed
over the background and image2.png will be composed
UNDER that result. Now for two images it is nothing much, but for many images you can generate quite a complex layering effect!
But only if you process the images one at a time in sequence.
Like I said it is rarely used and almost completely unknown.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T13:22:30-07:00
by chaoscarnage
I had a working example, but another update imagemagick and now it is no longer viable.
Code: Select all
convert BUFFER.png \(
IMAGE.png
\(
\( MASK1.png -alpha copy \) -compose Dst_In -composite -alpha disassociate
\)
\(
\( MASK2.png -alpha copy \) -compose Dst_In -composite -alpha disassociate
\)
/) -compose Over -composite OUTIMAGE.png
I need to apply both (or all) masks to the image.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T13:30:01-07:00
by fmw42
What is your version of Imagemagick. Are you on IM 7 or IM 6?
There is no -alpha disassociate that I know about. See
https://www.imagemagick.org/Usage/masking/. In IM 7 there is a -alpha discrete. Is that what you want?
check your parenthesis to be sure you have both opening and closing pairs.
Do not end a line with \( End of lines are just \ So your first line looks wrong if this is a multi-line command. For readability better to do as Anthony did above with line breaks for each composite.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T13:31:08-07:00
by fmw42
try putting end of line \
Code: Select all
convert BUFFER.png \( \
IMAGE.png
\( \
\( MASK1.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \
\) \
\( \
\( MASK2.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \
\) \
/) -compose Over -composite OUTIMAGE.png
I do not really understand what you are trying to do. Mask image compositing needs 3 images; two images and mask (that does not have alpha)
I do not understand why the -alpha copy with a mask nor the -alpha disassociate.
Please post your BUFFER IMAGE and MASK1 and MASK2 image and your output as you expected it to be when it was working.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T13:57:00-07:00
by chaoscarnage
This is where I got it from.
https://imagemagick.org/script/command- ... .php#alpha
Take 1 image and apply 2 masks to the image.
7.0.5-7 to 7.0.8-8
I went into my post history before posting and thought this was the thread I made about masking, my mistake for using it. I'll make another topic. Thank you.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T15:33:40-07:00
by fmw42
Thanks for the link. I was unaware of those associate and unassociated options to -alpha. They must be new for IM 7 along with discrete. They are not in the porting guide, nor in Anthonys (IM 6) docs.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T16:50:46-07:00
by anthony
I was unaware at Associate and Disassociate options as well. Any idea as to what they actually do? does it actually add/delete the alpha channel data from the image? The page is not exactly clear (needs some examples I suppose).
Also the aliases 'On' and 'Off' are missing from the list as being the same a Activate and Deactivate.
That becomes clear when you look at the text following the option list.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T16:56:24-07:00
by fmw42
Anthony, I do not know exactly what they are supposed to do. I guess we need to get more information from Magick. IM 7 uses alpha and masks differently and I suppose there were some cases that caused Magick to inroduce those new -alpha options.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T17:40:18-07:00
by magick
See
https://en.wikipedia.org/wiki/Alpha_compositing. Associated alpha is premultiplied alpha and the alpha channel is then removed. Disassociated alpha extracts the alpha from the premultiplied channels and restores the alpha channel.
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-05T18:29:14-07:00
by fmw42
magick wrote: ↑2018-08-05T17:40:18-07:00
See
https://en.wikipedia.org/wiki/Alpha_compositing. Associated alpha is premultiplied alpha and the alpha channel is then removed. Disassociated alpha extracts the alpha from the premultiplied channels and restores the alpha channel.
Can you show a simple use case?
Re: How do I Apply Multiple Screen and Multiply to one image?
Posted: 2018-08-06T10:58:55-07:00
by chaoscarnage
After many many hours of work Imagemagick is finally working correctly (for the most part).
On 7.0.5-7 this worked.
Code: Select all
convert "inline:PNG64DATA" "MULTIPLY_IMG_1.png" -channel RGBA -compose Multiply -composite "MULTIPLY_IMG_2.png" -channel RGBA -compose Multiply -composite "SCREEN_IMG_1.png" -channel RGBA -compose Screen -composite "NEW_IMAGE.png"
I have tried changing convert to magick. I have already tried doing...
Code: Select all
magick "inline:PNG64DATA" \( "MULTIPLY_IMG_1.png" -channel RGBA -compose Multiply \) -composite \( "MULTIPLY_IMG_2.png" -channel RGBA -compose Multiply \) -composite \( "SCREEN_IMG_1.png" -channel RGBA -compose Screen \) -composite "NEW_IMAGE.png"
While both still compile an image it is an outline of whatever the PNG64DATA was instead of the full image. This was fully function for the last 8 months until the update, yesterday which is 7.0.8-8. Is there a simple fix, I really hope so.