Perl Graphics Programming

Book description

Graphics programmers aren't the only ones who need to be proficient with graphics. Web and applications programmers know that a dull web page can be quickly transformed into one that's interesting and lively with the use of well-planned graphics. And fortunately, you don't need the skills of a fulltime graphics programmer to use graphics effectively. From access counters and log report graphs to scientific plots and on-the-fly animated GIFs, graphics scripting is within the grasp of most web programmers. Using open source software, like Perl, you have the power to dynamically generate graphics based on user input and activity, easily manipulate graphics content, and optimize graphics for compression and quality.Geared toward Perl users and webmasters, Perl Graphics Programming focuses on open-source scripting programs that manipulate graphics files for use on the Web. The book demystifies the manipulation of graphics formats for newcomers to the Web with a practical, resource-like approach. With this book you'll learn to:

  • Generate dynamic web graphics with charts, tables, and buttons
  • Automate graphics tasks (thumbnails and borders)
  • Create dynamics web documents (PDF, Postscript)
  • Produce rich Internet experiences with Flash and SVG
You'll begin with a tour of the most common web graphic file formats--PNG, JPEG, GIF, SWF, SVG, Postscript and PDF--then you'll explore the most powerful tools and Perl modules available for manipulating these graphics, such as GD, PerlMagick, and GIMP. Included in this part of the book is a thorough description of the Ming module for creating on-the-fly Flash files. Next, a "cookbook" section includes practical, all purpose recipes: GIF animation, generating images within a dynamic application, communicating between SWF front-end and Perl back-end, XSLT transformations, compression, and much more.Perl programmers naturally turn to Perl to tackle whatever challenge they have at hand, and graphics programming is no exception. Perl Graphics Programming provides all the tools you need to begin programming and designing graphics for the Web immediately. This book will change how you think about generating and manipulating graphics for the Web.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2. Preface
    1. Creating Raster Images and Web Graphics
    2. Creating Vector Images and Animations
    3. Creating Documents and Printing
    4. Using Code Examples
    5. Conventions Used in This Book
    6. How to Contact Us
    7. Acknowledgments
  3. I. Raster Images and Web Graphics
    1. 1. Creating Graphics with Perl
      1. Introduction to File Formats
      2. Color
        1. The RGB Color Space
        2. The CMYK Color Space
        3. Color Depth
        4. Color Tables
        5. Transparency and Alpha
      3. Raster File Formats
        1. Compression
        2. Interlacing
          1. Scanline (GIF) interlacing
          2. Adam7 (PNG) interlacing
          3. Progressive JPEGs
        3. PNG: An Open Standard for Web Graphics
        4. JPEG: The P Stands for Photographic
        5. GIF Animation for Fun and Profit
      4. Vector Graphic File Formats
        1. SVG for XML Images
        2. SWF for Flash Animation
      5. Document File Formats
        1. PostScript: A Language for Page Representation
        2. PDF: Toward a Truly Portable Document
      6. References
    2. 2. On-the-Fly Graphics with GD
      1. GD Basics
      2. Sample GD Applications
        1. Simple Drawing: Hello World
        2. Images from User Input: A Customized Billboard
        3. Image Generation Modules: The BrokenImage Module
      3. Reading and Writing Methods
      4. Getting and Setting General Information
      5. Color Table Manipulation Methods
      6. Brushes, Styles, and Tiles
      7. Copying and Transforming Images
      8. Image Drawing and Manipulation Methods
      9. Strings and Fonts
      10. Polygon Methods
    3. 3. Graphics Scripting with Image::Magick
      1. What Is ImageMagick?
        1. Installing ImageMagick
        2. ImageMagick’s Command-Line Tools
      2. Using Image::Magick
        1. The Basic Approach
        2. Error Checking
      3. Sample Image::Magick Applications
        1. Thumbnails with Image::Magick
        2. GIF Animation with Image::Magick
      4. Reading and Writing Images
      5. Retrieving and Setting File Information
      6. Sizing and Transforming Images
      7. Copying and Composing Images
      8. Color and Transparency
      9. Annotation and Drawing
      10. Filters and Effects
    4. 4. Charts and Graphs with GD::Graph
      1. Let’s Make Some Graphs!
      2. A Sample GD::Graph Application
      3. GD::Graph Methods
      4. Attributes of GD::Graph Objects
        1. Attributes of All Graphs
        2. Attributes of Graphs with Axes
        3. Attributes of Bar Graphs
        4. Attributes of Graphs with Lines
        5. Attributes of Graphs with Points
        6. Attributes of Mixed Graphs
        7. Attributes of Pie Graphs
        8. Logos and Legends
      5. Colors and Fonts in GD::Graph
    5. 5. Scripting the Gimp with Perl
      1. Getting and Installing the Gimp
        1. Installing the Gimp
        2. Installing the Perl Scripting Extension
      2. Writing Gimp Plug-ins in Perl
        1. The Gimp and Gimp::Fu Modules
        2. Types of Plug-ins
      3. Your First Gimp Script
      4. Object-Oriented Versus Procedural Scripting
      5. Adding New Features to the Gimp
        1. Handling Selections and Layers
        2. Manipulating Raw Data with Pixel Regions
          1. The PixelRgn object
          2. PDL objects
          3. A filter plug-in using pixel regions
        3. Alternative User Interfaces
      6. Standalone Scripts
  4. II. Vector Images and Animations
    1. 6. SVG: The Scalable Vector Graphics Format
      1. SVG Document Structure
        1. Viewing SVG Documents
          1. Standalone SVG documents
          2. Embedding SVG as an image reference
          3. Embedding SVG as an inline image
        2. Serving Compressed SVGs
        3. Rendering an SVG Document Tree
        4. Views and Coordinate Systems
      2. The Basic SVG Tags
        1. Structural Tags
        2. Shapes, Paths, and Images
        3. Text Elements
        4. Linking in SVG
    2. 7. Creating SVG with Perl
      1. A Slide-Show Presentation
      2. SVG Animation
      3. Creating a Bouncing Ball
      4. SVG Scripting with JavaScript
      5. Using Unicode Text in SVG Images
      6. Transformation with XSLT and Perl
    3. 8. SWF: The Flash File Format
      1. The History of Flash and SWF
      2. The Format and Function of SWF Files
        1. Definition Tags
          1. Shapes
          2. Text and fonts
          3. Bitmaps
          4. Buttons
          5. Sounds
          6. Morph shapes
          7. Sprites
        2. Control Tags
        3. The Dictionary and Display List
        4. SWF Data Types
          1. Integer fields
          2. Bit fields
          3. The coordinate system
      3. Anatomy of a Tag
        1. The Header Record
        2. Character ID
        3. Bounding Box
        4. The Fill Style Array
        5. The Line Style Array
        6. NumFillBits and NumLineBits
        7. The ShapeRecord List
      4. Parsing an SWF File with Perl
    4. 9. Using Ming
      1. Installation
      2. Overview of the Perl Interface
      3. The Astral Trespassers Game
      4. The SWF Module
      5. The SWF::Movie Module
      6. The SWF::Sprite (or SWF::MovieClip) Module
      7. The SWF::DisplayItem Module
      8. The SWF::Shape Module
      9. The SWF::Button Module
      10. The SWF::Bitmap Module
      11. The SWF::Text Module
      12. The SWF::TextField Module
      13. The SWF::Font Module
      14. The SWF::Fill Module
      15. The SWF::Gradient Module
      16. The SWF::Morph Module
      17. The SWF::Sound Module
      18. The SWF::Action Module
      19. SWF Recipes
        1. Drawing a Circle
        2. Creating a Preloader with Ming
        3. Assembling Sprite-Based Documents with XML
        4. Communicating Between an SWF Client and a Perl Backend
  5. III. Documents and Printing
    1. 10. Printing with Postscript and PDF
      1. PostScript in a Nutshell
        1. The Page
        2. Some PostScript Functions
        3. PostScript Document Structuring Conventions
          1. The prolog
          2. The body
      2. Portable Document Format (PDF)
        1. Structure of a PDF File
          1. The header
          2. The body
          3. The cross-reference table
          4. The trailer
        2. PDF Operators for Drawing Graphics
          1. Constructing paths
          2. Setting the graphics state
          3. Filling and stroking the path
        3. PDF Operators for Drawing Text
        4. Drawing with the Text::PDF Module
      3. References
    2. 11. Using the PostScript Modules
      1. Creating PostScript from a Web Interface
      2. The PostScript::TextBlock Module
      3. The PostScript::Document Module
      4. The PostScript::Elements Module
      5. Other PostScript Modules
    3. 12. Creating PDF Documents with Perl
      1. Introduction to PDF::API2
      2. Creating Address Labels
      3. Adding to Existing PDF Files
      4. PDF::API2 Reference
      5. PDF::API2::Page
      6. PDF::API2::Content
      7. PDF::API2::Gfx
      8. PDF::API2::Text
      9. PDF::API2::Outline
      10. References
  6. IV. Appendixes
    1. A. Serving Graphics on the Web
      1. The Server and CGI
        1. The CGI.pm Module
          1. Parsing CGI input with CGI.pm
          2. Generating HTTP headers with CGI.pm
        2. Increasing Server Performance
          1. Limit the number of simultaneous requests
          2. Install mod_perl
          3. Image farming
      2. Web Graphics and the Browser
      3. Presenting Images in HTML
        1. The SRC Attribute
        2. The WIDTH and HEIGHT Attributes
        3. Layout and Spacing Attributes
        4. The ALT Attribute
        5. Background Images
        6. The OBJECT Tag
      4. References
    2. B. Gimp Reference
      1. The Gimp::Fu register( ) Method
      2. The Gimp Interface
        1. The Toolbox
          1. The selection tools
          2. The move tool
          3. The magnifying glass tool
          4. The crop tool
          5. The transform tool
          6. The flip tool
          7. The text tool
          8. The color picker
          9. The bucket fill tool
          10. The blend tool
          11. The pencil tool
          12. The paintbrush tool
          13. The eraser tool
          14. The airbrush tool
          15. The clone tool
          16. The convolver tool
          17. The ink tool
          18. The dodge and burn tool
          19. The smudge tool
          20. The measure tool
        2. The Toolbox Menu Hierarchy
          1. The file menu
          2. The Xtns menu
        3. The Image Menu Hierarchy
          1. The File menu
          2. The Edit menu
          3. The Select menu
          4. The View menu
          5. The Image menu
          6. The Layers menu
          7. The Tools menu
          8. The Dialogs menu
          9. The Filters menu
          10. The Guides menu
          11. The Script-Fu menu
    3. C. Image::Magick File Formats
    4. D. ActionScript Reference
      1. Operators and Control Structures
      2. Actions, Functions, and Properties
      3. Objects
  7. Index
  8. About the Author
  9. Colophon
  10. Copyright

Product information

  • Title: Perl Graphics Programming
  • Author(s): Shawn Wallace
  • Release date: December 2002
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596002190