Miscellaneous
  Home arrow Miscellaneous arrow Page 6 - Adding Drop Shadows with PHP
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

Adding Drop Shadows with PHP
By: bluephoenix
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2005-01-24

    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

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Adding Drop Shadows with PHP - Overlay the Original


    (Page 6 of 7 )

    The final step is to overlay the original image and send the results back to the requesting browser.

    The imagecopymerge function can be used to copy a section of one image onto another.

    <?php
    $original_image 
    imagecreatefromjpeg($src);
    imagecopymerge($image$original_image0,00,0$o_width$o_height100);
    ?>

    The imagecopymerge function accepts the base image, the overlay image, coordinates where to place the overlay on the base image, cropping coordinates for the overlaid section and an alpha transparency.

    The overlaid image should be positioned at the top left of the base image. Since the entire original image will be superimposed, it's cropped coordinates should be 0,0 to its width and height. The image should be fully opaque so a value of 100 should be passed for the alpha.

    The final results can then be sent to the browser using imagejpeg.

    <?php
    header
    ("Content-type: image/jpeg");
    imagejpeg($image""100);
    ?>

    By sending a Content-Type header, we are creating a PHP script that outputs the jpeg file directly to the browser.

    The imagejpeg function can either save the image to a file or send the image directly to the request. By specifying an empty string for the file name it knows we wish to output the image directly to the browser. You can also set the compression quality of the image, which I have set at 100.

    Once the image has been sent it's good practice to free up the resources we've consumed to generate it.

    <?php
    imagedestroy
    ($image);
    imagedestroy($original_image);
    ?>

    More Miscellaneous Articles
    More By bluephoenix


       · Nice, this could come in handy.IS it easy to do this with Text?
       · Is it possible to make the dropshadow fade to a transparent value?Not that its a...
       · I am trying to learn PHP, and these tutorials have been a good place to practice. ...
       · The script can be called as with any other PHP script with a direct URI such as...
       · it works but is just solid and goes all around the right and bottom side
       · It could be a few things. When I was developing it, this happened to me a few times...
       · Timothy,This is some great code and a great idea. However, there are a few...
       · i used the code and works perfect for the jpeg images of my website...but i have a...
       · I get the following errorParse error: parse error, unexpected '=', expecting ')'...
       · All types of challenges with this code with extra characters etc. So I worked out...
       · /* number of steps from black to background color /*Note the close comment at...
     

    MISCELLANEOUS ARTICLES

    - Install Slackware on Your Old PC
    - Firefox Plugins You`re Not Using (and Should...
    - Working with MP3 ID3 Tags in FTP Server Usin...
    - How Switching to Linux Can Make Your Computi...
    - Set Up Your Home Office on Linux: a Guide fo...
    - Putty File Transfer Commands in SSH Protocol
    - Setting Up Ubuntu for Your Home Office
    - Installing Mint Linux
    - Crucial Traits of Awk
    - Using PHP to Stream MP3 Files and Prevent Il...
    - 10 Must Have Firefox Improvements
    - All About OpenOffice 3.0
    - Shell Script Writing
    - Loops in the UNIX Shell
    - The Test in the UNIX Shell





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 9 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek