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.


Thank You

 
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 -> Crop Canvas
View previous topic :: View next topic  
Author Message
Crashin
Newbie


Joined: 19 Nov 2003
Posts: 2
Location: Fort Collins, CO, USA

PostPosted: Wed Nov 19, 2003 4:35 pm    Post subject: Thank You Reply with quote

Hi Andrew...can I just tell you how appreciative I am of you for sharing your work. I've only just found your site, and I feel like I've found a treasure trove of new goodies! Very Happy

I've gotten the dropshadow class working great, and even have tried it out with a database photo gallery to auto-generate thumbs. Nice! But, then I discovered your crop canvas class and it is actually more of what I've been searching for. All of my images can be the same dimensions!!!

~*Later*~

I was originally going to ask you a question, in this message, about getting the class to work, but in doing so discovered what I was doing wrong. So, nevermind the question. This is merely KUDOS to you! Thanks for having so much class!
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 Nov 20, 2003 3:47 am    Post subject: Reply with quote

Hi Crashin,

Welcome to the board and thanks for your kind words!!

You might want to consider using both of the classes to show your thumbnails. That's what I did for the gallery I'm working on. That way all my thumbnail images are the same size, with a drop shadow, and my large image can be any dimension.

It's nowhere near finished yet, but check out an example link:

http://collingtons.amnuts.com/gallery.php?album_id=2

I first resize the image to the largest dimension (so if my thumbnail size is to be 100x100 I would resize the large image to have the minimum dimension of 100 on either height or width), then I crop it, then I drop-shadow it.

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


Joined: 19 Nov 2003
Posts: 2
Location: Fort Collins, CO, USA

PostPosted: Thu Nov 20, 2003 10:21 am    Post subject: Reply with quote

That is sweet! I like that a lot. Would you mind sharing the code you use to go about calling the two classes to accomplish that effect? Also, I'm going to need to set up my rows EXACTLY the way you did (i.e. with 8 to a row). How did you do that, if you don't mind sharing some more secrets...

Lastly, how's about sharing some of that pint!!!

Thanks again!

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


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

PostPosted: Fri Nov 28, 2003 7:42 am    Post subject: Reply with quote

Hi Chrasin,

First off; the pint was way to lovely to share with anyone! Smile

Secondly; The code for the cropping demo is posted up in another thread. Hope it helps!

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


Joined: 01 Dec 2003
Posts: 2

PostPosted: Mon Dec 01, 2003 4:17 am    Post subject: Suggestion Reply with quote

Hi Andy,

I made this little class that extends your canvasCrop.

With the redimToSize function you can resize the picture to certain width and height, keeping the aspect ratio, and if you set the variable $crop = TRUE, your image is then cropped to the size you asked (if the resizing didn't reach the width and height).

PHP:
<?php

class imgRedim extends canvasCrop
{

    function 
imgRedim($debug FALSE)
    {
        
$this->canvasCrop($debug);
    }
    
    function 
redimToSize($x$y$crop FALSE)
    {
        return (
$this->_reSize($x$y$crop'redimToSize'));
    }
    
    function 
_reSize($nx$ny$crop FALSE$function)
    {
        
        if (
$this->_imgOrig == NULL)
        {
            
$this->_debug($function'The original image has not been loaded.');
            return 
FALSE;
        }
        if ((
$nx <= 0) || ($ny <= 0))
        {
            
$this->_debug($function'The image could not be resized because the size given is not valid.');
            return 
FALSE;
        }
        
        
$ox = @ImageSX($this->_imgOrig);
        
$oy = @ImageSY($this->_imgOrig);
        
$nnx $nx;
        
$nny $ny;
        
        if ((
$nx $ox) || ($ny $oy))
        {
            
$this->_debug($function'The image could not be resized because the size given is larger than the original image.');
            return 
FALSE;
        }
    
        if(
$ox>$oy)
        {
            
$nx $ox*$ny/$oy;
        }
        elseif(
$ox<$oy)
        {
            
$ny $oy*$nx/$ox;    
        }
    
        if (
$this->_gdVersion == 2)
        {
            
$this->_imgFinal = @ImageCreateTrueColor($nx$ny);
            @
ImageCopyResampled($this->_imgFinal$this->_imgOrig0000$nx$ny$ox$oy);
        }
        else
        {
            
$this->_imgFinal = @ImageCreate($nx$ny);
            @
ImageCopyResized($this->_imgFinal$this->_imgOrig0000$nx$ny$ox$oy);
        }

        if(
$crop AND $nx!=$nnx AND $ny!=$nny)
        {
            
$_imgOrigCopy $this->_imgOrig;
            
$this->_imgOrig $this->_imgFinal;
            
$result $this->cropToSize($nnx$nny);
            
$this->_imgOrig $_imgOrigCopy;
            unset(
$_imgOrigCopy);

            return 
$result;
        
        }
        
        return 
true;
        
    }

}

?>


Best regards,
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 Dec 01, 2003 5:07 am    Post subject: Re: Suggestion Reply with quote

Hi Db,

Welcome to the board, and what a corker of a first post!

db wrote:
I made this little class that extends your canvasCrop.


This is a really nice little extension to the cropping class, thanks!

If you haven't already, you may like to check out my dropshadow/thumbnail class, as it contains a lot of extra resizing options. Perhaps I should combine the two and have one super resizing class?

Anyway; great job! Do you use this in any particular application?

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


Joined: 01 Dec 2003
Posts: 2

PostPosted: Mon Dec 01, 2003 9:28 pm    Post subject: ... Reply with quote

Hey Andy,

That was all I was missing in the class. A simple resizing function. Before I crop I want to get the picture to a certain size.

It's a great idea to combine the two classes. I believe it's going to fully satisfy all our needs.

I use your class with my extension to manipulate the images sent to this website:

http://www.haggai.com.br

By the way, I'm from Brazil =) and the website is in portuguese.

Best regards,

David
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 -> Crop Canvas 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