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.


Crop Interface not always working

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


Joined: 27 Sep 2005
Posts: 8

PostPosted: Mon Oct 31, 2005 3:07 pm    Post subject: Crop Interface not always working Reply with quote

Good day folks,

I have been trying to use this sweet script to make a photo upload interface for a client but have been running into problems sometimes when using the crop interface. It works when cropping smaller areas but often when I try to crop a large portion of the image it fails.

I have played around with the code a lot without any luck.

Here is my code. Let me know if you have any suggestions! I'm sure you guys do! Maybe you can show me how to shorten this down a bit as well? Seems wrong to open and close this image so many times - but how else would I do this?

Thanks!!

PHP:
<?php <?php
   
    
if ($_GET['file'])
    {
    
        
// NO ERRORS SO ADD INFORMATION TO THE DATABASE
        
include("database/db.php");
        
$result mysql_query("INSERT INTO photos (id) VALUES ('')"$db);        
        
$id mysql_insert_id();
        
        
// CROP PHOTO BASED ON INTERFACE
        
require_once 'includes/class.cropinterface.php';
        
$ci = new cropInterface();
        
$ci->loadImage("../images/gallery/photos/temp.jpg");
        
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
        
$ci->saveImage("../images/gallery/photos/temp.jpg");
        
$ci->flushImages();

        
// RESIZE PHOTO TO CORRECT SCALE
        
include('includes/class.dropshadow.php'); 
        
$ds =& new dropShadow(); 
        
$ds->setShadowPath('./'); 
        
$ds->loadImage("../images/gallery/photos/temp.jpg");
        
$ds->resizeToSize(532303);
        
$ds->saveFinal("../images/gallery/photos/" $id ".jpg"'jpg'80); 
        
$ds->flushImages();
        
        
// DELETE THE TEMP FILE NOW
        
$del_temp "../images/gallery/photos/temp.jpg";
        
unlink($del_temp); 
        
        
// RESIZE PHOTO TO THUMBNAIL SCALE
        
$ds =& new dropShadow(); 
        
$ds->setShadowPath('./'); 
        
$ds->loadImage("../images/gallery/photos/" $id ".jpg");
        
$ds->resizeToSize(9353);
        
$ds->saveFinal("../images/gallery/thumbnails/" $id ".jpg"'jpg'80); 
        
$ds->flushImages();
        
        
$cc = new canvasCrop();
        
$cc->loadImage("../images/gallery/thumbnails/" $id ".jpg");
        
$cc->cropToSize('53''53'ccCENTER);
        
$cc->saveImage("../images/gallery/thumbnails/" $id ".jpg");
        
$cc->flushImages();
        
        
?>
        <html>
        <body>

        <a href="gallery_photos.php?page=1&rpp=24&display=thumbnails&category=all&action=edit&id=<?=$id?>">Go to image</a>
        </body>
        </html>
        <?
        
        
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>
<script Language="javascript">self.moveto(0,0);self.resizeto(screen.availWidth,screen.availHeight);</script>
    <?php
    
    
require_once 'includes/class.cropinterface.php';
    
$ci = new cropInterface();
    
    
$ci->setCropDefaultSize(532303); 
    
$ci->setCropMinSize(532303); 
    
$ci->setResizing(false); 
    
$ci->loadInterface("../images/gallery/photos/temp.jpg");
    
$ci->loadJavaScript();

    
?>

</body>
</html> ?>
[/php][/code]
Back to top
View user's profile Send private message
JonathanReinink
Newbie


Joined: 27 Sep 2005
Posts: 8

PostPosted: Tue Nov 01, 2005 4:55 pm    Post subject: Reply with quote

Any thoughts at all? Smile
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 02, 2005 9:11 am    Post subject: Reply with quote

Hi,

Not sure why it's not working for larger images... How large are we talking, and what part doesn't actually work?

As for trimming down the code, you could try something like the following, which I warn you I have not tested at all so you may find errors in there! It's just provided as a guide... Smile

PHP:
<?php <?php

    
require_once('includes/class.cropinterface.php');
    require_once(
'includes/class.dropshadow.php');
    
    
$ci =& new cropInterface();
    
$ds =& new dropShadow(); 
    
$ds->setShadowPath('./'); 

    if (isset(
$_GET['file']) && $_GET['file'] != '') {
        
// NO ERRORS SO ADD INFORMATION TO THE DATABASE
        
include("database/db.php");
        
$result mysql_query("INSERT INTO photos (id) VALUES ('')"$db);        
        
$id mysql_insert_id();
        
        
// CROP PHOTO BASED ON INTERFACE
        
$ci->loadImage("../images/gallery/photos/temp.jpg");
        
$ci->cropToDimensions($_GET['sx'], $_GET['sy'], $_GET['ex'], $_GET['ey']);
        
$ds->_imgOrig $ci->_imgFinal;
        
$ds->resizeToSize(532303);
        
$ds->saveFinal("../images/gallery/photos/" $id ".jpg"'jpg'80); 
        
$ds->flushImages(1);
        
$ds->resizeToSize(9353);
        
$ds->saveFinal("../images/gallery/thumbnails/" $id ".jpg"'jpg'80); 
        
$ci->flushImages();
        
$ci->_imgOrig $ds->_imgFinal;
        
$ci->cropToSize('53''53'ccCENTER);
        
$ci->saveImage("../images/gallery/thumbnails/" $id ".jpg");
        
$ci->flushImages();
        
?>
<html>
<body>

<a href="gallery_photos.php?page=1&rpp=24&display=thumbnails&category=all&action=edit&id=<?php echo $id?>">Go to image</a>
</body>
</html>
<?        
        
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>
<script Language="javascript">self.moveto(0,0);self.resizeto(screen.availWidth,screen.availHeight);</script>
<?php
    
    $ci
->setCropDefaultSize(532303); 
    
$ci->setCropMinSize(532303); 
    
$ci->setResizing(false); 
    
$ci->loadInterface("../images/gallery/photos/temp.jpg");
    
$ci->loadJavaScript();

?>
</body>
</html> ?>
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
JonathanReinink
Newbie


Joined: 27 Sep 2005
Posts: 8

PostPosted: Thu Nov 03, 2005 10:59 am    Post subject: Reply with quote

Hello amnuts, that code works, so I'm guessing that's a better way of doing it - HOWEVER, I'm STILL having trouble when I crop only horizontal photos using the interface and only when I crop as much area as possible within the constrained proportions.

It's almost like the system won't accept the size of the photos, but what I'm actually doing is uploading about a 1 mb file, and resizing it to about 900px X whatever wide so that the crop interface isn't HUGE.

Any suggestions? This is really weird. Maybe an issue with my server? Who knows.
Back to top
View user's profile Send private message
JonathanReinink
Newbie


Joined: 27 Sep 2005
Posts: 8

PostPosted: Mon Nov 14, 2005 11:41 am    Post subject: Reply with quote

Any thoughts?

I know this does not make any sense. Sad
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 23, 2005 9:15 am    Post subject: Reply with quote

Hmm.. Not sure. If you want to email me one of the pictures you're specifically having a problem with I could try it out and see if I get the same issue.

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


Joined: 27 Sep 2005
Posts: 8

PostPosted: Thu Jan 12, 2006 9:03 am    Post subject: Reply with quote

Hello amnuts, I finally figured out the issue. (Using your very handy debugging features.

Basically the problem is that my crop interface is not work when I scale the crop area to as big as it can go. It returns the error that the crop size is larger than the photo.

So I adjusted the crop code to this:

$ci->cropToDimensions(($_GET['sx']+1), ($_GET['sy']+1), ($_GET['ex']-1), ($_GET['ey']-1));

Any thoughts to why this is happening and how this can be avoided? Thanks!! Smile
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Tue Jan 17, 2006 8:15 am    Post subject: Reply with quote

Hi,

Sounds to me like it might be the border issue I mentioned here:

http://php.amnuts.com/forums/viewtopic.php?t=292

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