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.


Size problems...

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


Joined: 06 Oct 2006
Posts: 5

PostPosted: Mon Oct 09, 2006 6:37 am    Post subject: Size problems... Reply with quote

Thanks for these superb scripts, you are a gift to the world Smile

I am using the script for users who upload an image for use on a id card, they then crop their face using proportional box, which works fine. The problem is when they upload their 2-3-4MB images, which makes the cropping task almost impossible, as you cannot see the crop area as the image consume the whole screen, and its hard to navigate.

1.) The question is quite simply; is it possible to scale the inital image to a fixed size if the image is larger than the window size set for the crop task? I.e. if a image is 2500x3000 it scale the image down so it fits into a 500x600 (scaled proportionally) cause then the users would be able to see the entire image more(a lot) easy, and able to find the correct crop area without scrolling a few miles back and forth Smile

2.) For some reason my crop box is also blurred/greyish area - where in the code is this defined so I can adjust it correctly again - don't know what happened, but the whole image is now in the same grayish color Smile

Thanks a million!
Back to top
View user's profile Send private message
Richard
Newbie


Joined: 06 Oct 2006
Posts: 5

PostPosted: Mon Oct 09, 2006 11:44 am    Post subject: ...one more thing! Reply with quote

When uploading a 2.9MB image and trying to crop it, this error msg show:

"Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 2028 bytes) in class.cropcanvas.php on line 425"

Any idea how to bypass the error?

Thanks Smile
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 Oct 10, 2006 4:52 am    Post subject: Re: Size problems... Reply with quote

Hi Richard, and welcome to the board! (Sorry it took so long to get authorized Smile )

Richard wrote:
1.) The question is quite simply; is it possible to scale the inital image to a fixed size if the image is larger than the window size set for the crop task? I.e. if a image is 2500x3000 it scale the image down so it fits into a 500x600 (scaled proportionally) cause then the users would be able to see the entire image more(a lot) easy, and able to find the correct crop area without scrolling a few miles back and forth Smile


Well, that kinda depends... Do you want to retain the full sized image, or are you happy to use a smaller version? Given that you're using it on an ID card you may want to retain the full-sized version. However, if you want to just resize the image and crop it then have a look at using the 'drop shadow thumbnail creator' - it's can do image resizing for you very easily (I really should change the name of it to something a bit less centred around the drop shadow part!) There are a number of examples on this board and the drop shadow one on how to do this, but it's pretty easy to get to grips with. If you want to retain the full size and just show the proportional image i nthe cropping area but apply the crops to the fullsized image, then it's much trickier and not something that the class can do for you. You'd basically work out what percentage bigger the full sized image is and make the crop start/end points proportionally that much bigger. Perhaps this is something I could look in to developing for any future versions.

Richard wrote:
2.) For some reason my crop box is also blurred/greyish area - where in the code is this defined so I can adjust it correctly again - don't know what happened, but the whole image is now in the same grayish color Smile


This sounds odd. Could you supply a screenshot so I can see what's going on?

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: Tue Oct 10, 2006 4:57 am    Post subject: Re: ...one more thing! Reply with quote

Richard wrote:
"Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 2028 bytes) in class.cropcanvas.php on line 425"


You can bump up the memory limit in your PHP script (the one that calls the crop canvas class, but somewhere before you instantiate the object) with this line:

ini_set('memory_limit', '80MB');

I set that to a really huge number, but the bigger the resolution and dimensions of the image (it's not really dependant on the file size) the more memory you'll need. You can play around with the number to optimize your memory usage.

Regards,

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


Joined: 06 Oct 2006
Posts: 5

PostPosted: Tue Oct 10, 2006 8:50 am    Post subject: Reply with quote

thanks, had to put it to a whooping 250MB for a 5MB jpeg file Smile then it worked.

in relation to the first questions, about keeping the original size, is this something you could create for payment, as I really need it : -) please pm me or send an email to me for a quote if you have the time and willingness Smile

thanks again!
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 Oct 11, 2006 1:18 pm    Post subject: Reply with quote

I'm a bit busy at the mo, but I'll try to look at this some time next week.

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


Joined: 06 Oct 2006
Posts: 5

PostPosted: Wed Oct 18, 2006 1:21 am    Post subject: Reply with quote

thats great, waiting in patience Smile
Back to top
View user's profile Send private message
Richard
Newbie


Joined: 06 Oct 2006
Posts: 5

PostPosted: Mon Oct 23, 2006 1:10 pm    Post subject: Reply with quote

....have u had the time Andrew?
Back to top
View user's profile Send private message
amnuts
Site Admin


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

PostPosted: Mon Oct 23, 2006 2:10 pm    Post subject: Reply with quote

I started it, Richard, and the concept is pretty easy, but I haven't really fully integrated it properly yet (that's a little harder since I revamped the class). Basically what you do is this:

(i1 is the full-sized image, i2 is the smaller size, m is the multiplier, c is the crop position)

i1.width / i2.width = m

c.start_x * m = i1.start_x
c.start_y * m = i1.start_y
c.end_x * m = i1.end_x
c.end_y * m = i1.end_y

Then use the i1.start/end_x/y values to apply the crop on your large image.

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: Tue Nov 28, 2006 7:50 pm    Post subject: Reply with quote

I know it's been just over a month since I last dealt with this, but it's all but done now. I have to do a couple tweaks to tidy up a function, but other than that the functionality is done.

Next version should hopefully be out in the next day or two and will also include the fix mentioned here:

http://php.amnuts.com/forums/viewtopic.php?p=1548#1548

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 Nov 29, 2006 10:13 am    Post subject: Reply with quote

Richard; a new version is now available with the resizing type option you were looking for... Still fancy throwing some money my way for it? Wink

http://php.amnuts.com/forums/viewtopic.php?p=1551

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