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.


Pass save quality in url and dynamic proportions

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


Joined: 10 Mar 2004
Posts: 1

PostPosted: Wed Mar 10, 2004 12:46 am    Post subject: Pass save quality in url and dynamic proportions Reply with quote

Hello there, first and foremost, awesome script! This will allow me to pursue writing a couple scripts I've been wanting to write for a long time.

On to the questions.. I'm trying to figure out how to pass a value in the url as a part of the get request sent upon 'submitting' to dynamically set the quality of the resulting cropped image. I've figured out where to add the form element, easy enough, but I cant figure out how to concatenate the value of that text box to the url, any help? It looks as though the best and perhaps only way to do this is to make the form element a part of the dd object but that script is way over my head..

On a less important sidenote, it would be great to be able to dynamically ( in "real-time" ) set the proportions of the 'to be cropped' area, via text boxes, any pointers where to look?

Thanks
JDF
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 Mar 10, 2004 6:25 am    Post subject: Reply with quote

Hi JDF, and welcome to the board!

Quote:
On to the questions.. I'm trying to figure out how to pass a value in the url as a part of the get request sent upon 'submitting' to dynamically set the quality of the resulting cropped image. I've figured out where to add the form element, easy enough, but I cant figure out how to concatenate the value of that text box to the url, any help? It looks as though the best and perhaps only way to do this is to make the form element a part of the dd object but that script is way over my head..


Okay, I assume you're talking about the crop-interface, as opposed to the actual crop class (which the interface extends). With that in mind...

What you need to do is update the 'my_Submit' function by adding a little javascript to add on an element. Say you added this to the page:

Code:
<select name="imgQuality" id="imgQuality">
    <option value="70">70%</option>
    <option value="85">85%</option>
    <option value="100">100%</option>
</select>


Note that it has the 'id' parameter set. Then in the my_Submit function you could do something like this:

Code:
    function my_Submit()
    {
        self.location.href = '{$_SERVER['PHP_SELF']}?file={$this->file}&q=' +
            (getElementByID('imgQuality').value) + '&sx=' +
            (dd.elements.theCrop.x - dd.elements.theImage.x) + '&sy=' +
            (dd.elements.theCrop.y - dd.elements.theImage.y) + '&ex=' +
            ((dd.elements.theCrop.x - dd.elements.theImage.x) + dd.elements.theCrop.w) + '&ey=' +
            ((dd.elements.theCrop.y - dd.elements.theImage.y) + dd.elements.theCrop.h);
    }


Then you can use $_GET['q'] as the quality value.

Please note that the above is not backwards compatible with older browsers. I've just used the above as an example, and you could probably tweak it fairly easily for your own use.

Quote:
On a less important sidenote, it would be great to be able to dynamically ( in "real-time" ) set the proportions of the 'to be cropped' area, via text boxes, any pointers where to look?


Sure! What you want to do is the same thing as the 'my_SetResizingType' does. In that you have your drop-down list and when the value changes it calls a javascript function which alters the width/height of dd.elements.theCrop.x and dd.elements.theCrop.y. I haven't tried it, but it intrigues me enough that I might when I have a few spare moments.

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


Joined: 03 Jan 2006
Posts: 1

PostPosted: Tue Jan 03, 2006 6:16 pm    Post subject: MySubmit messing up Reply with quote

Hi -

Super duper script.

In regards to variable passing the in URL...
I tried to add the code you suggested to the my_Submit function and it causes the submit button to do nothing when I hit it. It seems that every time I add a variable into the url in the my_Submit script that it causes the button to do nothing when I hit it.

Here is my HTML in the interface file...
Code:

<form><input name='ITEM' type='hidden' value='1179'  id='ITEM'></form>


And here is the adjustment to the my_Submit file.

Code:

   function my_Submit()
   {
      self.location.href = '{$_SERVER['PHP_SELF']}?file={$this->file}&cropped=yes&ITEM_NUMBER=' +
            (getElementByID('ITEM').value) + '&sx=' +
         (dd.elements.theCrop.x - dd.elements.theImage.x) + '&sy=' +
         (dd.elements.theCrop.y - dd.elements.theImage.y) + '&ex=' +
         ((dd.elements.theCrop.x - dd.elements.theImage.x) + dd.elements.theCrop.w) + '&ey=' +
         ((dd.elements.theCrop.y - dd.elements.theImage.y) + dd.elements.theCrop.h);
   }


Please help when you have a second. I think it's giving me brain damage.

Thanks so much!
Osaga
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 Jan 05, 2006 4:08 am    Post subject: Reply with quote

Hi Osaga and welcome to the board!

Not sure off the top of my head. Any chance at seeing the script running somewhere so I can check out the interface myself?

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