How do I Apply Multiple Screen and Multiply to one image?
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
How do I Apply Multiple Screen and Multiply to one image?
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.
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How do I Apply Multiple Screen and Multiply to one image?
First, learn how to composite just two images. It works like this:
"-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?
Code: Select all
convert img1 img2 -compose {METHOD} -composite out
Note also that we need two inputs before the "-composite".
Does that answer your question?
snibgo's IM pages: im.snibgo.com
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: How do I Apply Multiple Screen and Multiply to one image?
So would
be the correct way to chain them together?
Code: Select all
convert img1 img2 -compose Multiply -composite img3 -compose Screen -composite img4 -compose Multiply -composite out
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How do I Apply Multiple Screen and Multiply to one image?
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
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
snibgo's IM pages: im.snibgo.com
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How do I Apply Multiple Screen and Multiply to one image?
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...
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.
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
Like I said it is rarely used and almost completely unknown.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: How do I Apply Multiple Screen and Multiply to one image?
I had a working example, but another update imagemagick and now it is no longer viable.
I need to apply both (or all) masks to the image.
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I Apply Multiple Screen and Multiply to one image?
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I Apply Multiple Screen and Multiply to one image?
try putting end of line \
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.
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 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.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: How do I Apply Multiple Screen and Multiply to one image?
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I Apply Multiple Screen and Multiply to one image?
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How do I Apply Multiple Screen and Multiply to one image?
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.
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.
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: How do I Apply Multiple Screen and Multiply to one image?
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?
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How do I Apply Multiple Screen and Multiply to one image?
Can you show a simple use case?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.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: How do I Apply Multiple Screen and Multiply to one image?
After many many hours of work Imagemagick is finally working correctly (for the most part).
On 7.0.5-7 this worked.
I have tried changing convert to magick. I have already tried doing...
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.
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"
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"