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.


Drop Shadow Script - Error Messages...

 
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
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Sun Jun 13, 2004 8:06 pm    Post subject: Drop Shadow Script - Error Messages... Reply with quote

Hi there, firstly let me thank you for an amazing script - nice job!

What I would really like to do with this is have an online form where people can upload any picture they wanted (jpg, jpeg, png, whatever) and have your script resize and add the shadow on the fly then saving the original (uploaded) image along with the newly created (shadowed) thumbnail image with 'thumb_' added to the filename (would be nice if the 'thumb_<filename>.xxx' and original picture were put in the same directory too).

I have basic knowledge with php but am by no means a 'top geezer' Wink when it comes to writing something like this so your help would be fantastic.

I am using the latest version of the GDLib (at time of writing) and my development server is made up of Apache Server v2.0.48, ActivePerl v5.8.3.809, PHP v4.3.7, and MySQL v4.0.18 all running from a Windows XP Pro box if it helps.

Thank you again for such a top script.

Hope you can help out, Bri
Back to top
View user's profile Send private message
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Sun Jun 13, 2004 8:18 pm    Post subject: P.S. Reply with quote

So you know where I am at the moment I have the followng:

Quote:
/drop_shadow/
> class.dropshadow.php
> class.originaldropshadow.php
> test.dropshadow.php
> test.originaldropshadow.php

/drop_shadow/images/
> image1.jpg
> image2.jpg
> image3.jpg

/drop_shadow/shadows/
> ds_blcorner.png
> ds_bottom.png
> ds_brcorner.png
> ds_left.png
> ds_right.png
> ds_tlcorner.png
> ds_top.png
> ds_trcorner.png


When I run '/drop_shadow/test.originaldropshadow.php' I can select my image files no problem but when trying to process I get the following messages:
Quote:
Debug message from function resizeToSize: Image size is 100 / 149.48805460751

Debug message from function applyShadow: Original image size = 100/149 : Drop shadowed image size = 116/165

And then the image is created and shown in the browser, but if for instance I try to create another shadowed image I get the following:
Quote:
Debug message from function resizeToSize: Image size is 100 / 151.51515151515

Debug message from function applyShadow: Original image size = 100/151 : Drop shadowed image size = 116/167

And the old image is still displayed? - but if I refresh my browser window the correct image (all resized and shadowed) is displayed.

Bri
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Mon Jun 14, 2004 3:25 am    Post subject: Reply with quote

Hi Bri, and welcome to the board!

To remove the debugging information, instantiate your class with either no parameters or 'false' as the parameter, such as:

PHP:
<?php $ds = new dropShadow(false); ?>


This will stop the debugging information from being shown. You're probably not getting the new image to be displayed (I'm assuming you're using the showShadow or showFinal methods) because the http headers have already been set to text/html because of hte debugging strings.

Okay, now on to what you want to do... Fairly standard stuff. Assuming you've already setup your form and have submitted it and done validity checking on the file type, size, etc.

PHP:
<?php

// sanity checks done, so save files

if (move_uploaded_file($_FILES['your_form_filename']['tmp_name'], $path_and_filename_to_upload_to)) { 
    
$ds->setShadowPath('./shadows/');
    
$ds->loadImage($path_and_filename_to_upload_to);
    
$ds->resizeByPercent(500);
    
$ds->applyShadow('FFFFFF');
    if (!(
$ds->saveShadow($path_and_filename_to_save_thumbnail_to'jpg'90))) {
        echo 
'Cannot save thumbnail.';
    }
} else { 
   echo 
'Cannot save uploaded file.';


?>


Naturally, you'd change $ds->resizeByPercent(50, 0); to be whatever your resizing method and sizes would be, and $ds->applyShadow('FFFFFF'); to have your own background colour... And, obviously, you'd put in your own paths and such.

HTH

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Mon Jun 14, 2004 5:57 am    Post subject: Reply with quote

Hi Andy, thank you very much for your help regarding this.

This is the gallery script I am using: http://www.circle.ch/scripts/code/autogallery.zip.

As you can see it already makes its own thumbnails (but they are a bit plain looking.

Is there anyway I could add this to use your drop shadow effect/script?

Regards, Bri
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Mon Jun 14, 2004 6:05 am    Post subject: Reply with quote

Sure you can. Just re-write the 'resize' function in the 'autogallery.inc.php' file so that 1) is creates an instance of hte dropshadow class, 2) does the while loop, 3) loads the file, resizes and saves, 4) does the bit with the idxfile saving.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Wed Jun 16, 2004 6:42 pm    Post subject: I'm lost already - lol Reply with quote

Hi amnuts, now I'm lost lol - I have no idea what to add/remove to make it call your script so that a drop shaddow gets added and not the standard picture behind the GD created thumbnail.

Any suggestions?

Thank you in advance, Bri
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Thu Jun 17, 2004 3:01 am    Post subject: Reply with quote

I can't promise this to work right off the page (it's too early!), but it'll put you on the right track, nonetheless.

PHP:
<?php

    
function resize() 
    {
        static 
$ds null;
        static 
$tpl_size = array();
        
        require_once(
'/path/to/class.dropshadow.php');
        if (
$ds === null) {
            
$ds =& new dropShadow;
            
$ds->setShadowPath('/path/to/shadow/images');
        }
        
        if (empty(
$tpl_size)) {
            
$tpl_size getimagesize($this->tpl);
        }

        
$count 0;
        
$d dir($this->src);
        
$fp fopen("$this->path/$this->idxfile"'a+');
        
        if (
$fp) {
            while (
false !== ($entry $d->read())) {
                if (
eregi(".+\.jp[e]{0,1}g$"$entry)) {
                    if (
$ds->loadImage("$this->path/_$this->prefix$entry")) {
                        
$size getimagesize("$this->path/_$this->prefix$entry");
                        if (
$size[0] > $size[1]) {
                            
$ds->resizeToSize($tpl_size[1], 0);
                        } else {
                            
$ds->resizeToSize(0$tpl_size[0]);
                        }
                        
$ds->applyShadow('FFFFFF');
                        
$ds->saveShadow("$this->path/_$this->prefix$entry"null90);
                        
$ds->flushImages();

                        
// create an index file with "thumbnailfile, filename, width, height"
                        
if (!strstr(join(''file("$this->path/$this->idxfile")), $entry)) {
                            
fwrite($fp"_$this->prefix$entry,$entry,{$size[0]},{$size[1]}\n"strlen("_$this->prefix$entry,$entry,{$size[0]},{$size[1]}\n"));
                        }
                    }
                }
            }
            
fclose($fp);
        }
        
$d->close();
    }


?>


Obviously you'll need to change the path strings to be where you've got them located, and the shadow background colour if you don't want it to be white.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Thu Jun 17, 2004 9:31 am    Post subject: Drop Shadow Reply with quote

Hi there amnuts, thank you so much for your help - It is a rare thing to have such help from a stranger Wink

I will have a play with the code and see what I can come up with.

Thank you again, Bri

P.S.
I will let you know how I get on Very Happy
Back to top
View user's profile Send private message
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Tue Jun 22, 2004 6:01 am    Post subject: cant sort it mate... Reply with quote

Hi there, sorry to say I could not get it to work so I ended up just having pictures without any dropshadows - shame really as your script was just what I was looking for...

Guess I will have to do it all manually in photoshop or stick with GD created thumbnails with no shadows. Crying or Very sad

Bri
Back to top
View user's profile Send private message
Bri
Newbie


Joined: 13 Jun 2004
Posts: 9

PostPosted: Tue Jul 06, 2004 1:43 pm    Post subject: working now Reply with quote

Hi, just another thank you for helping me finally get the gallery script to speak with your drop shadow script.

For anyone reading this, top script from a top bloke- nuff said really!

One happy customer, Bri
Back to top
View user's profile Send private message
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