Take the tour ×  Suppose I want to take one picture, move all of
its pixels one pixel to the right and one to the left, and save
it. I tried this code:  my $image_file = "a.jpg"; my $im =
GD::Image->newFromJpeg($image_file); my ($width, $height) =
$im->getBounds(); my $outim = new GD::Image($width, $height);
foreach my $x (1..$width)     foreach my $y (1..$height)
my $index = $im->getPixel($x-1,$y-1);         my ($r,$g,$b) =
$im->rgb($index);         my $color =
$outim->colorAllocate($r,$g,$b); %printing the picture...  That
doesn't do the trick; it draws all pixels, except those in which
x=0 or y=0, in one color. Where am I going wrong?  share|improve
this question add comment  3 Answers  up vote 4 down vote
accepted  Look in the docs:  Images created by reading JPEG
images will always be truecolor. To force the image to be
palette-based, pass a value of 0 in the optional $truecolor
argument.  It's not indexed. Try adding a ,0 to your newFromJpeg
call.  From the comments, it seems your next problem