/usr/share/doc/ImageMagick-perl/demo
NameSizeModeActions
annotate.pl15890644editdlrm
annotate_words.pl19670644editdlrm
button.pl3590644editdlrm
compose-specials.pl54730644editdlrm
composite.pl15250644editdlrm
demo.pl120970644editdlrm
lsys.pl23360644editdlrm
Makefile3600644editdlrm
model.gif234330644editdlrm
piddle.pl19080644editdlrm
pink-flower.gif5440644editdlrm
pixel-fx.pl15450644editdlrm
README1240644editdlrm
red-flower.gif6940644editdlrm
settings.pl6970644editdlrm
shadow-text.pl5050644editdlrm
shapes.pl12400644editdlrm
single-pixels.pl11290644editdlrm
smile.gif13490644editdlrm
steganography.pl6640644editdlrm
tile.gif15660644editdlrm
tree.pl7440644editdlrm
Turtle.pm8680644editdlrm
yellow-flower.gif5650644editdlrm
Edit: /usr/share/doc/ImageMagick-perl/demo/pixel-fx.pl (1545B)
#!/usr/bin/perl # # Example of modifying all the pixels in an image (like -fx). # # Currently this is slow as each pixel is being looked up one pixel at a time. # The better technique of extracting and modifying a whole row of pixels at # a time has not been figured out, though perl functions have been provided # for this. # # Also access and controls for Area Re-sampling (EWA), beyond single pixel # lookup (interpolated unscaled lookup), is also not available at this time. # # Anthony Thyssen 5 October 2007 # use strict; use Image::Magick; # read original image my $orig = Image::Magick->new(); my $w = $orig->Read('rose:'); warn("$w") if $w; exit if $w =~ /^Exception/; # make a clone of the image (preserve input, modify output) my $dest = $orig->Clone(); # You could enlarge destination image here if you like. # And it is possible to modify the existing image directly # rather than modifying a clone as FX does. # Iterate over destination image... my ($width, $height) = $dest->Get('width', 'height'); for( my $j = 0; $j < $height; $j++ ) { for( my $i = 0; $i < $width; $i++ ) { # read original image color my @pixel = $orig->GetPixel( x=>$i, y=>$j ); # modify the pixel values (as normalized floats) $pixel[0] = $pixel[0]/2; # darken red # write pixel to destination # (quantization and clipping happens here) $dest->SetPixel(x=>$i,y=>$j,color=>\@pixel); } } # display the result (or you could save it) $dest->Write('pixel-fx.pam'); $dest->Write(magick=>'SHOW',title=>"Pixel FX");