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.


Howto cut a Image into lot's of slices

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


Joined: 26 Feb 2004
Posts: 5

PostPosted: Thu Feb 26, 2004 1:06 am    Post subject: Howto cut a Image into lot's of slices Reply with quote

I can't get it working to cut a uploaded image into lot's of little slices.
I got a Picture with 1000*700 and want 100*pictures with 100*70 so I get a 10X10 Grid... to prevent easy downloading of images.. sure screenshots can be made...
And also I got a other little project I could need this for.
But it seams like CropCanvas is only for one crop at the time? Crying or Very sad Question
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Thu Feb 26, 2004 8:07 am    Post subject: Reply with quote

Hi, max0matic, and welcome to the board!

Off the top of my head, why not do something like this:

PHP:
<?php

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

    if (
$cc->loadImage('your-file.jpg')) {
        
$h 0;
        for (
$i=0$i<100$i++) {
            
$w 0;
            for (
$j=0$j<70$j++) {
                
$cc->cropToDimensions($w$h$w+10$h+10);
                
$cc->saveImage("ouput-directory/$i-$j.jpg"90);
                
$w = ($j 10);
            }
            
$h = ($i 10);
        }
    }

?>


You may need to tweak that a little as I haven't tested it.... But should give you the right idea.

You only need to load the image once because it stores that in a class variable (if you wanted to load a different image without creating another instance of the class, then you could use the flushImages function). Then all you have to do is iterate over the amount of crops you want. Because the crop canvas class has a LOT of different ways to crop an image, doing multiple crops at different dimensions should be pretty easy.

HTH

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


Joined: 26 Feb 2004
Posts: 5

PostPosted: Thu Feb 26, 2004 8:13 am    Post subject: wow Reply with quote

thanx alot..
that points me into the right direction..
Thanx for your support... Very Happy Laughing
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