Jump to content

copying image pixel by pixel


cohs

Recommended Posts

can someone help me and tell me why this only outputs a black rectangle.

 

<?php
header("Content-type: image/jpg");
$a = imagecreatefromjpeg("c:\C.jpg");

$x = imagesx($a) ;
$y = imagesy($a);

$new = imagecreatetruecolor($x,$y);
imagepalettecopy($new,$a);

for ($count2 =1; $count2 >=$y;$count2++){
for ($count = 1;$count >= $x;$count++){


  $pixel = imagecolorat($a,$count,$count2);
$pix = imagecolorsforindex($a,$pixel);
$color = imagecolorallocate($a,$pix['red'],$pix['green'],$pix['blue']);

imagesetpixel($new,$count,$count2, $color);

}
}


imagejpeg($new);?>

i know its messy but i was moving things around trying to figure it out.

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/85484-copying-image-pixel-by-pixel/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.