Imager::Tutorial 0.54
|
|||||||||||||||||||
Imager::Tutorial is an introduction to Imager.
Before you start
If you have the necessary knowledge, install the image format libraries you want Imager image file support for, and Imager itself, otherwise arrange to have it done.
You will also want some sort of image viewer tool, whether an image editor like Photoshop or the GIMP, or a web browser.
Hello Boxes! - A Simple Start
As with any perl program it's useful to start with a #! line, and to enable strict mode:
#!/usr/bin/perl -w
# you might to 'use warnings;' instead of the -w above
use strict;
These lines will be omitted in further examples.
As with any module, you need to load it:
use Imager;
Now create a image to draw on:
my $image = Imager->new(xsize => 100, ysize => 100);
and draw a couple of filled rectangles on it:
$image->box(xmin => 0, ymin => 0, xmax => 99, ymax => 99,
filled => 1, color => 'blue');
$image->box(xmin => 20, ymin => 20, xmax => 79, ymax => 79,
filled => 1, color => 'green');
Since the first box fills the whole image, it can be simplified to:
$image->box(filled => 1, color => 'blue');
and save it to a file:
$image->write(file=>'tutorial1.ppm')
or die 'Cannot save tutorial1.ppm: ', $image->errstr;
So our completed program is:
use Imager;
my $image = Imager->new(xsize => 100, ysize => 100);
$image->box(filled => 1, color => 'blue');
$image->box(xmin => 20, ymin => 20, xmax => 79, ymax => 79,
filled => 1, color => 'green');
$image->write(file=>'tutorial1.ppm')
or die 'Cannot save tutorial1.ppm: ', $image->errstr;
Requirements:
tags
Download Imager::Tutorial 0.54
Authors software
|
|
|
|
|
|
Similar software
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Other software in this category
|
|
|
|
|
|
|
|
|
|
Featured Software
jEdit 4.3 pre8
jEdit is an Open Source text editor written in Java
Opera 9.02
Surf the Internet in a safer, faster, and easier way with Opera browser
GNU Aspell 0.60.4
GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell
- Communications
- Database
- Desktop Environment
- Games
- Internet
- Multimedia
- Office
- Programming
- Science and Engineering
- System
- Text Editing&Processing
