473,396 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

image header error

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
1 1355
zorgi
431 Expert 256MB
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

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

Similar topics

1
by: Kiran B. | last post by:
hello, Im getting this error everytime i load this page. malformed header from script. Bad header=*** You don't have the (right): c:/program files/apache group/apache/cgi-bin/fig28_18.py I...
2
by: Karthik | last post by:
When I try to compile my VC++ program (am Using VS6.0). I get the following error in a header file ATLCONV.H. c:\program files\microsoft visual studio\vc98\atl\include\atlconv.h(52) : error...
3
by: Scott Simonson | last post by:
I have had an application in MSAccess 2k for about year now without issues until recently. My users were using it in W98 without issue, but recently moved to WindowsXP and now are getting an...
1
by: Jason | last post by:
For some reason, most but not all reports printing from an access application our client is using will not print any images on the reports or forms. One report will print the image and data...
12
by: Lance | last post by:
hey all, first time vb.net 2005 user, after sticking vb6 out for a long time... anyway, using this code ====================== Dim FS As FileStream = File.OpenRead(Filename) Dim theImage As...
2
by: guoqi zheng | last post by:
dear sir, I am using itextShap for pdf generation. I know I can insert image into it, I can add header to it as well. However, I can not add an image as a header. Does any one has experience...
4
by: shotokan99 | last post by:
i have a web service and accessing it is done thru query string. how to access a certain header field using php? the sample program i saw was done in java and it goes like this: String...
0
by: =?Utf-8?B?c3Vpcw==?= | last post by:
Hi .Net team, I have a image name call test.jpeg, Any body can download this image on: http://files-upload.com/files/538354/test.rar I used bellow code to create that test.jpeg image ! Dim...
0
by: jodleren | last post by:
Hi I want to read an image an return it to the user - the point is, that it can be any graphic image, so I need to set it properly. AFAIK there are imaga/jpeg, image/png - then? image/gif and...
2
by: kelvinwebdesigner | last post by:
Hi everybody. Im currently developing an application where users can upload files and later get acess to the url. Im now having this trouble with header Cannot modify header information – headers...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.