By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

image header error

P: 1
The code below works perfectly fine by itself, but once i try to combine it with any other script, it generates an error.

Warning: Cannot modify header information - headers already sent

The script generates random thumbs and stitches them together. But i need to use the image afterwards. Any suggestions?


$slot1 = rand(1,12);
$slot2 = rand(1,12);
$slot3 = rand(1,12);
$slot4 = rand(1,12);
$slot5 = rand(1,12);
$slot6 = rand(1,12);


// Create image instances
$src = imagecreatefrompng("$slot1.png");
$dest = imagecreate ( 150 , 100 );
// Copy
imagecopy($dest, $src, 0, 0, 0, -50, 150, 100);

$src2 = imagecreatefrompng("$slot2.png");
imagecopy($dest,$src2, 0, 0, 0, 0, 150, 50);

$src5 = imagecreatefrompng("$slot3.png");
imagecopy($dest,$src5, 0, 0, 50, -50, 100, 100);

$src3 = imagecreatefrompng("$slot4.png");
imagecopy($dest,$src3, 0, 0, 50, 0, 100, 50);

$src6 = imagecreatefrompng("$slot5.png");
imagecopy($dest,$src6, 0, 0, 100, -50, 50, 100);

$src4 = imagecreatefrompng("$slot6.png");
imagecopy($dest,$src4, 0, 0, 100, 0, 50, 50);



// Output and free from memory
header('Content-Type: image/png');
imagepng($dest);

imagedestroy($dest);
imagedestroy($src);
imagedestroy($src2);
imagedestroy($src3);
imagedestroy($src4);
imagedestroy($src5);
imagedestroy($src6);
Oct 26 '11 #1
Share this Question
Share on Google+
1 Reply


zorgi
Expert 100+
P: 431
Can you show us how you combine your script? Just to mention this wil not work:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. ....
  3. ....
  4. //your script
  5. ....
  6. ....
  7. </html>
  8.  
You would have to do something like this:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. ....
  3. ....
  4. <img src='path/to/your/script.php' />
  5. ....
  6. ....
  7. </html>
  8.  
Oct 26 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.