Mosaic two pngs, one without and one with alpha

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?".
Post Reply
saptarshi

Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi,
I have two images. I have created a shadow background for one

convert NW20Vq1.png -background black -shadow 80x3+5+5 final.png

This works = final.png has transparancy, but NW20Vq1 does not.
And then i mosaic the two together

convert final.png NW20Vq1.png -background none -mosaic y.png

However, i get the following error

convert: Pixel cache allocation failed `final.png'.
convert: Memory allocation failed 'y.png'
Warning: recursive semaphore lock detected!

If i mosaic two images(pngs) none of them with alpha, the mosaic works.
I'm running Linux, and have installed Imagemagick in my home directory (along with PerlMagick).
This however works on OS/X.

Could someone help me out?
Thanks for your time.
Regards
Saptarshi
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mosaic two pngs, one without and one with alpha

Post by Bonzo »

Are you just trying to add shadow to an image? If so try this for your second line:

Code: Select all

convert final.png -composite NW20Vq1.png -composite shadow_test.png
saptarshi

Re: Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi,
Thank you. However that didn't work (probably my mistake) - though it did lead me to the solution.
Suppose final.png is the shadow and NW20Vq1.png is the original png to which i wish to add the shadow.

I tried using your command but i got the error

convert: missing an image filenaname 'shadow_test.png'

I tried

convert -composite NW20Vq1.png -composite final.png shadow_test.png
This ran, but no shadow, i flipped sequence of images but to no avail.

I then tried
composite NW20Vq1.png final.png x.png

and x.png contained the drop shadow.

However, how can i get it to work with convert?


Thank you
Saptarshi
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mosaic two pngs, one without and one with alpha

Post by Bonzo »

My original image was boots_layer_2.png and I used php to run the code

<?php
// This creates the shadow
exec("convert boots_layer_2.png -background black -shadow 80x3+5+5 final.png ");
// This puts the original image on top of the shadow
exec("convert final.png -composite boots_layer_2.png -composite shadow_test.png");
?>

Output on this page http://www.rubblewebs.co.uk/imagemagick/other.php
Last edited by Bonzo on 2007-04-09T11:57:31-07:00, edited 1 time in total.
saptarshi

Re: Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi,
Thanks again for the code, unfortunately this is my output

Code: Select all

convert NW20Vq1.png -background black -shadow 80x3+5+5 final.png
convert final.png -composite NW20Vq1.png  -composite shadow_test.png
convert: missing an image filename `shadow_test.png'.
I wonder why this is happening
My version of convert is
Version: ImageMagick 6.3.3 04/06/07 Q16 file:///home/sguha/mine/share/doc/ImageMagick-6.3.3/index.html
Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Mosaic two pngs, one without and one with alpha

Post by Bonzo »

That is strange !

I am using Version: ImageMagick 6.2.8 06/10/06 Q16

I am afraid that I have no idea apart from give composite a try:

Code: Select all

exec("composite final.png NW20Vq1.png shadow_test.png");
saptarshi

Re: Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi,
I've managed to get it working with composite. Now, my next challenge is to get a thin shadow all arround the image - not a drop shadow as such. Something like iPhoto thumbnail shadows.

Thank you for your time.
Rgds
Saptarshi
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Mosaic two pngs, one without and one with alpha

Post by anthony »

your original errors sould more like a memory problem, with your commands running out of memory. just how big are the images?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
saptarshi

Re: Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi,

Code: Select all

file NW20Vq1.png 
NW20Vq1.png: PNG image data, 1268 x 946, 16-bit/color RGB, non-interlaced
This is on a machine running
2.6.9-42.0.3.ELsmp #1 SMP x86_64 x86_64 x86_64 GNU/Linux
and 4GB ram (its a Dell, but i forget the model).

Thanks
Saptarshi
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Mosaic two pngs, one without and one with alpha

Post by anthony »

That does not sound like it should run out of memory. Is it posible to give us a link to the image to try out?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
saptarshi

Re: Mosaic two pngs, one without and one with alpha

Post by saptarshi »

Hi.
Unfortunately due to privacy issues I can't share the PNG (its a graph of some data).
However, it works now.... i have no idea why but all is well.

I appreciate everybody's time and effort.

Regards
Saptarshi
Post Reply