andy's php projects
Script and site usage:
All of the scripts on this site are provided free for non-commercial, personal or non-profit use. If you wish to use any of these in a commercial system, please refer to the payment plan.

Support:
Support for each of the scripts is given, free of charge, on the message board. Each script has its own message board which can be accessed by clicking on the 'project forum' link (beneath the description of each project).


Proudly hosted with Dreamhost

Save $20 when signing up for Dreamhost by using the promo code amnuts20


If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh to encourage me to continue? Every little helps!

Zend Certified Engineer logo


Drop Shadowed Thumbnail Creator

This class allows you to very easily create thumbnails of images, on which you can also apply a drop-shadow effect. You can control the colour of the background so that drop-shadow will fit better onto your page and the size of the thumbnail.

You can resize in an absolute or relative way (to a certain size or by a certain size), both as a pixel number or a percentage.

class.dropshadow.php

The main class file. Version two works considerably differently to version one. To emulate version one, see the 'class.originaldropshadow.php' file below.

17.84kb in size
last modified May 6, 2006 at 1:54pm
15569 views, 13316 downloads

class.originaldropshadow.php

This is an extension of the main class file to emulate version 1.x of the script.

<?php

//
// class.originaldropshadow.php
// version 1.0.0, 22nd May, 2003
//
// License
//
// PHP class to create thumbnails of images and/or to add a drop shadow effect.
//
// Copyright (C) 2002 Andrew Collington, php@amnuts.com, http://php.amnuts.com/
//
// This program is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation; either version 2 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program; if not, write to the Free Software Foundation, Inc., 59 Temple
// Place - Suite 330, Boston, MA 02111-1307, USA.
//
// Description
//
// This class is an extension of the shadow class file found on the website
// http://php.amnuts.com/.  It allows you to emulate the version 1.x version of
// the dropshadow class by using the newer version 2.x.
//
// Requirements
//
// PHP 4.1.0+, GD 2.0.1+
//
// Andrew Collington, 2003
// php@amnuts.com, http://php.amnuts.com/
//


class originalDropShadow extends dropShadow
{
    var 
$_size;
    var 
$_type;

    function 
setDebugging($do FALSE)
    {
        
$this->_showDebug = ($do TRUE FALSE);
    }

    function 
setImageType($type '')
    {
        if (
$type != "jpg" && $type != "png"$this->_type "png";
        else 
$this->_type $imgtype;
        if (
$this->_type == 'jpg'$this->_type 'jpeg';
    }

    
// set maximum size of image, width or height - whichever is greater
    // 0 = no resizing
    
function setImageSize($size 0)
    {
        
$this->_size $size;
    }

    
// a wrapper for the createDropShadow function that forces it not to create the drop-shadow
    // $input      = directory/filename you wish to save to
    // $output     = directory/filename you wish to save to
    // $background = array of ints representing the RGB value, eg, array(255,255,255) - white
    // $isstring   = set to 1 if the $input will be a string representing the image, as you
    //               might draw from a database.
    
function createThumbnail($input ''$output ''$isstring FALSE)
    {
        
$this->createDropShadow($input$output, array(255,255,255), $isstring1);
    }

    
// does the grunt work of putting all the images together
    // $input      = directory/filename you wish to save to
    // $output     = directory/filename you wish to save to
    // $background = array of ints representing the RGB value, eg, array(255,255,255) - white
    // $isstring   = set to 1 if the $input will be a string representing the image, as you
    //               might draw from a database.
    
function createDropShadow($input ''$output ''$background = array(), $isstring FALSE$withoutshadow 0)
    {
        
// load the image
        
$ok FALSE;
        if (
$isstring$ok $this->loadImageFromString($input);
        else 
$ok $this->loadImage($input$this->_type);
        if (
$ok == FALSE)
        {
            
$this->_debug('createDropShadow''The image could not be loaded.');
            return 
FALSE;
        }

        
// resize the image
        
if ($this->_size)
        {
            
$sizes = @GetImageSize($input);
            if (
$sizes[0] > $sizes[1]) $this->resizeToSize(0$this->_size);
            else 
$this->resizeToSize($this->_size0);
        }
        
        
// apply dropshadow and/or save
        
if (!$withoutshadow)
        {
            
$this->applyShadow(dechex($background[0]) . dechex($background[1]) . dechex($background[2]));
            
$this->saveShadow($output$this->_type90);
        }
        else
        {
            
$this->saveFinal($output$this->_type90);
        }
    }

}


?>
3.6kb in size
last modified May 6, 2006 at 1:54pm
6342 views, 8162 downloads

ds_blcorner.png

230b in size
last modified May 6, 2006 at 1:54pm
9377 views, 9509 downloads

ds_bottom.png

419b in size
last modified May 6, 2006 at 1:54pm
7232 views, 8927 downloads

ds_brcorner.png

288b in size
last modified May 6, 2006 at 1:54pm
6074 views, 8989 downloads

ds_left.png

730b in size
last modified May 6, 2006 at 1:54pm
5754 views, 8760 downloads

ds_right.png

864b in size
last modified May 6, 2006 at 1:54pm
5642 views, 8726 downloads

ds_tlcorner.png

163b in size
last modified May 6, 2006 at 1:54pm
5414 views, 8694 downloads

ds_top.png

224b in size
last modified May 6, 2006 at 1:55pm
5292 views, 8796 downloads

ds_trcorner.png

203b in size
last modified May 6, 2006 at 1:55pm
5955 views, 8609 downloads

test.dropshadow.php

231b in size
last modified May 6, 2006 at 1:55pm
9252 views, 9174 downloads

test.originaldropshadow.php

1.45kb in size
last modified May 6, 2006 at 1:55pm
7113 views, 8182 downloads
list all projects :: this project's forum :: script in action
added Sep 20, 2002 at 5:44pm :: updated May 22, 2003 at 5:19am :: 12 files :: 64927 views

© Andrew Collington, 2002-2007.