Re: GD transparency problem

From: Date: Mon, 12 May 2003 22:31:34 +0000
Subject: Re: GD transparency problem
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-147358@lists.php.net to get a copy of this message
Oops - spoke too soon. I haven't quite sorted the problem - or, at least, I've created a new one. I'm merging a bunch of images based on a database search using the following code: $backimg = imagecreatefrompng('deptmaps/bckgrnd.png'); for ($i = 1; $i <= $dbrows ; $i++) { if ( file_exists("deptmaps/".$deptcode[$i].".png")) { $overlay[$i] = imageCreateFromPNG("deptmaps/".$deptcode[$i].".png"); imageCopyMerge($backimg,$overlay[$i],0,0,0,0,350,394,100); } } So far so good. I then need to create a new image. All of this is working and I was writing the new image out to a file called 'composite.jpg', and that works too - except that the new graphic isn't always loaded by the browser because it's already cached an older version of 'composite.jpg' and so doesn't bother to get subsequent ones. I fixed this by changing the filename each time using the following code: $newfile = time(); imagejpeg($backimg,"deptmaps/".$newfile.".jpg"); echo "<IMG SRC='deptmaps/".$newfile.".jpg'>"; That sorted the caching problem, but now I'm creating lots of new images which will slowly fill up the hard disk. Ugh! So either I need to delete the older file each time (without being able to know its full name) or I need a way of preventing the caching of the image. I'd appreciate any thoughts on this... James earlier suggested making the IMG SRC refer to a separate script that does the image creation, but that means passing the array to that script, and I'm not sure how to do that.

« previous php.general (#147358) next »