Apply overlay image but retain shadows
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Apply overlay image but retain shadows
Hi,
Is there a way to apply an overlay image on base image and retain the shadows?
As example I would like to overlay a fabric onto a image with shadows as in the attached image.
I have tried to make the overlay transparent, but then the colour is not correct, as the base image colour then darkens the final image
Any pointers or ideas will be appreciated.
Thanks
Johann
https://dev.zaxo.cz/362.png (base)
https://dev.zaxo.cz/kiwi.jpg (overlay)
Is there a way to apply an overlay image on base image and retain the shadows?
As example I would like to overlay a fabric onto a image with shadows as in the attached image.
I have tried to make the overlay transparent, but then the colour is not correct, as the base image colour then darkens the final image
Any pointers or ideas will be appreciated.
Thanks
Johann
https://dev.zaxo.cz/362.png (base)
https://dev.zaxo.cz/kiwi.jpg (overlay)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply overlay image but retain shadows
try
or
Code: Select all
convert \( kiwi.jpg -crop 430x660+0+0 +repage \) \
\( 362.png -alpha off -colorspace gray \) \
-compose hardlight -composite \
\( 362.png -alpha extract \) \
-alpha off -compose copy_opacity -composite \
result1.png
Code: Select all
convert \( kiwi.jpg -resize 430x660! \) \
\( 362.png -alpha off -colorspace gray \) \
-compose hardlight -composite \
\( 362.png -alpha extract \) \
-alpha off -compose copy_opacity -composite \
result2.png
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Re: Apply overlay image but retain shadows
Wow thanks - the second option works quite well - i.e. with the resize vs the crop. Thank you very much for the assistance and suggestions!!
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Re: Apply overlay image but retain shadows
Hmm, Now I'm stuck. The above worked fine for most of the colours but now it seems to change the colour completely on lots of the samples I'm trying?
So for 362.png and kiwi.jpg it works fine, as well for coral-body.png and coral.jpg it works. But for pink-body.png and pink.jpg I get a very dark result?
I played around with the options - like changed colorspace to RGB but them my result is bright red?
Any pointers will be great
Works:
convert \( coral.jpg -resize 430x660! \) \( coral-body.png -alpha off -colorspace gray \) -compose hardlight -composite \( coral-body.png -alpha extract \) -compose copy_opacity -composite new-coral.png
Doesn't work:
convert \( pink.jpg -resize 430x660! \) \( pink-body.png -alpha off -colorspace gray \) -compose hardlight -composite \( pink-body.png -alpha extract \) -compose copy_opacity -composite new-pink.png
So for 362.png and kiwi.jpg it works fine, as well for coral-body.png and coral.jpg it works. But for pink-body.png and pink.jpg I get a very dark result?
I played around with the options - like changed colorspace to RGB but them my result is bright red?
Any pointers will be great
Works:
convert \( coral.jpg -resize 430x660! \) \( coral-body.png -alpha off -colorspace gray \) -compose hardlight -composite \( coral-body.png -alpha extract \) -compose copy_opacity -composite new-coral.png
Doesn't work:
convert \( pink.jpg -resize 430x660! \) \( pink-body.png -alpha off -colorspace gray \) -compose hardlight -composite \( pink-body.png -alpha extract \) -compose copy_opacity -composite new-pink.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply overlay image but retain shadows
Try this using -compose colorize: (unix syntax)
Please always provide your IM version and platform, since syntax may vary.
Code: Select all
convert pink-body.png \
\( +clone -alpha extract -write mpr:alpha +delete \) \
pink.jpg -alpha off -compose colorize -composite \
mpr:alpha -compose copy_opacity -composite result.png
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Re: Apply overlay image but retain shadows
Hello,
Thanks once again for the advise - always amazed with all the options and power of ImageMagick.
I will have to play a little with the input image pink.jpg to make it slightly lighter so that the final image comes out the correct colour. Perhaps not a "clean" solution but I'm sure it will work as well.
Thanks
Johann
Thanks once again for the advise - always amazed with all the options and power of ImageMagick.
I will have to play a little with the input image pink.jpg to make it slightly lighter so that the final image comes out the correct colour. Perhaps not a "clean" solution but I'm sure it will work as well.
Thanks
Johann
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Re: Apply overlay image but retain shadows
Hello Fred,
I'm trying to do something very similar than before, except this time I'm using the same set of white base images and then overlaying a new colour photo for each new fabric - but I just don't seem to get it working What would the optimal "recipe" be to make it work to overlay the colours on this base please.
Base images:
https://dev.zaxo.cz/im/base-1.png
https://dev.zaxo.cz/im/base-2.png
Overlay Photos:
https://dev.zaxo.cz/im/kiwi.jpg
https://dev.zaxo.cz/im/koralova.jpg
https://dev.zaxo.cz/im/seda.jpg
https://dev.zaxo.cz/im/pivonkova.jpg
I will keep experimenting but would be great if you could please give me some pointers please.
Kind regards,
Johann
I'm trying to do something very similar than before, except this time I'm using the same set of white base images and then overlaying a new colour photo for each new fabric - but I just don't seem to get it working What would the optimal "recipe" be to make it work to overlay the colours on this base please.
Base images:
https://dev.zaxo.cz/im/base-1.png
https://dev.zaxo.cz/im/base-2.png
Overlay Photos:
https://dev.zaxo.cz/im/kiwi.jpg
https://dev.zaxo.cz/im/koralova.jpg
https://dev.zaxo.cz/im/seda.jpg
https://dev.zaxo.cz/im/pivonkova.jpg
I will keep experimenting but would be great if you could please give me some pointers please.
Kind regards,
Johann
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Apply overlay image but retain shadows
try -compose multiply rather than -compose hardlight
Code: Select all
dims=`convert base-1.png -format "%wx%h" info:`
convert \( kiwi.jpg -resize $dims! \) \
\( base-1.png -alpha off -colorspace gray \) \
-compose multiply -composite \
\( base-1.png -alpha extract \) \
-alpha off -compose copy_opacity -composite \
result1.png
dims=`convert base-2.png -format "%wx%h" info:`
convert \( kiwi.jpg -resize $dims! \) \
\( base-2.png -alpha off -colorspace gray \) \
-compose multiply -composite \
\( base-2.png -alpha extract \) \
-alpha off -compose copy_opacity -composite \
result2.png
-
- Posts: 9
- Joined: 2017-12-03T06:58:02-07:00
- Authentication code: 1152
- Location: Czech Republic
Re: Apply overlay image but retain shadows
Excellent - wow tried many other things but not "multiply"
Thanks once again for saving my bacon and helping - great great product and community!!
Thanks once again for saving my bacon and helping - great great product and community!!