Programming Web Graphics with Perl and GNU Softwar

Book description

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 authors. It is a little documented field, however, and the many valuable free libraries and tools available on the Internet remain under-utilized. Programming Web Graphics with Perl & GNU Software is aimed at intermediate and advanced Web users who want to use CGI scripts to generate dynamic graphic content. It will also help to demystify the manipulation of graphics formats for newcomers to the Web. Programming Web Graphics with Perl & GNU Software takes a practical, resource-like approach to the content. It is not a book about design or aesthetics of Web graphics; its focus is on programming or, more accurately, scripting programs that manipulate graphics file to be published on the Web. Most of the examples in the book use Perl as a scripting language, though the concepts are applicable to any programming language. However, several powerful Perl modules for generating graphics (GD, PerlMagick, GIFgraph) should help position Perl as a major contender for your Web graphics applications. Most of the topics covered in the book are applicable to any platform (NT, Linux, Un*x, MaxOS), with the exception of the chapter detailing the Gnu Image Manipulation Program (a free Adobe Photoshop-like application), which requires a connection to an X server. The focus is always on free software, when it is available. This book covers the following:

  • a tour through the most popular Web graphics file formats by implementing parsers for GIF, JPEG, and PNG files

  • descriptions of the PNG, JPEG, and giflib libraries, as well as many other free and proprietary libraries and SDKs

  • extensive documentation and examples using the Perl graphics modules GD and GIFgraph, and the Perl interface to the powerful ImageMagick libraries

  • documentation on the Gnu Image Manipulation Program (GIMP) and the Perl interface that lets you easily script plug-ins or interface to the GIMP via the Web

  • the creation of image maps from data extracted from a database

  • the implementation of several new Perl modules for the creation of neatly formatted PostScript files

  • details on interfacing to a fax gateway

  • reusable recipes for many popular applications such as Web counters and Web cams

  • the creation of animated GIFs on-the-fly

  • One of the key ingredients to the success of the Web is that anyone who wanted to could participate in publishing to the world. This book will take its readers to the next level of publishing to the world: learning to use scripting programs to create dynamic graphics for their Web sited. The information in this book is written in a practical, easy manner with high-quality documentation and useful examples throughout. It is a detailed reference that provides Web designers and programmers and with the information they need to program.

    Table of contents

    1. Programming Web Graphics with Perl & GNU Software
      1. Preface
        1. Contents of This Book
        2. Conventions Used in This Book
        3. How to Contact Us
        4. Acknowledgments
      2. I. Introduction to Web Graphics
        1. 1. Image File Formats
          1. Network Graphics Basics
            1. Fields and Streams
            2. Color Tables
            3. Transparency and Alpha
            4. Compression
            5. Interlacing
              1. GIF interlacing
              2. PNG interlacing
              3. JPEG interlacing: Progressive JPEGs
            6. GIF, PNG, JPEG: Which to Use When?
              1. Circular or irregularly shaped images
              2. Photographs
              3. Images with text
              4. Grayscale images
              5. Line drawings
              6. Animated images
          2. Graphics Interchange Format (GIF)
            1. The Header Block
            2. The Global Color Table Block
            3. The Image Block(s)
              1. Local Image Descriptor
              2. Local Color Table
              3. Image Data
            4. The Extension Block(s)
              1. The Graphics Control Extension
              2. The Application Extension
          3. Portable Network Graphics (PNG)
            1. The header chunk
            2. The palette chunk
            3. The Image Data chunk
            4. Ancillary chunks
          4. JPEG
            1. The JPEG Encoding Process
              1. Step 1. Color space transform and downsampling
              2. Step 2. Discrete Cosine Transforms
              3. Step 3. Quantization
              4. Step 4. Huffman Encoding
          5. References
        2. 2. 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. Images as Links: ISMAP and USEMAP
            5. Dehanced for Lynx: The ALT Attribute
            6. Background Images
            7. The OBJECT Tag
            8. A Rogue’s Gallery of Proprietary Attributes
              1. Netscape tag extensions
              2. Internet Explorer tag extensions
          4. Colors and the Web Browser
          5. The Once and Future Browser
          6. References
        3. 3. A Litany of Libraries
          1. Image Support Libraries
            1. AA-lib, an ASCII Art Library
            2. The Codes Library: A Free Compression Library
            3. The FreeType Project: A Free TrueType Font Engine
            4. gd: A GIF Manipulation Library
            5. Ghostscript: A Free PostScript Interpreter
            6. GIFLIB and libungif
            7. ImageMagick: An All-Purpose Image Manipulation Library
            8. The IPG’s JPEG Library
            9. NetPBM
            10. photopc
            11. libpng: PNG Image Format Support Library
            12. VFlib: A Font Rasterizer
            13. zlib: A Free Compression Library
          2. References
      3. II. Graphics Programming Tools
        1. 4. On-the-Fly Graphics with GD
          1. GD Jumpstart
          2. Sample Application: A Chess Board Simulator
          3. The GD.pm Distribution
            1. GD Objects and Methods by Category
            2. Image Reading and Writing Methods
              1. new( )
              2. newFromGif( )
              3. newFromXbm( )
              4. newFromGd( )
              5. gif( )
              6. gd( )
            3. Color Manipulation Methods
              1. colorAllocate( )
              2. colorDeallocate( )
              3. colorClosest( )
              4. colorExact( )
              5. colorsTotal( )
              6. getPixel( )
              7. rgb( )
              8. transparent( )
              9. setBrush( )
              10. setStyle( )
              11. setPixel( )
              12. setTile( )
            4. Image Drawing and Manipulation Methods
              1. arc( )
              2. copy( )
              3. copyResized( )
              4. dashedLine( )
              5. fill( )
              6. filledPolygon( )
              7. filledRectangle( )
              8. fillToBorder( )
              9. getBounds( )
              10. interlaced( )
              11. line( )
              12. polygon( )
              13. rectangle( )
              14. string( )
              15. stringUp( )
          4. Font Methods
            1. nchars( )
            2. offset( )
            3. width( ), height( )
          5. Polygon Methods
            1. addPt( )
            2. bounds( )
            3. delete( )
            4. getPt( )
            5. length( )
            6. map( )
            7. offset( )
            8. scale( )
            9. setPt( )
            10. toPt( )
            11. transform( )
            12. vertices( )
        2. 5. Industrial-Strength Graphics Scripting with PerlMagick
          1. Learn PerlMagick in 21 Seconds
          2. The ImageMagick Distributionand PerlMagick
            1. ImageMagick Supported File Formats
            2. Where to Find It
            3. System Requirements
            4. Installing PerlMagick and the ImageMagick Libraries
              1. Installing on *nix
              2. Installing on Windows NT
          3. Image::Magick Attributes and Methods by Category
            1. Attributes
            2. Methods
          4. Reading and Writing Images
            1. Read( )
            2. Write( )
          5. Getting and Setting Image::Magick Attributes
            1. adjoin
            2. background
            3. base_columns
            4. base_filename
            5. base_rows
            6. blue_primary
            7. bordercolor
            8. class
            9. colormap[i]
            10. colors
            11. colorspace
            12. columns
            13. comment
            14. compress
            15. delay
            16. density
            17. depth
            18. dispose
            19. dither
            20. file
            21. filename
            22. filesize
            23. filter
            24. font
            25. format
            26. gamma
            27. geometry
            28. green_primary
            29. height
            30. interlace
            31. iterations
            32. loop
            33. magick
            34. matte
            35. mean
            36. normalized_mean
            37. normalized_max
            38. packetsize
            39. packets
            40. page
            41. pen
            42. pixel
            43. pointsize
            44. quality
            45. red_primary
            46. rendering_intent
            47. rows
            48. signature
            49. size
            50. texture
            51. total_colors
            52. type
            53. units
            54. white_point
            55. width
            56. x_resolution
            57. y_resolution
          6. Manipulating Images
            1. AddNoise( )
            2. Annotate( )
            3. Append( )
            4. Average( )
            5. Blur( )
            6. Border( )
            7. Charcoal( )
            8. Chop( )
            9. Clone( )
            10. Comment( )
            11. Composite( )
            12. Contrast( )
            13. Crop( )
            14. CycleColormap( )
            15. Despeckle( )
            16. Draw( )
            17. Edge( )
            18. Emboss( )
            19. Enhance( )
            20. Equalize( )
            21. Flip( )
            22. Flop( )
            23. Frame( )
            24. Gamma( )
            25. Implode( )
            26. Layer( )
            27. Label( )
            28. Magnify( )
            29. Map( )
            30. Minify( )
            31. Modulate( )
            32. Mogrify( )
            33. MogrifyRegion( )
            34. Montage( )
            35. Negate( )
            36. Normalize( )
            37. OilPaint( )
            38. Opaque( )
            39. Ping( )
            40. Quantize( )
            41. QueryColor( )
            42. Raise( )
            43. ReduceNoise( )
            44. Roll( )
            45. Rotate( )
            46. Sample( )
            47. Scale( )
            48. Segment( )
            49. Shade( )
            50. Sharpen( )
            51. Shear( )
            52. Signature( )
            53. Solarize( )
            54. Spread( )
            55. Swirl( )
            56. Texture( )
            57. Threshold( )
            58. Transform( )
            59. Transparent( )
            60. Trim( )
            61. Wave( )
            62. Zoom( )
          7. How to Tell When Something Has Gone Wrong
          8. Using the ImageMagick Utilities
        3. 6. Charts and Graphs with GIFgraph
          1. Let’s Make Some Graphs!
          2. GIFgraph Reference
            1. GIFgraph Methods
              1. new( )
              2. set_text_clr
              3. set_title_font( )
              4. plot( )
              5. plot_to_gif( )
              6. set( )
              7. set_label_font, set_value_font
              8. set_x_label_font, set_y_label_font, set_x_axis_font, set_y_axis_font
              9. set_legend( )
              10. set_legend_font( )
            2. Attributes of GIFgraph Objects
              1. Attributes for graphs with axes
              2. Attributes for graphs with lines
              3. Attributes for graphs with points
              4. Attributes for legends (axes-type graphs only)
              5. Attributes for pie graphs
          3. Colors in GIFgraph
            1. colour_list
            2. hue
            3. luminance
            4. read_rgb
            5. rgb
            6. sorted_colour_list
          4. Creating Data Sets with Data::Xtab
          5. Passing GIFgraph Graphs to GD Objects
        4. 7. Web Graphics with the Gimp
          1. Quick Gimp
            1. Step 1. Open a New Document and Create a Background
            2. Step 2. Apply a Radial Gradient
            3. Step 3. Create a New Layer
            4. Step 4. Apply a Custom Gradient with Transparency
            5. Step 5. Merge the Layers
            6. Step 6. Apply Plug-In Filters to the Image
            7. Step 7. Apply an Animation Script
            8. Step 8. Save the Marble as an Animated GIF
          2. Getting and Installing the Gimp
          3. Using the Gimp for Day-to-Day Web Projects
            1. Image Formats
              1. GIF
              2. JPEG
              3. PNG
            2. Transparency in the Gimp
            3. Using the Gimp for GIF Animation
          4. Scripting the Gimp in Perl
            1. Installing the Perl-Fu Modules
            2. Anatomy of a Plug-In
              1. The register method
              2. The plug-in subroutine
          5. References
      4. III. Dynamic Graphic Techniques
        1. 8. Image Maps
          1. Client-Side Versus Server-Side
            1. Implementing Client-Side Maps
              1. The <MAP> tag
              2. The <AREA> tag
            2. Server-Side Maps
            3. An Alternative: Image Buttons with the<INPUT> Tag
          2. Image Map Tools
            1. Map Hacker Tools for Generating Coordinates
            2. WYSIWYG Map Editing Tools
            3. Translating Server-Side Image Maps toClient-Side Format
          3. Image Maps on the Fly: A Clickable “Wander” Engine
        2. 9. Moving Pictures: Programming GIF Animation
          1. Anatomy of a GIF89a Animation
            1. Looping
            2. Disposal Methods
            3. Interframe Delay
            4. Local and Global Palettes
            5. Transparency
            6. Interlacing
            7. User Input
          2. Seven Easy Pieces with PerlMagick
            1. #1: Simple Sprites
            2. #2: Several Simple Sprites
            3. #3: Applying an Effect Iteratively
            4. #4: Producing a Separate File for Each Frame
            5. #5: Scrolling an Image Through a Frame
            6. #6. Splitting an Image
            7. #7: Reconstituting Split Images
          3. GIFscript, an Animation Scripting Language
        3. 10. Web Graphics Cookbook
          1. The BrokenImage Module
            1. Requirements
            2. Solution
          2. A Web Page Access Counter
            1. Requirements
            2. Solution
          3. A JavaScript Rollover Menu
            1. Requirements
            2. Solution
          4. A Web Cam
            1. Requirements
            2. Solution
          5. ASCII ALTs
            1. Requirements
            2. Solution
          6. Thumbnailing
            1. Requirements
            2. Solution
          7. References
        4. 11. Paperless Office? Not in Our Lives: Printing and the Web
          1. Everything I Needed to Know About PostScript I Learned Here
            1. The Page
            2. Some PostScript Functions
            3. The PostScript Document Structuring Conventions
              1. The prolog
              2. The body
          2. Using the PostScript Modules on the Web
          3. The PostScript::TextBlock Module
            1. Reference Section
              1. new( )
            2. Reference Section
              1. addText( )
            3. Reference Section
              1. numElements( )
            4. Reference Section
              1. Write( )
            5. Style Sheets
            6. Multipage Documents with PostScript::TextBlock
          4. Multipage Documents with PostScript::Document
            1. new( )
            2. addText( )
            3. addHeader( )
            4. addFooter( )
            5. Write( )
          5. The PostScript::Elements Module
            1. new( )
            2. addArc( )
            3. addBox( )
            4. addLine( )
            5. Write( )
          6. References
      5. IV. Appendixes
        1. A. A Simple PNG Decoder in Perl
        2. B. Quick Reference Guide to the Gimp
          1. The Gimp 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. Text Tool
            8. The Color Picker
            9. The Bucket Fill Tool
            10. 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
          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 Filters Menu
            9. The Script-Fu Menu
        3. C. Procedure Reference for the Gimp
          1. Procedural Database Information
          2. File Operations
          3. Painting, Drawing, and Transforms
          4. Color Control, Palettes, and Patterns
          5. Selection Procedures
          6. Layers and Channels
          7. Undo and Redo
          8. Image Information and Management
          9. User Interface
          10. Extensions
      6. Index
      7. Colophon

    Product information

    • Title: Programming Web Graphics with Perl and GNU Softwar
    • Author(s): Shawn Wallace
    • Release date: February 1999
    • Publisher(s): O'Reilly Media, Inc.
    • ISBN: 9781565924789