Re: GD Image Resizing on the fly.

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

 



Tony Devlin wrote:
Hello Everyone,

    I am looking for a script or guidance in where to look to figure out how
to create a php script that resizes an image on the fly when it is called(...)

Image resizing takes a lot of cycles. As opposed to generating a thumbnail every time a visitor comes to your site, cache it.


	/* PHP Psuedocode */
	thumbnail_file = thumbnail-cache/product.png
	if(file_exists(thumbnail_file))
		print <img src=thumbnail_file />
	else
		generate_thumbnail(source, thumbnail_file);
		print <img src=thumbnail_file />

This way, the expensive GD hits only take place once, when the thumbnail is first created. Otherwise, you may get a visitor who constantly refreshes and drives up your load average -- and on shared hosting, this can be problematic.

--
     _
    (_)___    Jed Smith, Code Ninja
    | / __|   RFBs: [email for info]
    | \__ \   +1 (541) 606-4145
   _/ |___/   jed@xxxxxx (Signed mail preferred: PGP 0x703F9124)
  |__/        http://personal.jed.bz/keys/jedsmith.asc

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux