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.


Problems with Notice

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


Joined: 06 Feb 2004
Posts: 5

PostPosted: Fri Feb 06, 2004 12:33 am    Post subject: Problems with Notice Reply with quote

Hi there, I?m new here, from spain. Wink

I find your script very, very nice and so useful for my purposes, providing a cropping utility online to a website that I'm trying to develop at the same time I?m learning PHP programming.

Now I?m learning a lot from your script, but I?m a novice, and first I'll try to modify your script for my purposes, before trying (at least) to develop one of my own.

I viewed the online demo and it looks great!, but in my server I got an error message.

Maybe you haven?t tested the script on a windows server or I?m doing anything wrong.

I?m testing it on WinXP, Apache 2.0.48 and PHP 4.3.4, the cropinterface works great, but when it sends the image to the browser after the crop select, the browser (Mozilla 1.6) says that the image cannot be shown because it has errors, and on I.Explorer I got a lot of crap like this : ????JFIF????S??`?????4?????3E??'?g????>??(+????M[?G?um?A?????G_???]Cc?h?&?g6??j????%
[...]

Maybe it?s a wrong header?

I use the default files downloaded from here, but changed the file name of the image to fit mine.

What am I doing wrong?

Update: If I change:

header('Content-type: image/jpeg');
$ci->showImage('jpg', 100);

for:

$ci->saveImage(dirname(__FILE__). '/cortes/corte_'. $_GET['file'] , 90);
$ci->showImage('jpg', 100);
$ci->flushImages();

I get the image cropped saved in the folder and the error quoted above, so it seems that class cropcanvas worksfine, but the function showImage() is the one in trouble, I'll keep investigating...

If you want to test the script on my server just tell me.

Thanks in advance, and sorry for my poor english.


Last edited by Mich on Fri Feb 06, 2004 5:05 am; edited 1 time in total
Back to top
View user's profile Send private message
Mich
Newbie


Joined: 06 Feb 2004
Posts: 5

PostPosted: Fri Feb 06, 2004 4:14 am    Post subject: Reply with quote

Hey!! I found how whats wrong!!

Of course as it was expected the headers were wrong, using this cropinterface.php:

PHP:
<?php <?php
ini_set
("display_errors","on");
// aca tengo escrita la clase
include "class.cronometro.php";
$casio = new cronometro();

    require_once 
'class.cropinterface.php';
    
$ci = new cropInterface(true);
    
    if (
$_GET['file'])
    {
            
$ci->loadImage($_GET['file']);
        
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
        
$ci->saveImage(dirname(__FILE__). '/cortes/corte_'$_GET['file'] , 90);
        
header('Content-type: image/jpg');
        
$ci->showImage('jpg'100);
        
$ci->flushImages();
        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('yo.jpg');
        
$ci->loadJavaScript();
    
    echo 
"segun mi reloj, este script se demoro " $casio->stop(true2) . " segundos en su ejecucion";
    
?>

</body>
</html> ?>


NOTE:class.cronometro.php is a class that shows how much time takes the script to generate.

I was getting a Notice: Undefined variable: position in E:\WWW\index\Pruebas\Crop\class.cropcanvas.php on line 271

which is resolved adding this to line 270:

if(!isset($position)){$position=0;}

Maybe there is a more cute way to fix this, but this works.

I also get a few more notice on cropinterface GUI page:
Notice: Undefined index: file in E:\WWW\index\Pruebas\Crop\cropinterface.php on line 10

This one is overrided if you change if ($_GET['file']) for if (isset($_GET['file']))

Notice: Undefined index: width in E:\WWW\index\Pruebas\Crop\class.cropinterface.php on line 154

and this adding if(!isset($this->crop['width'])){$this->crop['width'] = 0;} on line 153 on class.cropinterface.php

I really don?t know if adding this lines will change the way that script shall work, but seemingly not.

Now it's Great!! works now!!, great script, I?m going to vote 5 to your script at hotscripts now, thanks. Very Happy
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 Feb 06, 2004 5:28 am    Post subject: Reply with quote

Hi Mich,

Welcome to the baord! I'm really glad that you like the scripts and were able to work out your problems with getting it to run! Smile

The additions you made to the script wont cause anything bad to happen at all. The error messages you were getting from PHP were simply notices saying that I hadn't declared or initiated a variable. Though, thankfully, PHP is forgiving enough for this not to be a problem for a class this size. However, in the future I will endeavour to test with error reporting showing all notices as well as actual errors.

Just to let you know, I develop on a Win2k platform, running both Apache 1.3 and 2.0.48, MySQL 4.0, and using PHP 4.3.3 (though I should update!) with the bundled GD version (2.0.15). I also check the pages on Mozilla 1.6 and IE 6.0. This server the site and demos are running on is Unix, Apache version 1.3.29, MySQL version 4.0.15-standard, PHP version 4.3.4.

Have a great one!

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: Fri Feb 06, 2004 5:30 am    Post subject: Reply with quote

Oh, one more thing... where you have this bit of code:

PHP:
<?php 

        $ci
->loadInterface('yo.jpg'); 
        
$ci->loadJavaScript(); 
     
    echo 
"segun mi reloj, este script se demoro " $casio->stop(true2) . " segundos en su ejecucion"
    
?>


make it like this:

PHP:
<?php 

        $ci
->loadInterface('yo.jpg'); 
    echo 
"segun mi reloj, este script se demoro " $casio->stop(true2) . " segundos en su ejecucion"
        
$ci->loadJavaScript(); 
     
    
?>


because the loadJavaScript call should ideally be the last thing on the page before the closing body tag.

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


Joined: 06 Feb 2004
Posts: 5

PostPosted: Fri Feb 06, 2004 6:02 am    Post subject: Reply with quote

OK, thanks again, I?ve changed it.
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