By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

imageline and extra contiguous pixels

P: n/a
Hello!

I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15
compatible) to generated some graphics based on mysql data and to my
surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2,
$cl); (with $cl being the collorallocated via function) the line is
draw dirtying the contiguous pixels of the image ($im), making some
extra pixels around the background. I've removed my jpeg background
and the problem remains. It's something like when we zoom in too much
and got some block
pixels with "random" colors. I don't know what to do. If someone want
to help me I can send two little .jpg (each 20kb) showing the problem.
I'm wondering to use only 16 colors pics (I don't know how to create
it with only 16 colors (4bits?)) to see if I can "fool" the imageline
to avoid extra dirty pixels... help me please!

Thank you for your attention
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"baruch" <sp***@terra.com.br> wrote in message
news:3a*************************@posting.google.co m...
Hello!

I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15
compatible) to generated some graphics based on mysql data and to my
surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2,
$cl); (with $cl being the collorallocated via function) the line is
draw dirtying the contiguous pixels of the image ($im), making some
extra pixels around the background. I've removed my jpeg background
and the problem remains. It's something like when we zoom in too much
and got some block
pixels with "random" colors. I don't know what to do. If someone want
to help me I can send two little .jpg (each 20kb) showing the problem.
I'm wondering to use only 16 colors pics (I don't know how to create
it with only 16 colors (4bits?)) to see if I can "fool" the imageline
to avoid extra dirty pixels... help me please!

Thank you for your attention


Code, code, code, code, code. Make a test application that demonstrates the
same problem with minimal code and post it so we can try it ourselves.

Garp
Jul 17 '05 #2

P: n/a
"Garp" <ga***@no7.blueyonder.co.uk> wrote in message news:<gK*********************@news-text.cableinet.net>...
"baruch" <sp***@terra.com.br> wrote in message
news:3a*************************@posting.google.co m...
Hello!

I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15
compatible) to generated some graphics based on mysql data and to my
surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2,
$cl); (with $cl being the collorallocated via function) the line is
draw dirtying the contiguous pixels of the image ($im), making some
extra pixels around the background. I've removed my jpeg background
and the problem remains. It's something like when we zoom in too much
and got some block
pixels with "random" colors. I don't know what to do. If someone want
to help me I can send two little .jpg (each 20kb) showing the problem.
I'm wondering to use only 16 colors pics (I don't know how to create
it with only 16 colors (4bits?)) to see if I can "fool" the imageline
to avoid extra dirty pixels... help me please!

Thank you for your attention


Code, code, code, code, code. Make a test application that demonstrates the
same problem with minimal code and post it so we can try it ourselves.

Garp


// just testing without loading the .jpeg
// $im = imagecreatefromjpeg("imagens/a4escala.jpg");

$im = imagecreatetruecolor(750, 650);
if (!$im) { die("error..."); }

$c = imagecolorallocate ($im, 255, 255, 255);
imagefilledrectangle ($im, 0, 0, 750, 650, $c);

// [...] here the data is loaded from a sql query;
// some color allocation...
$cl= imagecolorallocate ($im, 0, 0, 255); // azul
header("Content-type: image/jpeg");
// for {
// more some calcs and loops to generated 5 up to 7 lines (array of points)
imageline($im, $x1, $y1, $x2, $y2, $cl);
// }
$arq = "relatorios/g-001001SP-".$f_id.".jpg";
imagejpeg($im, $arq);
imagejpeg($im);
imagedestroy($im);
deleta_rel_tmp();
unset($a_x, $a_y, $a_v);
Jul 17 '05 #3

P: n/a

"baruch" <sp***@terra.com.br> wrote in message
news:3a**************************@posting.google.c om...
"Garp" <ga***@no7.blueyonder.co.uk> wrote in message news:<gK*********************@news-text.cableinet.net>...
"baruch" <sp***@terra.com.br> wrote in message
news:3a*************************@posting.google.co m...
Hello!

I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15
compatible) to generated some graphics based on mysql data and to my
surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2,
$cl); (with $cl being the collorallocated via function) the line is
draw dirtying the contiguous pixels of the image ($im), making some
extra pixels around the background. I've removed my jpeg background
and the problem remains. It's something like when we zoom in too much
and got some block
pixels with "random" colors. I don't know what to do. If someone want
to help me I can send two little .jpg (each 20kb) showing the problem.
I'm wondering to use only 16 colors pics (I don't know how to create
it with only 16 colors (4bits?)) to see if I can "fool" the imageline
to avoid extra dirty pixels... help me please!

Thank you for your attention


Code, code, code, code, code. Make a test application that demonstrates the same problem with minimal code and post it so we can try it ourselves.

Garp


// just testing without loading the .jpeg
// $im = imagecreatefromjpeg("imagens/a4escala.jpg");

$im = imagecreatetruecolor(750, 650);
if (!$im) { die("error..."); }

$c = imagecolorallocate ($im, 255, 255, 255);
imagefilledrectangle ($im, 0, 0, 750, 650, $c);

// [...] here the data is loaded from a sql query;
// some color allocation...
$cl= imagecolorallocate ($im, 0, 0, 255); // azul
header("Content-type: image/jpeg");
// for {
// more some calcs and loops to generated 5 up to 7 lines (array of

points) imageline($im, $x1, $y1, $x2, $y2, $cl);
// }
$arq = "relatorios/g-001001SP-".$f_id.".jpg";
imagejpeg($im, $arq);
imagejpeg($im);
imagedestroy($im);
deleta_rel_tmp();
unset($a_x, $a_y, $a_v);


Still having this? I tried this code and it's not really showing it (least
of all, $x1, $y1 etc are all undefined so I'm filling in bogus values). Feel
like posting URLs to the Jpegs?

Garp
Jul 17 '05 #4

P: n/a
"baruch" <sp***@terra.com.br> wrote in message
news:3a**************************@posting.google.c om...
"Garp" <ga***@no7.blueyonder.co.uk> wrote in message news:<gK*********************@news-text.cableinet.net>...
"baruch" <sp***@terra.com.br> wrote in message
news:3a*************************@posting.google.co m...
Hello!

I'm using PHP Version 4.3.3RC5-dev with GD Version bundled (2.0.15
compatible) to generated some graphics based on mysql data and to my
surprise when I use the GD function imageline($im, $x1, $y1, $x2, $y2,
$cl); (with $cl being the collorallocated via function) the line is
draw dirtying the contiguous pixels of the image ($im), making some
extra pixels around the background. I've removed my jpeg background
and the problem remains. It's something like when we zoom in too much
and got some block
pixels with "random" colors. I don't know what to do. If someone want
to help me I can send two little .jpg (each 20kb) showing the problem.
I'm wondering to use only 16 colors pics (I don't know how to create
it with only 16 colors (4bits?)) to see if I can "fool" the imageline
to avoid extra dirty pixels... help me please!

Thank you for your attention


Code, code, code, code, code. Make a test application that demonstrates the same problem with minimal code and post it so we can try it ourselves.

Garp


// just testing without loading the .jpeg
// $im = imagecreatefromjpeg("imagens/a4escala.jpg");

$im = imagecreatetruecolor(750, 650);
if (!$im) { die("error..."); }

$c = imagecolorallocate ($im, 255, 255, 255);
imagefilledrectangle ($im, 0, 0, 750, 650, $c);

// [...] here the data is loaded from a sql query;
// some color allocation...
$cl= imagecolorallocate ($im, 0, 0, 255); // azul
header("Content-type: image/jpeg");
// for {
// more some calcs and loops to generated 5 up to 7 lines (array of

points) imageline($im, $x1, $y1, $x2, $y2, $cl);
// }
$arq = "relatorios/g-001001SP-".$f_id.".jpg";
imagejpeg($im, $arq);
imagejpeg($im);
imagedestroy($im);
deleta_rel_tmp();
unset($a_x, $a_y, $a_v);


If you change 'imagejpeg($im);' to 'imagejpeg($im,"",100) the problem may
go away. This is the quality of the image from 0 to 100 with 100 being the
best. The only other thing to do is use 'imagepng' instead (or gif if you
install it). The problem simply is the jpeg compression causes artifacts
with solid colors and/or sharp edges.

p.s. make sure you include the double quotes "" as you can't specify the
quality without them.

Norm
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.