how to put a texture on a .png image with transparent background

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

how to put a texture on a .png image with transparent background

Post by direction » 2019-08-01T21:42:11-07:00

Input image 1: texture image
Image

Input image 2: .png image file which have a 'deboss' effect
Image


Expected output image with transparent background, deboss effect (not so good as the input image 2, this is best result I can do) and texture:
(I used Photoshop)
Image

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

Re: how to put a texture on a .png image with transparent background

Post by fmw42 » 2019-08-01T22:20:14-07:00

Try this:

Code: Select all

convert input-texture.png \
\( out2_a315.png -channel a -negate +channel \) \
\( +clone -alpha extract -negate +write mpr:alpha +delete \) \
-compose multiply -composite \
mpr:alpha -alpha off -compose over -compose copy_opacity -composite \
emboss_texture.png

direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

Re: how to put a texture on a .png image with transparent background

Post by direction » 2019-08-02T03:24:25-07:00

fmw42 wrote:
2019-08-01T22:20:14-07:00
Try this:

Code: Select all

convert input-texture.png \
\( out2_a315.png -channel a -negate +channel \) \
\( +clone -alpha extract -negate +write mpr:alpha +delete \) \
-compose multiply -composite \
mpr:alpha -alpha off -compose over -compose copy_opacity -composite \
emboss_texture.png
I tried it. below is the output image. Seems like it lost the 'deboss' effect:
Image

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

Re: how to put a texture on a .png image with transparent background

Post by fmw42 » 2019-08-02T09:32:04-07:00

Tell us the steps you uses in PS to create it.

direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

Re: how to put a texture on a .png image with transparent background

Post by direction » 2019-08-02T18:50:10-07:00

fmw42 wrote:
2019-08-02T09:32:04-07:00
Tell us the steps you uses in PS to create it.
In photoshop.
I overlay two layers, push Alt button, and used the 'Mask' to get the effect.

Hi fmw42,
Just find another way to get the expected result, IM should be able to do it..
I used Photoshop, right click layer - layer style - bevel and emboss -out put image. The effect is like below:

Input image:
Image

Output image (with a little 'deboss' effect, more is better:) -
I can not simply use "emboss -a 315 ..." to get the expected image.

Image

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

Re: how to put a texture on a .png image with transparent background

Post by fmw42 » 2019-08-02T21:16:55-07:00

try this:

Code: Select all

convert img.png \
\( -clone 0 -alpha extract -morphology dilate diamond:1 -write mpr:alpha +delete \) \
texture.png -compose multiply -composite \
mpr:alpha -alpha off -compose copy_opacity -composite result.png

direction
Posts: 16
Joined: 2019-07-20T21:21:37-07:00
Authentication code: 1152

Re: how to put a texture on a .png image with transparent background

Post by direction » 2019-08-03T17:43:29-07:00

fmw42 wrote:
2019-08-02T21:16:55-07:00
try this:

Code: Select all

convert img.png \
\( -clone 0 -alpha extract -morphology dilate diamond:1 -write mpr:alpha +delete \) \
texture.png -compose multiply -composite \
mpr:alpha -alpha off -compose copy_opacity -composite result.png
fmw42, It works. Thanks. :)

Post Reply