Masking 1 Image with 2 Masks no longer working.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
Looks OK and I suspect you have a symbolic link between convert and magick. But that does not explain why "magick" does not work. In what way does in not work? Do either of my commands above work on your old example? Do my new code work if you use convert rather than magick?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
My new methods should work just fine with one image with transparency and any number of black/white masks with no transparency. You can use -evaluate-sequence multiply with any number of images. But your two examples are quite different in the number of input images. In that case you have one mask for each image and also a blank background image.
Post a set of example images that do not work with either of my commands. I can see more from a real-world example.
Post a set of example images that do not work with either of my commands. I can see more from a real-world example.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
I use a buffer image that is blank, and compile everything into it.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
For some reason there are times with magick that it breaks entirely and the transparent image that is being masked, now has a black background. Convert never does this.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
If you save the output to JPG, you will get a black background since JPG does not support transparency. The same if you save to TIFF will JPG compression. Could that be your issue?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
It might be possible that your use of convert is not a symbolic link and your convert in IM 7 is actually calling IM 6 to do the work. But I would have to see an example where IM 7 magick does not work and convert does.
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
No, it's a png.
Do you have any other ideas to help apply multiple (dynamically infinite) masks to a single image?
Do you have any other ideas to help apply multiple (dynamically infinite) masks to a single image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
You can use my new method or you can apply your dst_in as before.
This works fine for me using IM 6 or IM 7
You should be able to add more masks in the same way
Or if you want a blank background the size of the input, then
These all work for me
This works fine for me using IM 6 or IM 7
Code: Select all
convert image.png \
\( mask1.png -alpha copy \) -compose dst_in -composite \
\( mask2.png -alpha copy \) -compose dst_in -composite \
result2.png
Code: Select all
magick image.png \
\( mask1.png -alpha copy \) -compose dst_in -composite \
\( mask2.png -alpha copy \) -compose dst_in -composite \
result2.png
Code: Select all
magick image.png \
\( mask1.png -alpha copy \) -compose dst_in -composite \
\( mask2.png -alpha copy \) -compose dst_in -composite \
\( mask3.png -alpha copy \) -compose dst_in -composite \
\( mask4.png -alpha copy \) -compose dst_in -composite \
result3.png
Code: Select all
magick image.png \
\( -clone 0 -alpha transparent \) +swap -compose over -composite \
\( mask1.png -alpha copy \) -compose dst_in -composite \
\( mask2.png -alpha copy \) -compose dst_in -composite \
result4.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
P.S. Your install has only two delegates. Is that what you want?
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
Code: Select all
magick buffer.png \
\( IMAGE_TO_MASK.png \
\( MASK1.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \
\( MASK2.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \
\) -compose Over -composite OUT_IMAGE.png
It's done like this because more images are combine into buffer.
Code: Select all
magick /folder/buffer.png \( /folder/0a/70/6d/0410487174583b9d794bf95a571.png \( /folder/d1/9a/63/32bf2bcb08536c78b7be4cf7e2.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \( /folder/18.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \) -compose Over -composite \( /folder/43/56/4c/3c8f642a849782b51d3475d0d7211.png \( /folder/18.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \) -compose Over -composite \( /folder/77/6f/7a/73ab514c223a5aa1e2703c8c34230.png \( /folder/18.png -alpha copy \) -compose Dst_In -composite -alpha disassociate \) -compose Over -composite /outputfolder/ae1b55334da62a012071469e0c24.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
I do not understand the need for -alpha disassociate. So I cannot help. Did you try my commands above that do not use it.
Sorry I have no idea what you are doing with the last command nor the buffer.png. Is that a pure transparent image?
If you want a buffer, then try this and replace my buffer.png with yours.
Repeat as many masks as you want.
Sorry I have no idea what you are doing with the last command nor the buffer.png. Is that a pure transparent image?
If you want a buffer, then try this and replace my buffer.png with yours.
Code: Select all
convert -size 100x100 xc:none buffer.png
Code: Select all
convert buffer.png \
image.png -compose over -composite \
\( mask1.png -alpha copy \) -compose dst_in -composite \
\( mask2.png -alpha copy \) -compose dst_in -composite \
result5.png
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
I have a buffer image that is loaded, just in the massive example in the previous past.
I have tried exactly what you have, and it just ignores the first mask. I also removed -alpha disassociate temporarily and still it ignores the first mask.
I have tried exactly what you have, and it just ignores the first mask. I also removed -alpha disassociate temporarily and still it ignores the first mask.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
Did you try my exact command with the same images that I used. Or did you replace with your buffer and other images. If you cannot duplicate my results with the same images that I used, then I don't think I can help further. It works for me. I cannot reproduce your problem with my code and the examples I used that you provided. I can only surmise that your Imagemagick install is flawed.
Try disabling OpenMP or use one thread and see if that works.
Try disabling OpenMP or use one thread and see if that works.
Code: Select all
convert -limit thread 1 ....
-
- Posts: 93
- Joined: 2012-12-31T15:56:29-07:00
- Authentication code: 6789
Re: Masking 1 Image with 2 Masks no longer working.
I have run exactly what you've given me using isolated examples and everytime one mask is ignored.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Masking 1 Image with 2 Masks no longer working.
Given that you say magick does not always work and that the first mask is ignored and you only have two delegates, I can only assume that your Imagemagick install if flawed.