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 Rectangle with H and W?

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


Joined: 18 Jan 2005
Posts: 3

PostPosted: Tue Jan 18, 2005 1:24 pm    Post subject: Crop Rectangle with H and W? Reply with quote

Is it possible to have the height and width of the crop rectangle displayed in a corner? Say if I were to crop a part of an image to exactly 200x500, I would want to see exactly how large the cropped image would be.
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 18, 2005 1:33 pm    Post subject: Reply with quote

Hi Sam, and welcome to the board!

Sure it's possible. You just need to set the w/h of the cropping area before you load the interface. You can do this with the following method:

PHP:
<?php /**
    * @return void
    * @param int $w
    * @param int $h
    * @desc Sets the initial size of the cropping area.
    * If this is not specifically set, then the cropping size will be a fifth of the image size.
    */
    
function setCropDefaultSize($w$h?>


and coupled with that you might also want to set the minimum size of the cropping area:

PHP:
<?php /**
    * @return void
    * @param int $w
    * @param int $h
    * @desc Sets the minimum size the crop area can be
    */
    
function setCropMinSize($w 25$h 25?>


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


Joined: 18 Jan 2005
Posts: 3

PostPosted: Tue Jan 18, 2005 1:59 pm    Post subject: Reply with quote

Thanks for the welcome.

I don't think you understood quite what I meant.. I want to see the exact size of the crop rectangle dynamically in the corner of the rectangle. Sort of like the cursor x,y on your graph scripts.
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 18, 2005 2:42 pm    Post subject: Reply with quote

Ahhh.... Okay, I get you now!

I've done something similar in different <div> tags, so what I did was basically this:

I added a container to the html, such as:

<div id="coords">&nbsp;</div>

In your case you'll use the div tag that is the cropping area.

And then updated the my_ResizeFunc function to include writing to the container, such as:

Code:
   function my_ResizeFunc()
   {
       dd.elements.theCrop.maxw = (dd.elements.theImage.w + dd.elements.theImage.x) - dd.elements.theCrop.x;
       dd.elements.theCrop.maxh = (dd.elements.theImage.h + dd.elements.theImage.y) - dd.elements.theCrop.y;
       document.getElementById('coords').innerHTML = dd.elements.theCrop.w + ' / ' + dd.elements.theCrop.h;
   }


Where I put in 'coords' you'll naturally replace it with the id of the cropping area div tag (theCrop).

Something like that, anyway... You may have to play with the elements you display, but you should be able to see all you have access to by looking at the javascript drag/drop file.

Incidentally; the above would only work on browsers that support getElementById. I'll leave it up to you to decide if you want to support other/older browsers, too.

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
amnuts
Site Admin


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

PostPosted: Wed Jan 19, 2005 3:59 am    Post subject: Reply with quote

As an update to that, to show that it can work, check out this demo:

http://php.amnuts.com/demos/crop-canvas/interactive2.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
sam
Newbie


Joined: 18 Jan 2005
Posts: 3

PostPosted: Wed Jan 19, 2005 9:12 am    Post subject: Reply with quote

Great, it works. Thanks!
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