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 = imagecreatefrom png("$slot1.png ");
$dest = imagecreate ( 150 , 100 );
// Copy
imagecopy($dest , $src, 0, 0, 0, -50, 150, 100);
$src2 = imagecreatefrom png("$slot2.png ");
imagecopy($dest ,$src2, 0, 0, 0, 0, 150, 50);
$src5 = imagecreatefrom png("$slot3.png ");
imagecopy($dest ,$src5, 0, 0, 50, -50, 100, 100);
$src3 = imagecreatefrom png("$slot4.png ");
imagecopy($dest ,$src3, 0, 0, 50, 0, 100, 50);
$src6 = imagecreatefrom png("$slot5.png ");
imagecopy($dest ,$src6, 0, 0, 100, -50, 50, 100);
$src4 = imagecreatefrom png("$slot6.png ");
imagecopy($dest ,$src4, 0, 0, 100, 0, 50, 50);
// Output and free from memory
header('Content-Type: image/png');
imagepng($dest) ;
imagedestroy($d est);
imagedestroy($s rc);
imagedestroy($s rc2);
imagedestroy($s rc3);
imagedestroy($s rc4);
imagedestroy($s rc5);
imagedestroy($s rc6);
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 = imagecreatefrom png("$slot1.png ");
$dest = imagecreate ( 150 , 100 );
// Copy
imagecopy($dest , $src, 0, 0, 0, -50, 150, 100);
$src2 = imagecreatefrom png("$slot2.png ");
imagecopy($dest ,$src2, 0, 0, 0, 0, 150, 50);
$src5 = imagecreatefrom png("$slot3.png ");
imagecopy($dest ,$src5, 0, 0, 50, -50, 100, 100);
$src3 = imagecreatefrom png("$slot4.png ");
imagecopy($dest ,$src3, 0, 0, 50, 0, 100, 50);
$src6 = imagecreatefrom png("$slot5.png ");
imagecopy($dest ,$src6, 0, 0, 100, -50, 50, 100);
$src4 = imagecreatefrom png("$slot6.png ");
imagecopy($dest ,$src4, 0, 0, 100, 0, 50, 50);
// Output and free from memory
header('Content-Type: image/png');
imagepng($dest) ;
imagedestroy($d est);
imagedestroy($s rc);
imagedestroy($s rc2);
imagedestroy($s rc3);
imagedestroy($s rc4);
imagedestroy($s rc5);
imagedestroy($s rc6);
Comment