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.


Resizing Question

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


Joined: 29 Mar 2004
Posts: 13

PostPosted: Mon Mar 29, 2004 1:49 am    Post subject: Resizing Question Reply with quote

This script is great because it can add shadows AND create thumbnails for you. But one problem is the resizing.

Say you have a large image and you call the script to thumbnail and shadow it. You tell the script to resize to a maximum width or a maximum height but not both. Eg: I wanted a wallpaper to be resized at a max of 96 wide and 96 high.

Is there a way to implement that?
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 Mar 29, 2004 2:31 am    Post subject: Reply with quote

Hi, and welcome to the board!

You could do something like:

Code:
$size = getimagesize('picture.jpg');
if ($size[0] > $size[1]) {
    $ds->resizeToSize(96, 0);
} else {
    $ds->resizeToSize(0, 96);
}


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


Joined: 29 Mar 2004
Posts: 13

PostPosted: Mon Mar 29, 2004 3:40 am    Post subject: reply Reply with quote

heres my current code which allows changing details through the url:
PHP:
<?php 

    
list($x$y) = explode(','$_GET['size']); 

    include 
"class.dropshadow.php"

    
$ds = new dropShadow(FALSE); 
    
$ds->setShadowPath('./'); 
    
$ds->loadImage('./../../'.$_GET['input']); 
    if (
$x || $y$ds->{$_GET['show']}($x$y); 
    
$ds->$show($x$y); 
    if (
$_GET['shadow'] == 1
    { 
        
$ds->applyShadow($_GET['colour']); 
        
$ds->showShadow('jpg'); 
    } 
    else 
$ds->showFinal('jpg');     

?>


is there a way to implement this "maximum resize" thing in the url? say for eg:
http://site.com/dropshadow.php?shadow=1&input=gallery/thumbnails/aa.gif&maxsize=96,96
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 Mar 29, 2004 6:23 am    Post subject: Re: reply Reply with quote

TheBuggerGuy wrote:
is there a way to implement this "maximum resize" thing in the url? say for eg:
http://site.com/dropshadow.php?shadow=1&input=gallery/thumbnails/aa.gif&maxsize=96,96


The way the resizeToSize function works is that if you supply 0 as one of the parameters, the image is going to be resized proportionally using the size you provided as the maximum size. Because of this, you only need to pass one size along in the query string, which you will use as the max value.

So you might have something like:

PHP:
<?php

    
require_once "class.dropshadow.php";

    
$ds = new dropShadow(FALSE);
    
$ds->setShadowPath('./');
    
$ds->loadImage("./../../{$_GET['input']}");

    
$size getimagesize("./../../{$_GET['input']}");
    if (
$size[0] > $size[1]) {
        
$ds->resizeToSize($_GET['maxsize'], 0);
    } else {
        
$ds->resizeToSize(0$_GET['maxsize']);
    }

    if (
$_GET['shadow'] == 1) {
        
$ds->applyShadow($_GET['colour']);
        
$ds->showShadow('jpg');
    } else {
        
$ds->showFinal('jpg');     
    }

?>


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


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

PostPosted: Mon Mar 29, 2004 6:30 am    Post subject: Re: Resizing Question Reply with quote

TheBuggerGuy wrote:
Say you have a large image and you call the script to thumbnail and shadow it. You tell the script to resize to a maximum width or a maximum height but not both. Eg: I wanted a wallpaper to be resized at a max of 96 wide and 96 high.


You know.. I just re-read this and took it a different way. Originally, I thought you were trying to resize an image proportionally so that it was either 96 pixels wide, or 96 pixels in height, whichever is the greatest. That's what my replies have been geared towards. However, going over it again I read it that you want the resulting image to be 96x96 pixels in dimensions. This is possible by just using:

Code:
$ds->resizeToSize(96, 96);


However, if your image is not square in proportions to start with, then it will cause the thumbnail to not look quite correct (because you're not taking into account the proportions of the image).

What you could do, if you wanted to retain proportions and not mind loosing some of your image, is resize and crop. You'd resize to 96 pixels as your MINIMUM dimension size. Then use the cropping class to crop the image in the centre to a size of 96x96 pixels. You'll end up with an image that retains it's proportions, but is still a square 96x96.

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


Joined: 29 Mar 2004
Posts: 13

PostPosted: Fri Apr 02, 2004 2:32 am    Post subject: reply Reply with quote

what i meant was that i could supply the MAXIMUM size for the image and it would resize proportinally to fit into that maximum size
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 Apr 02, 2004 3:10 am    Post subject: Re: reply Reply with quote

TheBuggerGuy wrote:
what i meant was that i could supply the MAXIMUM size for the image and it would resize proportinally to fit into that maximum size


Okay, I got it right the first time, then. See my second reply to this thread.

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