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.


Can I Add Shadow to Actual file??

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


Joined: 06 Feb 2005
Posts: 3

PostPosted: Sun Feb 06, 2005 2:12 pm    Post subject: Can I Add Shadow to Actual file?? Reply with quote

Excellent script. I have been searching for something like this for a long time!

I have an online gallery, and would like to be able to create a thumbnail and drop shadow (which I have figured out) and would ALSO like to add a drop shadow to the actual file. I am getting an error with debug on that it can not create the image. Do I need to destory the original image in the class??

Can you post and example of how you can create a resized image of 0,0 and save back to the original file name..??

Thanks!
-clayton
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 Feb 07, 2005 4:03 am    Post subject: Reply with quote

Hi Clayton, and welcome to the board!

If you load an image, resize, apply a drop shadow to it, and then save it, you would certainly need to clear the image before yo ulaod up the full size and apply the drop shadow again. This is because there are a few class variables which get used to save the images along various stages and the save routines use those variables.

You can easily clear the information with the flushImages method. It's probably best you give two calls to that - one with 0 as the parameter and the other as 1.

So for example, you might have something like:

PHP:
<?php

    
require_once('class.dropshadow.php');
    
$ds =& new dropShadow(FALSE);
    
$ds->setShadowPath('./shadows/');

    
$ds->loadImage('original.jpg');
    
$ds->resizeByPercent(500);
    
$ds->applyShadow('CCCCCC');
    
$ds->saveShadow('thumbnail.jpg');

    
$ds->flushImages(0);
    
$ds->flushImages(1);

    
$ds->loadImage('original.jpg');
    
$ds->applyShadow('CCCCCC');
    
$ds->saveShadow('shadowed.jpg');

?>


If you're still getting errors then post them up.

Regards,

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


Joined: 06 Feb 2005
Posts: 3

PostPosted: Mon Feb 07, 2005 6:10 pm    Post subject: Reply with quote

Thanks for the reply!

This is the code I currently have. The only difference I have is that I'm trying to save to the same file name. basically overwriting the original file. I did try to have a flush(0) in there after the last applyShadow, but that still did not give me the results I was after. Any insight??

PHP:
<?php $thumbsfilenamepath="$thumbsdir/$file";
    if (!@
file_exists($thumbsfilenamepath)){

      
$ds = new dropShadow(TRUE);
      
$ds->setShadowPath('./images/shadows/');
      
$ds->loadImage($filenamepath);
      
$ds->resizeToSize(125125);
      
$ds->applyShadow('FFFFFF');
      
$ds->saveShadow($thumbsfilenamepath);
      
$ds->flushImages(0);
      
$ds->flushImages(1);

      
$ds->loadImage($filenamepath);
      
$ds->applyShadow('FFFFFF');
      
$ds->saveShadow($filenamepath);

    } 
?>


Here is the output I am getting in DEBUG mode:


Debug message from function resizeToSize: Image size is 125 / 89.375

Quote:

Debug message from function applyShadow: Original image size = 125/89 : Drop shadowed image size = 141/105

Debug message from function applyShadow: There is no resized image, so the original image is being used.

Debug message from function applyShadow: Original image size = 400/286 : Drop shadowed image size = 416/302

Debug message from function _saveImage: Could not save the output file 'images/galleries/misc/boston/boston_1.jpg' as a jpeg.



Thanks a lot!
-clayton



ps...
I also re wrote the resizeToSize function to keep porportions when resizing. when using 125,125 it would make the image 125 square. I rewrote it to resize the max length to whatever is specified, and resize the other to keep things porportional

PHP:
<?php //
    // resize the original image to a certain pixel size
    // if 0 is supplied for $x or $y then the resize will be proportional
    //
    
function resizeToSize($x$y)
    {
        
$nx $x;
        
$ny $y;
        
$orig_x = @ImageSX($this->_imgOrig);
        
$orig_y = @ImageSY($this->_imgOrig);
        if (
$orig_x<$orig_y$x=0;
        if (
$orig_y<$orig_x$y=0;
        if (
$x == 0) list($nx$ny) = $this->_getProportionalSize(0$y);
        if (
$y == 0) list($nx$ny) = $this->_getProportionalSize($x0);
        
$this->_debug('resizeToSize'"Image size is $nx / $ny");
        return (
$this->_resizeImage($nx$ny'resizeToSize'));
    } 
?>
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Tue Feb 08, 2005 5:47 am    Post subject: Reply with quote

Quote:
Debug message from function _saveImage: Could not save the output file 'images/galleries/misc/boston/boston_1.jpg' as a jpeg.


This is the key here, I think. It's basically saying that you cannot overwrite the original file. Make sure that your webserver/php have permissions to write to that file.

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


Joined: 06 Feb 2005
Posts: 3

PostPosted: Tue Feb 08, 2005 9:43 am    Post subject: Reply with quote

How would I tell that??

Is there any sneaky code to delete the original file before trying to save the new shadowed???

any help appreciated!
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Tue Feb 08, 2005 1:09 pm    Post subject: Reply with quote

Are you able to log into the shell? If so then you can do 'ls -l' to see the file permissions. You could change them with the 'chmod' command.

How did you get the image there to begin with? Did you FTP it there? If so, your FTP client might enable you to change the file permissions.

Of course, it might also be the folder permissions, so you'd probably want to check them, too - just in case.
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