Home arrow Miscellaneous arrow Page 3 - Adding Drop Shadows with PHP

Adding Drop Shadows with PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12

    Table of Contents:
  • Adding Drop Shadows with PHP
  • Setting the Shadow Options
  • Opening the Canvas
  • Allocating the Color Pallette
  • Drawing on the Canvas
  • Overlay the Original
  • Combined Code



    Adding Drop Shadows with PHP - Opening the Canvas

    (Page 3 of 7 )

    An image canvas is needed so that we will have something on which to draw the drop shadow.

    list($o_width$o_height) = getimagesize($src);

    $width  $o_width DS_OFFSET;
    $height $o_height DS_OFFSET;

    $image imagecreatetruecolor($width$height);

    The getimagesize function is used to retrieve the width and height of a given image file. It actually returns an array of 4 elements (the width, height, file type and attributes), but we've discarded the unwanted information.

    The dimensions of the new canvas should be larger than the original image by the size of the drop shadow's offset. This way, we won't need to resize or crop the original image later.

    The imagecreatetruecolor function creates a new image canvas with the specified dimensions and returns a resource identifier to it.

    A note for those who may be familiar with the imagecreate function: imagecreate returns a palette image resource. Since we'll presumably be working with true color images, imagecreatetruecolor is preferred over imagecreate.

    More Miscellaneous Articles
    More By bluephoenix

    blog comments powered by Disqus


    - Attention: Forum and Site Maintenance
    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength

    Developer Shed Affiliates


    © 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap