Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- From: eric.butera@xxxxxxxxx ("Eric Butera")
- Date: Fri, 25 Jan 2008 13:59:19 -0500
On Jan 25, 2008 1:39 PM, Richard Lynch <ceo@xxxxxxxxx> wrote:
On Fri, January 25, 2008 7:27 am, Eric Butera wrote:
I think the memory size can (sort of) be determined by width * height
* bits * channels / 8. I've never found anything better than that.
There are a few comments on the php site in the gd section about such
things but I've never seen it work 100%. I always set the real memory
limit much higher than what I say the max is for the memory size just
in case it gets an image that could break it. At least that stopped
the friendly white screens of death. :)
If anyone has better ways of handling this I'd love to hear them.
Don't try to do the thumb-nail in real-time for the user that uploads it.
They already know what the image looks like. :-)
Off-load that task to a separate cron job, run from CLI, which can use:
php -q -d memory_limit 1000000000 thumbnail.php /path/to/image.jpg
/path/to/thumbnails/
This way, you are not letting your HTTP php processes chew up more RAM
than they really should, and you can give the thumbnail script a GIG
(or more) of RAM to do whatever it needs to do.
Run that job often enough, and the thumbnail will be available "fast
enough" for the users who don't know what the image looks like.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
Hi Richard,
The way I handle thumbnail creation is (this is generalized) but an if
statement that says
if (thumbnail file name not in db) {
set img src to a script that renders thumbnail, saves it
somewhere, and updates the db record so that this never happens again
until i reset it (in case they want to change thumb sizes)
} else {
raw link to image
}
The main issue is that when someone uploads an image for a piece of
content or a product image I need to scale it down to a sane amount of
~800 w/h before I even allow it on the site. From there I use the
thumbnail on demand.
I'm not sure the cron job idea is the best for my situation though.
When a client uploads a product image in a store they just paid for
they expect it to show up before 3am when the server load is down. If
I run it every 15 minutes I really don't see the advantage of that
seeing as I can do an ini_set on the memory limit at any point I
decide since it is my server. Cron for 15 minutes still means at 3pm
which we are at a heavy load the 1g script would kick in.
The good thing though is that most people just set up their
store/content and don't really update it too much after that. That is
why I'm after a solution that allows me to figure out the memory size
so I can just tell them if they need to lower the resolution a bit and
try again.
I'll keep this cron solution in mind though, could come in handy at some point.
.
- Follow-Ups:
- Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- From: "Richard Lynch"
- Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- References:
- Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- From: Emil Edeholt
- Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- From: "Eric Butera"
- Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- From: "Richard Lynch"
- Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- Prev by Date: Re: [PHP] Re: how dod you get to do multiple mysql queries concurrently?
- Next by Date: Re: [PHP] Exception thrown without a stack frame
- Previous by thread: Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- Next by thread: Re: [PHP] Re: php-general Digest 25 Jan 2008 07:59:28 -0000 Issue 5255
- Index(es):
Relevant Pages
|