Ik heb een code waarmee een wallpaper wordt gemaakt. In internet explorer werkt dit perfect, maar in firefox niet. Daar krijg ik de hexidecimale code (denk ik) ipv de afbeelding te zien.

Iemand die weet waaraan dit kan liggen?

Dit is mijn code:

<?php
error_reporting(0);
$r = null;

foreach ($_REQUEST as $key => $value) {
switch ($key) {
case 'r': $r = $value;break;
}
}
function ob_clean_all () {
$ob_active = ob_get_length () !== false;
while($ob_active) {
ob_end_clean();
$ob_active = ob_get_length () !== false;
}

return true;
}
if ( $r != null ) {

if ( $r == "submitwallpaper" ) {
// open background
$imgName = $_POST['imgName'];
//$imgName = "1600x1200.jpg";
$src_img = imagecreatefromjpeg($imgName);

switch ($imgName) {
case "1024x768.jpg":
$puntX = 571;
$puntY = 184;
break;
case "1152x864.jpg":
$puntX = 645;
$puntY = 259;
break;
case "1600x1200.jpg":
$puntX = 1002;
$puntY = 460;
break;
}


//open overlay image + set transparancy
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];

// create the image with desired width and height

$layer_img = imagecreatetruecolor($w, $h);

// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($layer_img, 0, 0, 0xF9F2E8);

$rows = 0;
$cols = 0;

// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($layer_img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($layer_img, $cols, $rows, $test);
}
}
}



ImageCopyMerge($src_img , $layer_img, $puntX, $puntY, 0, 0, ImageSX($layer_img), ImageSY($layer_img), 90);

$data = imagejpeg($src_img, "", 90);

// File size not set?
$filesize = strlen($data);

// Mimetype not set?
$mimetype = 'application/octet-stream';

// Make sure there's not anything else left
ob_clean_all();

// Start sending headers
/*header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Transfer-Encoding: binary");*/
/*header("Content-Type: " . $mimetype);
header("Content-Length: " . $filesize); */
//header("Content-Disposition: attachment; filename=wallpaper.jpg;" );
header("Content-type: image/jpeg");
header("Content-length: $filesize");
// display the image
imagejpeg($src_img, "", 100);
//die();
}
}
?>
Ook daarvoor hoef je niet te bumpen, maar toch goed dat het nu werkt :)

Reageren