Re: Memory limit of 8 MB not enough

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 16, 2008 at 9:59 AM, tedd <tedd.sperling@xxxxxxxxx> wrote:
>
> At 9:41 AM -0400 4/16/08, Andrew Ballard wrote:
>
> > On Wed, Apr 16, 2008 at 7:56 AM, tedd <tedd.sperling@xxxxxxxxx> wrote:
> >
> > >  At 6:48 PM +0900 4/16/08, Dave M G wrote:
> > >
> > >  > PHP list,
> > >  >
> > >  > I have a PHP script that resizes an image. It takes just about
> whatever
> > >  size and shrinks and crops it down to 320X240.
> > >  >
> > >  > I've found that these days, it's not uncommon for people to take
> images
> > >  straight off their digital camera, which can be 3000X2000 pixels in
> image
> > >  size, even if the jpeg file containing the image is only 200 KB. When
> > >  working with the image, it gets uncompressed and takes up a lot of
> memory.
> > >  >
> > >
> > >  You might want to look into using javascript to trim the file down to a
> > >  respectable size before uploading.
> > >
> > >  Cheers,
> > >
> > >  tedd
> > >
> >
> > I'd be interested in seeing an example of how you actually plan on
> > doing that, Tedd. JavaScript can't access the file from an input
> > field, and I'm not aware of any JavaScript image handling functions
> > either.
> >
> > Andrew
> >
>
>
>  I saw one the other day that caught my eye -- will look into it.
>
>
>
>  Cheers,
>
>  tedd

The first problem I see implementing the approach is the JavaScript
sandbox. JavaScript is allowed to read the text of the input file
field (and thus know the file name and path once a file has been
selected); it cannot access the disk to actually get to the image or
do anything with it. From here, I'm thinking there are a couple things
you could do with JavaScript. The first would be to embed the image
into the web page using an IMG tag, which would allow you to determine
the pixel dimensions (but not the actual file size). The second would
be what Gmail seems to do, and actually upload the form to their
server with some sort of AJAX request, at which time your server could
return information on the size of the file. However, if the file is
too large, you're back to the original problem of needing to increase
the RAM limit in PHP.

The second problem is, as I said, I'm not aware of any JavaScript that
can manipulate the image. JavaScript can cause the display of an image
to be resized within the browser, but that doesn't actually affect the
stored file. I don't know, but I guess if you could actually get to
the bits, you could probably write an algorithm in JavaScript to
resize an image by manipulating the bits, but I think it would be
dreadfully slow if it would even run without running out of resources.

I think the only pure-client options are either Java (which would
require special permissions to get out of its own sandbox) or ActiveX.

If you know of some other approach, I'd be interested to see how it works.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux