performance problem with dynamic image compression

From: Date: Thu, 15 May 2003 13:41:09 +0000
Subject: performance problem with dynamic image compression
Groups: php.general 
Request: Send a blank email to php-general+get-147702@lists.php.net to get a copy of this message
Hello everybody, I would like to add dynamic image quality and dynamice image size to my application. Currently the images are stored on the file system. Now I have created a php file which is changing the image as I like it and then outputs it to the browser. The code works great. Problem: Performance is verry bad. On my celeron 1.7 Ghz test system it takes about 0.5 to 1 s to display the image. In production with lots of other users and a 1 GHZ celeron it would be even worse. H Has anybody an idea on how to increase this performance? My code is underneath and I do not know on how to make it more performant. Code woks, but as I said it takes to long. Thank you for any hint, Merlin Code for dynamic compression and dynamic image size: $inputImg = @ImageCreateFromJPEG($picture_location); ############### # resize # old size $srcX = imagesx($inputImg); $srcY = imagesy($inputImg); # new size $ratio = ($srcX / $maxX); $dstY = ($srcY / $ratio); $picX = $maxX; $picY = ($maxX / ($srcX / $srcY)); $outputImg = ImageCreateTrueColor($maxX, $dstY); imagefill($outputImg, 0, 0, ImageColorAllocate($outputImg, 0, 0,0)); imagecopyresampled($outputImg, $inputImg, $posX, $posY,0,0, $picX, $picY, $srcX, $srcY); ############################################################################ #################### # output header("Content-type: $file[type]"); imagejpeg($outputImg,'',$file[compression]); ############################################################################ ####################

« previous php.general (#147702) next »