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.


Just a observation

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


Joined: 13 Jan 2005
Posts: 3
Location: Mexico

PostPosted: Thu Jan 13, 2005 7:22 pm    Post subject: Just a observation Reply with quote

Greetings Andy, hey SUPERB coding man... really cool...

I've been looking at it and I found this... what happends when you try to save an image with jpg file type?? the save function wont work 'cause it takes the extention of the file and it wont save it so imagejpeg never is executed... so its just a small fix to the function... (maybe its already fixed... if so just forget this post... Wink )

Quote:
function saveImage($filename, $quality = 100)
{
if ($this->_imgFinal == null)
{
$this->_debug('saveImage', 'There is no processed image to save.');
return false;
}

$ext = strtolower($this->_getExtension($filename));

if($ext == "jpg")
$ext = "jpeg";


$func = "image$ext";

if (!@function_exists($func))
{
$this->_debug('saveImage', "That file cannot be saved with the function '$func'.");
return false;
}

$saved = false;
if ($ext == 'png') $saved = $func($this->_imgFinal, $filename);
if ($ext == 'jpeg') $saved = $func($this->_imgFinal, $filename, $quality);
if ($saved == false)
{
$this->_debug('saveImage', "Could not save the output file '$filename' as a $ext.");
return false;
}

return true;
}
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
amnuts
Site Admin


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

PostPosted: Fri Jan 14, 2005 3:43 am    Post subject: Re: Just a observation Reply with quote

Hi Burguez, and welcome to the board!


Glad you like the code, and thanks for posting up. But it will save jpgs, no worries... Smile

Do you see the line just above the part you placed in? It's this one:

PHP:
<?php $ext strtolower($this->_getExtension($filename)); ?>


That goes off to a method which pretty much does what you included. It looks like this:

PHP:
<?php function _getExtension($filename)
    {
        
$ext  = @strtolower(@substr($filename, (@strrpos($filename".") ? @strrpos($filename".") + : @strlen($filename)), @strlen($filename)));
        return (
$ext == 'jpg') ? 'jpeg' $ext;
    } 
?>


the return statement being the jpg/jpeg check, of course.

Cheers,

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