Adding a drop Shadow with phMagick

August 9, 2009 by nuno costa 5 comments

phMagick :: Drop Shaddows

 

You can add drop-shadows even to complex images, you can also specify shadow color, offset and opacity

 

Default drop-shadow

$phMagick = &new phMagick('original.png');
$phMagick->setDestination('shaddow2.png');
 ->dropShaddow();

 

Original Image Result

 

 

Custom drop shaddow (blue shaddow, 10px offset, 60% opacity)

$phMagick = &new phMagick('original.png');
$phMagick->setDestination('shaddow3.png');
 ->dropShaddow('#00f', 10, 60);

 

Original Image Result

 

Complex Image Drop-shadow

$phMagick = &new phMagick('original.png');
$phMagick->setDestination('shaddow.png') 
 ->dropShaddow();

 

Original Image Result

 

5 comments so far Add Your Comment

  1. by Beto Lima on November 23 2009 at 18:01

    Hi, i from brasil and i have a doubt. First i want to explain that i don’t know english, perfectly. Ok let’s go. for my situation i need to use with dropshadow but using more than one image. I want to show in browser many images of products of my site using dropshadow. Is this possible? Need i to change the script? Thank you.
    PS: Enjoying, tell me if my english is well!!!

  2. by nuno costa on November 24 2009 at 12:17

    Hello Beto,

    Your english is fine to me.

    You can do that but on file at a time, that is for each image you want to display you must first create the shadow and then show it as a regular image (< img src= …).
    I would advice you to name your new images as dropshadow_image_name that way you can check if the image was already created so you don't have to create the images again

    Olá Beto,
    Podes fazer isso sem problemas, mas tem que ser imagem a imagem.
    As imagems novas são guardadas no disco e podes mostra-las como uma imagem normal com a tag img

    O que costumo fazer nestes casos e gravar a nova imagem com um prefixo como dropShadow_ antes do nome.
    Por exemplo se a imagem original se chamar 123.jpg a nova vai se chamar dropShadow_123.jpg assim posso verificar se ja criei a dropshadow antes e não tenho que a criar de novo, porque fazer isso a cada pedido da pagina vai tornar o teu site lento

    Um abraço de Portugal

  3. by mac97000 on December 3 2009 at 11:44

    Hello,
    I’m sorry but I think that in the first and second example you have one more ” ; ” at the end.

    $phMagick->setDestination(’shaddow3.png’); <- this one

    ————-

    Bonjour,

    je viens de découvrir votre excellent script.

    En essayant différente proposition je pense que vous avez un point virgule de trop dans le premier et le second exemple à la fin de la ligne "destination".

    Cordialement Manuel

  4. by mac97000 on December 3 2009 at 11:52

    Sorry …

    You write “dropShaddow” with 2 “d” for the example …

    But the class function is “dropShadow” with only one “d”.

    Best regards Manuel

  5. by nuno costa on December 15 2009 at 16:51

    @ mac97000

    That example comes from the old version, where dropshadow was misspelled

    Thanks for noticing the syntax error, I will correct it

More from francodacosta.com

© francodacosta.com - All rights reserved