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.


Why is life never simple ?

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


Joined: 05 Jul 2004
Posts: 4

PostPosted: Mon Jul 05, 2004 5:22 pm    Post subject: Why is life never simple ? Reply with quote

Hello all

I have been messing around with php for a month or so trying to get what I want with images - I am a php noob so the code is very basic.

I liked the idea of being able to select the area to use for my thumbnail so have downloaded and tried your script.

I thought I would be clever and read all the images from a directory and create a thumbnail or each and save; could not get to work but i can not remember the errors now.
PHP:
<?php
$read 
'up';
     
$myDirectory opendir($read);

        while(
$entryname readdir($myDirectory))
    {
    if (
strtolower(substr($entryname, -3)) == "jpg")
           
$dirArray[]=$entryname;
                   }
        
closedir($myDirectory);
 
 
$indexCount count($dirArray);

  
     for (
$i=0$i<$indexCount$i++)
     {

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']);
    
//$ci->saveImage('/path/to/save/to.jpg', 90);
    
$ci->saveImage('to.jpg'90);
    
// now you can do something else here if you want
    // like give a message, or redirect, or something
} else {
    
$ci->loadInterface($name);
    
$ci->loadJavaScript();
}

                  }
?>


I then thought I would pass the image name accross in a session variable when I uploded a image and modify it then but I get an error about cookies.
PHP:
<?php <html>
<
body>
<?
php  echo $manip// Variable from upload script
              
$path '../up';
//$name = $_GET['name'];
      
$name $path.$manip;
      echo 
$name;
//$name = 'original.png';

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']);
    
//$ci->saveImage('/path/to/save/to.jpg', 90);
    
$ci->saveImage('to.jpg'90);
    
// now you can do something else here if you want
    // like give a message, or redirect, or something
} else {
    
$ci->loadInterface($name);
    
$ci->loadJavaScript();
}

?>
</body>
</html> ?>


Above was the sort of thing I had; can somebody give me some help on getting either method working please ?

I must say the script works great as a stand alone item.

Anthony

P.S. php code is very rough as I have tried different things !!
Back to top
View user's profile Send private message Visit poster's website
Bonzo
Newbie


Joined: 05 Jul 2004
Posts: 4

PostPosted: Tue Jul 06, 2004 2:10 pm    Post subject: Reply with quote

I think in my test there was 50% of the code right !!

Anyway this is where I am now http://www.rubble.info/photo/crop/test_delete_me.php

PHP:
<?php
require_once 'class.cropcanvas.php';
require_once 
'class.cropinterface.php';

$read 'up/';

$myDirectory opendir($read);

while(
$entryname readdir($myDirectory))
    {
     if (
strtolower(substr($entryname, -3)) == "jpg")
        
$dirArray[]=$entryname;
     }

closedir($myDirectory);

$indexCount count($dirArray);


for (
$i=0$i<$indexCount$i++)
     {
      
$ci = new cropInterface();

              
$ci->loadInterface($read.$dirArray[$i]);
              
$ci->loadJavaScript();

              }
?>

I have the correct images; I have the interface but thats it !
I assume that I should modify one before it calls the next ?
Anyway I will see if it comes to me tomorrow after another hard boring day in a factory - nothing else to think about apart from the problems from the nigt before.

Anthony
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: Wed Jul 07, 2004 8:52 am    Post subject: Reply with quote

he crop canvas class wont produce a thumbnail of an image. That is to say, it will not shrink down the full sized image into a smaller one, but will instead remove portions of the image that you define (for example, you want to remove the 10 pixels around the outside of an image).

For thumbnailing you'll want to use the drop shadow class, as this provides you lots of ways to resize images. You can reduce them in size by a certain amount (in pixels or a percentage of the image size), or to a certain size (again by pixels or percentage), and more. This script you could automatically setup to resize an entire directory (in fact, I plan to have that as a feature of the next version, whenever I get around to doing it!).

The crop interface probably wont work with multiple images on the same page because of the way the javascript is set up... I could be wrong - I haven't tested it before!

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


Joined: 05 Jul 2004
Posts: 4

PostPosted: Wed Jul 07, 2004 12:01 pm    Post subject: Reply with quote

Thanks for the reply; I was already creating a thumbnail from reducing an image during upload with my current code using IM or GD.

What I was looking do do was just use part of an image for the thumbnail which cropcanvas with cropinterface looked ideal for.

I will take a look at the drop shadow class later and see what it can do; but whatever I use I realy want it to happen automaticaly on image upload.

I will get back to you when I have given the drop shadow class a go.

Anthony
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: Wed Jul 07, 2004 12:57 pm    Post subject: Reply with quote

Ahh, I see now. Well, I have an image gallery that automatically resizes an image into a thumbnail and then I crop it so that the thumbnail image is square. I do this automatically by using the dropshadow and cropcanvas classes, but I do not use the crop interface. The interface is there for user interaction. If you want to automatically crop an image, you have a number of options available to you with the crop canvas class itself. For example, you can crop in the top left, top centre, top right, left, centre, right, bottom left, bottom centre, and bottom right area of the image, to a set size, or by a set size. The size can be pixels or a percentage, and it can even crop automatically by a threshold limit.

Now, what I do is resize all the images so that they have a minimum height or width of, say, 90 pixels. Then I crop in the centre of the image (because presumably the focus of the image is the actual centre of the picture) so that the thumbnail is now 90x90 pixels. Then I might add a dropshadow effect to the thumbnail, just for an added extra.

All of this is done automatically on the viewing of a gallery folder.

I think there are some threads on this board, or the dropshadow board, that show examples of using the two classes together.

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