Re: [PHP] Image handling advice needed
Hello, I need to build an image 'library'. The library will consist mostly of images taken with digital cameras. Since unedited digicam pics will most likely be too big for web usage they need to be edited automatically so that they can be put to a web page. I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. I think that if the disk space is not an issue I could upload the original file. But are there performance issues if the thumbnails are created on the fly if there are hundreds of pics? Thanks for your advice -Will Will: I don't want to start any my machine will beat-up your machine wars, but if I was confronted with the problem (using a Mac), it would be a somewhat simple process to automate resizing a bunch of pictures using Photoshop and Automator and then make them to the size/type I want before uploading. Barring that, you could use a thumbnail script to cycle through a directory and resample pictures to a specific size. But after that, I would delete the originals online -- no need to keep them UNLESS you are going to use them in some fashion. As to where to put them, there are two schools of thought: 1) store them in folders and put their url's in the dB; 2) or store them directly in the dB. I've heard good/bad points about each side and to me it boils down to which method are you most comfortable. As far as performance issues creating thumbnails on the fly, just reduce them to a number that the user can comfortably view at one and then show them as the user wants. I would guess that no one wants to see hundreds of picts at one time. Please review -- http://xn--ovg.com/mysql -- to see an example of what I mean. There you can generate up-to 1000 records but see them a few (5) at a time. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image handling advice needed
Hello, I need to build an image 'library'. The library will consist mostly of images taken with digital cameras. Since unedited digicam pics will most likely be too big for web usage they need to be edited automatically so that they can be put to a web page. I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. I think that if the disk space is not an issue I could upload the original file. But are there performance issues if the thumbnails are created on the fly if there are hundreds of pics? Thanks for your advice -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image handling advice needed
On 1/18/06, William Stokes [EMAIL PROTECTED] wrote: I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. Why not scaled them once and for all (first option)? are you going to need them in BIG size on the server or anything else? -ahmed
Re: [PHP] Image handling advice needed
At 04:10 AM 1/18/2006, William Stokes wrote: Hello, I need to build an image 'library'. The library will consist mostly of images taken with digital cameras. Since unedited digicam pics will most likely be too big for web usage they need to be edited automatically so that they can be put to a web page. I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. I think that if the disk space is not an issue I could upload the original file. But are there performance issues if the thumbnails are created on the fly if there are hundreds of pics? Thanks for your advice -Will Will, Before you go too far, have you looked at Gallery or Gallery2? Miles -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.371 / Virus Database: 267.14.18/230 - Release Date: 1/14/2006 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Image handling advice needed
William Stokes wrote: Hello, I need to build an image 'library'. The library will consist mostly of images taken with digital cameras. Since unedited digicam pics will most likely be too big for web usage they need to be edited automatically so that they can be put to a web page. I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. I think that if the disk space is not an issue I could upload the original file. But are there performance issues if the thumbnails are created on the fly if there are hundreds of pics? Will - do a bit of both. upload and store the original in fullsize (and _without_ any compression or whatever). then have a script (or set of them, depending or your needs) that doesn't just blindly resample a requested image according some given criteria (set in either the script or the from the request) but first check it's 'own' cache for previously resampled files ... if it finds a valid file in 'its cache' then just spit it out; otherwise generate the requested image file (manipulating/resampling however you like) and save it to the cache (most likely to disk) and also output the image data. this effectively gives you one time resampling with some added bonuses: 1. when the underlying extension (e.g. GDlib) is upgraded you can clear your image cache and have all your images regenerated automatically using the improved routines (e.g. crisper resamping) 2. when the client wants all the images on the site to be a different tint/size/ratio/format/etc you can change you image generation scripts, clear the image cache and bingo - 'fixed' images. below is a class I use to store images I cache in the manner I described above. using it is quite simple [if you don't want it to use values of named REQUEST args as the basis of the unique cache identifier (i.e. the filename) then you'll have to do some hacking]: // create the object $ic = ImageCache('/dev/shm/site-image-cache'); // read up on /dev/shm !!! // set out an array of REQUEST arguments. e.g. imagine the following url // ./showimg.php?id=12345size=big - how you use the actual REQUEST argument values // to generate an non-existant image is up to you. $cacheArgs = array('size', 'id') // use the image cacher to determine the generated name of the cached image file. $ic-genCacheFileName( $cacheArgs, 'jpeg', 'some-prefix' ); // determine a set of files with which to check the file modification // time against (at least 1 is required) $files = array('/path/to/your/original/image/file.jpg'); // check the cache if (!$ic-checkCache($files)) { // do some stuff to create an image // use the value from $ic-getCacheFilePath() // as the path+filename under which to store the // new image } // show cache image. $ic-showImage(); ?php class ImageCache { var $validTypes = array('png','gif','jpeg'); var $cacheFileName; var $cacheFileType; var $cacheDir; var $dirSep; var $im; /* you must give a valid 'cache' dir AND you must have already generated * a cache file name for the file we want to cache (may have already been cached) * * in effect you must always call ImageCache::genCacheFileName() before calling this function. */ function ImageCache($cDir) { $this-cacheDir = $cDir; $this-dirSep = defined('DIR_SEP') ? DIR_SEP: '/'; // just to be safe we define this if it does not exist. if (!defined('WEBROOT')) { define('WEBROOT', realpath($_SERVER['DOCUMENT_ROOT'])); } } function genCacheFileName( $args = array(), $type = '', $prefix = '' ) { /* name/val pair delimiter in the string that results in the hash for the cache id */ $qHashMark = '%~^*'; $args = (array)$args; natsort($args); $qry = array(); foreach ($args as $arg) { if (($val = $this-getR( $arg, false )) !== false) { $qry[] = {$arg}=.str_replace($qHashMark,'',$val); } } //var_dump(WEBROOT . $_SERVER['PHP_SELF'] .'-:-'. join($qHashMark, $qry)); $hash = md5(WEBROOT . $_SERVER['PHP_SELF'] .'-:-'. join($qHashMark, $qry)); if (!in_array($type, $this-validTypes)) { if ($type == 'jpg') { $type = 'jpeg'; } else { $type = 'png'; } } $this-cacheFileType = $type; if (!$prefix) { $prefix = 'cacheimg'; } return ($this-cacheFileName = {$prefix}_{$hash}.{$type}); } function getCacheFilePath() { return $this-cacheDir . $this-dirSep . $this-cacheFileName; } /* Return true if the cache file is younger than the source file(s), * false otherwise.
Re: [PHP] Image handling advice needed
On Wed, January 18, 2006 2:10 am, William Stokes wrote: I need to build an image 'library'. The library will consist mostly of images taken with digital cameras. Since unedited digicam pics will most likely be too big for web usage they need to be edited automatically so that they can be put to a web page. I'am trying to deside between two options. To resize (=scale down) the images once they are uploaded to server and store the smaller file or upload and store the original BIG file and scale it to thumbnail once it's viewed. Any opinnions about this. I think that if the disk space is not an issue I could upload the original file. But are there performance issues if the thumbnails are created on the fly if there are hundreds of pics? The question isn't the number of pics, but how many times your server gets pounded on... Or are you planning on scaling down hundreds of pics on *ONE* page on the fly? For sure, don't do that. Or, you can do it, but cache the results of the thumbnails you displayed, so you only have to really scale them in PHP the first time. The real question is: Why do you need / want the original large picture? What use do you have for it? Storage space for hundreds of digital camera images is pretty predictable -- You could figure out exactly how much drive space you need. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] image handling
I have a form on my website that allows users to upload photographs.. 1. How to find out the file type they are uploading..like jpeg or png or gif? 2. Also is there any way to find out size and resolution of the image? Thanks in advance :) - Free cPanel Web Hosting http://hostwindow.info/web-hosting/2/free-cpanel-web-hosting/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] image handling
On 4/16/05, Dasmeet Singh [EMAIL PROTECTED] wrote: I have a form on my website that allows users to upload photographs.. 1. How to find out the file type they are uploading..like jpeg or png or gif? 2. Also is there any way to find out size and resolution of the image? http://us3.php.net/manual/en/function.getimagesize.php You can use getimagesize to get the size and type of the image as well as some other information possibly usefull information. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Image Handling
Hi all, I am working on a store app. On the admin side I want to allow the admin to upload a pic, adjust the size, and create a thumbnail. Does anyone know of any open source image handling routines I can take advantage of for this? The file format will be jpg or even gif. Thanks in advance. Johnny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php