Dst_Out and layers

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?".
Locked
excel
Posts: 18
Joined: 2015-12-19T13:16:12-07:00
Authentication code: 1151

Dst_Out and layers

Post by excel »

There are two images:

extrude.png (with opacity) and rect.png (without opacity)

Image Image

Code: Select all

composite -compose Dst_Out -alpha Set extrude.png rect.png result.png
This command allows to get such result.png (with opacity):

Image


How to get result with a green inner frame?

Image

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

Re: Dst_Out and layers

Post by fmw42 »

try this as one way to do it.

(unix syntax)

Code: Select all

convert rect.png \
\( -clone 0 -fill green1 -colorize 100% \) \
\( extrude.png -alpha extract -auto-level -write show: \) \
-compose over -composite \
-fuzz 30% \
-fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 result.png
Please always provide your IM version and platform, since syntax differs on Unix and Windows.

excel
Posts: 18
Joined: 2015-12-19T13:16:12-07:00
Authentication code: 1151

Re: Dst_Out and layers

Post by excel »

fmw42 wrote:try this as one way to do it.

(unix syntax)

Code: Select all

convert rect.png \
\( -clone 0 -fill green1 -colorize 100% \) \
\( extrude.png -alpha extract -auto-level -write show: \) \
-compose over -composite \
-fuzz 30% \
-fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 result.png
Please always provide your IM version and platform, since syntax differs on Unix and Windows.


Debian 7,
Version: ImageMagick 6.8.9-9 Q16 x86_64 2015-01-05

Thanks, your example works, but why the corners are dirty?
Which parameter allows avoid this?


Image

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

Re: Dst_Out and layers

Post by fmw42 »

try increasing the -fuzz value. This happens because your transparent image has black on the line and black in the corners. So I had to make all black into green and then make the corners transparent by fuzzy floodfill.

Code: Select all

convert rect.png \
\( -clone 0 -fill green1 -colorize 100% \) \
\( extrude.png -alpha extract -auto-level \) \
-compose over -composite \
-fuzz 60% \
-fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 -fill none -draw "matte 2,2 floodfill" \
-rotate 90 result.png


Or perhaps better to separate the extrude.png alpha channel into two different images: one for the line and the other for the corner.

Code: Select all

convert rect.png \
\( -clone 0 -fill green1 -colorize 100% \) \
\( extrude.png -alpha extract -auto-level \) \
\( -clone 2 -fuzz 60% -fill black \
-rotate 90 -draw "color 2,2 floodfill" \
-rotate 90 -draw "color 2,2 floodfill" \
-rotate 90 -draw "color 2,2 floodfill" \
-rotate 90 -draw "color 2,2 floodfill" \) \
\( -clone 2 -clone 3 -compose difference -composite -negate \) \
-delete 2 \
\( -clone 0-2 -compose over -composite  \) \
-delete 0-2 +swap \
-alpha off -compose copy_opacity -composite \
result.png


excel
Posts: 18
Joined: 2015-12-19T13:16:12-07:00
Authentication code: 1151

Re: Dst_Out and layers

Post by excel »

Thank you.
I decided to split "extrude.png" into two files.
Then easier to operate and good quality.

Locked