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.


Help

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


Joined: 04 Dec 2004
Posts: 1
Location: Banja Luka, RS, BiH

PostPosted: Sat Dec 04, 2004 7:14 am    Post subject: Help Reply with quote

Hi.

I need to out file be dimensions 150 x 150.
Can you give my example hav to make.
Sorry if you don't understudy because I don't speak English very
Back to top
View user's profile Send private message Visit poster's website
amnuts
Site Admin


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

PostPosted: Sat Dec 04, 2004 11:52 am    Post subject: Reply with quote

Hi smcom and welcome to the board!

Okay... If you want to use the cropping interface, you'd have something like this:

PHP:
<?php <?php

    
require_once('class.cropinterface.php');
    
$ci =& new cropInterface();
    
$ci->setCropDefaultSize(150150);
    
$ci->setResizing(false);
    
    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);
        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('mypicture.jpg');
        
$ci->loadJavaScript();

    
?>

</body>
</html> ?>


This will give you a fixed crop size of 150x150 pixels, and not allow you to resize that image. Obviously, if you want to save the file etc., then you'd change these lines:

PHP:
<?php header('Content-type: image/jpeg');
$ci->showImage('jpg'100);
exit; 
?>


for whatever you wanted to do.

If you wanted to crop the image automatically without the cropping interface, then you'd have something like:

PHP:
<?php

    
require_once('class.cropcanvas.php');
    
$cc =& new canvasCrop();

    
$cc->loadImage('your_image.png');
    
$cc->cropBySize(150150ccCENTRE);
    
$cc->saveImage('result.png');

?>


You would change the [b]ccCENTRE[b] for whatever area you wanted to make the crop at. (ccTOPLEFT, ccBOTTOMRIGHT, etc.)

If you wanted to resize the image first, so that the minimum dimension was 150px, and then crop off the excess giving you a nice square image with the majority of the picture in it, then refer to my post on this thread:

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

Hope that helps!

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