Da jeg satte header ind nede sammen med imagejpeg, kom den og sagde, at header allerede var sendt. Jeg laver jo noget tabel-værk over, så jeg flyttede header op aller øverst på siden. Duer det ikke?
Du får lige hele filen:
<?
header('Content-Type: image/jpeg');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head>
<title>farveberegning</title>
</head>
<body>
<?php
// print "filnavn = ".$filnavn;
$allowedTypes = array("image/jpeg", "image/pjpeg", "image/jpg");
$maxFileSize = 10307200;
$max_width = 2400;
$max_height = 2400;
$antal = 0;
$red = 0;
$green = 0;
$blue = 0;
$purple = 0;
$yellow = 0;
$cyan = 0;
$black = 0;
$white = 0;
$equal = 0;
$path = "galleri/";
if ( $_FILES['img']['size'] > 0 )
{
if ( in_array( $_FILES['img']['type'], $allowedTypes ) )
{
if ( $_FILES['img']['size'] <= $maxFileSize )
{
$size = getimagesize($_FILES['img']['tmp_name']);
if ( $size[0] < $max_width )
{
if( $size[1] < $max_height )
{
$im=ImageCreateFromJpeg( $_FILES['img']['tmp_name'] );
for ($i = 0; $i < $size[0]; $i++)
{
for ($j = 0; $j < $size[1]; $j++)
{
$rgb = ImageColorAt( $im, $i, $j );
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
if ( $r > $b && $r > $g )
{
$red++;
}
else if ( $b > $r && $b > $g )
{
$blue++;
}
else if ( $g > $b && $g > $r )
{
$green++;
}
else if ( $r == $g && $g > $b )
{
$yellow++;
}
else if ( $r == $b && $b > $g )
{
$purple++;
}
else if ( $g == $b && $b > $r )
{
$cyan++;
}
else if ( $g == $b && $b == $r && $r = 0 )
{
$black++;
}
else if ( $g == $b && $b == $r && $r = 255 )
{
$white++;
}
else
{
$equal++;
}
$antal++;
}
}
}
else
{
$fejl = "Billede ikke sat ind: Filen er for høj!";
}
}
else
{
$fejl = "Billede ikke sat ind: Filen er for bred!";
}
}
else
{
$fejl = "Billede ikke sat ind: Filen er for stor!";
}
}
else
{
$fejl = "Billede ikke sat ind: Forkert fil-format!";
}
}
if ( isset( $fejl ) )
{
echo $fejl;
}
else
{
?>
<TABLE BORDER="0">
<TR VALIGN="top">
<TD width="20px"></TD>
<TD width="50px">Pixels</TD>
<TD width="100px">Areal i %</TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#ff0000; border:1px solid #000000"> </TD>
<TD width="50px"><? print $red ?></TD>
<TD width="100px"><? print round(100/$antal*$red, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#00ff00; border:1px solid #000000"> </TD>
<TD><? print $green ?></TD>
<TD><? print round(100/$antal*$green, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<td width="20px" style="background-color:#0000ff;border:solid 1px #000000;"> </TD>
<TD><? print $blue ?></TD>
<TD><? print round(100/$antal*$blue, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#ffff00; border:1px solid #000000"> </TD>
<TD><? print $yellow ?></TD>
<TD><? print round(100/$antal*$yellow, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#ff00ff; border:1px solid #000000"> </TD>
<TD><? print $purple ?></TD>
<TD><? print round(100/$antal*$purple, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#00ffff; border:1px solid #000000"> </TD>
<TD><? print $cyan ?></TD>
<TD><? print round(100/$antal*$cyan, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#ffffff; border:1px solid #000000"> </TD>
<TD><? print $white ?></TD>
<TD><? print round(100/$antal*$white, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#000000; border:1px solid #000000"> </TD>
<TD><? print $black ?></TD>
<TD><? print round(100/$antal*$black, 2)." %" ?></TD>
</TR>
<TR VALIGN="top">
<TD width="20px" style="background-color:#808080; border:1px solid #000000"> </TD>
<TD><? print $equal ?></TD>
<TD><? print round(100/$antal*$equal, 2)." %" ?></TD>
</TR>
</TABLE>
<?
print "Pixels beregnet: ". ( $size[0] * $size[1] ) ."<BR><br><br>";
print "<img src=\"diagram.php?data=".$red."\*".$green."\*".$blue."\*".$yellow."\*".$purple."\*".$cyan."\*".$black."\*".$white."\*".$equal."&etiket=Rød*Grøn*Blå*Gul*Lilla*Cyan*Hvid*Sort*Grå\">";
// print "<BR><BR><img src=\"".$_FILES['img']['tmp_name']."\">";
imagejpeg($im, '', 100);
}
?>
</body>
</html>