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.


Save??

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


Joined: 14 Nov 2004
Posts: 2

PostPosted: Sun Nov 14, 2004 5:27 am    Post subject: Save?? Reply with quote

Hi,

I want to use the croppingscript on my website - a newswebsite.
On the frontpage I want to use a picture, but only a fragment of it.

But when I use the cropping-script it doesn's save the cropped image.

Why not?

PHP:
<?php <?php

    
require_once 'class.cropinterface.php';
    
$ci = new cropInterface();
    
    if (
$_GET['file'])
    {
        
$ci->loadImage($_GET['file']);
        
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
        
header('Content-type: image/jpeg');
        
$ci->showImage('jpg'100);
        
$ci->saveImage("../pictures/thumb/{$_REQUEST['file']}"100);
        exit;
    }

?>

<html>

<head>
    <style type="text/css">
        body, td, p
        {
            font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
            font-size: 10px;
        }
        
        #submit
        {
            font-size: 10px;
            font-family: "MS Sans Serif", Geneva, sans-serif;
            height: 23px;
            background-color: #D4D0C8;
            border: 0px;
            padding: 3px,5px,3px,5px;
            width: 100%;
        }
    </style>
</head>
<body>

    <?php

        $ci
->loadInterface("{$_REQUEST['filename']}");
        
$ci->loadJavaScript();
    
?>

</body>
</html> ?>
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 Nov 15, 2004 3:31 am    Post subject: Reply with quote

Hi Ton, and welcome to the board.

Try putting in the full path for the save location, rather than the relative path. If you want to use the relative path, wrap the path up in the realpath function.

Make sure that the path you're trying to write to has write permissions for whatever user PHP runs under.

If all else fails, instantiate the class with 'true' as a parameter to turn on debugging to see if that kicks out anything that might help answer the problem.

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


Joined: 14 Nov 2004
Posts: 2

PostPosted: Wed Nov 17, 2004 8:22 am    Post subject: Reply with quote

First of all, there is no function realpath.

Secondly,
I don't think there is a code which saves the image in the function:
PHP:
<?php 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));
        
$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;
    } 
?>


I don't see a bit of code, where is described that the image will be saved in a certain path.
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Wed Nov 17, 2004 12:10 pm    Post subject: Reply with quote

Ton wrote:
First of all, there is no function realpath.


http://uk.php.net/realpath

Ton wrote:
I don't see a bit of code, where is described that the image will be saved in a certain path.


The $filename parameter is the path and file name. This is used in the image saving function calls which look like this in the class:

Code:
if ($ext == 'png') $saved = $func($this->_imgFinal, $filename);
if ($ext == 'jpeg') $saved = $func($this->_imgFinal, $filename, $quality);


The $func is a dynamically created function name (yes, it's a completely valid way of calling a function). You'll find it calls either imagejpeg or imagepng depending on the file type.

http://uk2.php.net/imagejpeg
http://uk2.php.net/imagepng
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