andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. 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? If you wish to use any of these in a commercial system, please refer to the payment plan.


Sample PHP File for Calling Class (code resource)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator
View previous topic :: View next topic  
Author Message
motionbliss
Newbie


Joined: 11 Jul 2005
Posts: 21

PostPosted: Wed Jul 20, 2005 12:46 am    Post subject: Sample PHP File for Calling Class (code resource) Reply with quote

Although it?s not the prettiest or most refined thing, I thought this might be a valuable resource for someone just getting started.

PHP:
<?php

//
// alterimage.php
// version 1.0, July 19th, 2005
//
//
// syntax: 
//        alterimage.php?img=thepicture.jpg&resize=250,0
// switches:
//        ?img=thepicture.jpg                  || hosted locally in the "post_pictures" dir
//        ?url=http://foo.com/thepicture.jpg     || direct url to an external image
//        &resize=width,height                || replace width and height with numbers; zero means proportional
//        &noshadow                            || exclude the shadow; must use resize or no image will display
//

    
require "class.dropshadow.php";

    
$local $_GET['img'];
    
$url $_GET['url'];
    
    
$picture = new dropShadow(FALSE);
    
$picture->setShadowPath('./shadows/');

    if (isset(
$local)) {
        
$imageType substr($local, -3);
        
$picture->loadImage('./post_pictures/'.$local);         
    } elseif (isset(
$url)) {
        
$imageType substr($url, -3);
        
$picture->loadImageFromString(file_get_contents($url));
    }
    if (isset(
$resize)) {
        list(
$width$height) = explode(','$resize);
        
$picture->resizeToSize($width,$height);
    }
    if (isset(
$noshadow)) {
        
$picture->showFinal($imageType80); 
    } else {
        
$picture->applyShadow('FFFFFF');
        
$picture->showShadow($imageType80);
    } 
?>


Enjoy!

//craig
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Wed Jul 20, 2005 3:37 am    Post subject: Reply with quote

Nice one!

If other people want to integrate this, but don't want to use the rest of the code above, then you could add a function like this to your class:

PHP:
<?php function loadImageFromURL($url)
{
    return (
$this->loadImageFromString(file_get_contents($url)));
?>


and then just use the loadImageFromURL() method.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Drop Shadowed Thumbnail Creator All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group