Re: Re: GD transparency problem

From: Date: Tue, 13 May 2003 08:40:53 +0000
Subject: Re: Re: GD transparency problem
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-147405@lists.php.net to get a copy of this message
John, Thanks for responding. No, I don't really need to write it to the filesystem - it's just that that's the only way I could think of doing it. Displaying as a streamed image seems a sensible solution - but this and serializing are new to me (though I was aware of them). Anyway, after a bit of grappling with the manual I've got something working. FYI, this is what I'm doing... I've created a file called dept-img.php which contains: <?php header("Content-type: image/jpeg"); $deptcode=array(); $deptcode=unserialize(stripslashes($_GET['codes'])); $backimg = imagecreatefrompng('deptmaps/bckgrnd.png'); foreach ($deptcode as $dkey => $dval) { if ( file_exists("deptmaps/".$deptcode[$dkey].".png")) { $overlay = imageCreateFromPNG("deptmaps/".$deptcode[$dkey].".png"); imageCopyMerge($backimg,$overlay,0,0,0,0,350,394,100); } } imagejpeg($backimg); ?> That's the whole file. And I'm calling this with: <?php $ser_codes = serialize($deptcode); ?> <IMG SRC='dept-img.php?codes=<?php echo $ser_codes ?>' > ($deptcode is an array of two-character strings) Like I say, it seems to be working, though if anyone can see an obvious snag with this code I'm always open to constructive criticism. And thanks again for putting me on the right track. a+ Steve "John Coggeshall" <john@coggeshall.org> wrote in message news:1052780768.17713.5.camel@coogle.localdomain... > > 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. > > You can serialize the array and pass it: > > http://www.php.net/manual/en/function.serialize.php > > Does the image need to be written to the file system?? If it doesn't, > why not just display it as a streamed image. If you still have caching > problems then you can always send some HTTP headers to inform the > browser to not cache the image. > > John > > -- > -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~- > John Coggeshall > john at coggeshall dot org > http://www.coggeshall.org/ > -~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~--~=~-

« previous php.general (#147405) next »