The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Image::Empty - HTTP response helper for 1x1 empty GIFs, used with tracking URLs.

VERSION

Version 0.16

SYNOPSIS

Create 1x1 empty GIFs to use in tracking URLs without the hassle of actually creating and/or loading image data.

Such a basic and common scenario deserves a basic solution.

 use Image::Empty;
 
 my $gif = Image::Empty->gif;
 
 print $gif->render;   # HTTP headers and body

METHODS

Class Methods

gif

Returns a new instance representing an empty GIF for use in an HTTP response.

 my $gif = Image::Empty->gif;

Instance Methods

render

The render method is used to set the HTTP headers and body.

 $gif->render;

With no arguments, returns a string.

Under a CGI environment this would generally be printed directly to STDOUT (ie, the browser).

Chaining methods together can give very concise and compact code.

 use Image::Empty;
 
 print Image::Empty->gif->render;

Remember that the render method returns the HTTP headers. The above 2 lines are all you need in a script.

Plack

If you are working with Plack, supply the Plack::Response object to the render method.

The finalized Plack::Response object is returned.

As a quick one-liner...

 my $app = sub {

         return Image::Empty->gif->render( Plack::Response->new );
 }

It is the same as doing...

 my $app = sub {
 
         my $gif = Image::Empty->gif;
 
         my $response = Plack::Response->new;
 
         $response->status(200);
 
         $response->content_type( $gif->type );
         $response->content_length( $gif->length );
 
         $response->header( 'Content-Disposition' => $gif->disposition . '; filename="' . $gif->filename . '"' );
 
         $response->body( $gif->content ); 
 
         return $response->finalize;
 }

Attributes

type

 $gif->type;

Returns the mime/type of the image for use in HTTP headers.

length

 $gif->length;

Returns the content length for use in HTTP headers.

disposition

 $gif->disposition;

Returns the content disposition for use in HTTP headers.

filename

 $gif->filename;

Returns the content filename for use in HTTP headers.

content

 $gif->content;

Returns the image data to send in the HTTP response body.

TODO

mod_perl support

PNG support

Catalyst support

AUTHOR

Rob Brown, <rob at intelcompute.com>

BUGS

Please report any bugs or feature requests to bug-image-empty at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Image-Empty. I will be notified, and then you will automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Image::Empty

You can also look for information at:

ACKNOWLEDGEMENTS

I can not actually remember where the original line came from to produce the gif content.

LICENSE AND COPYRIGHT

Copyright 2012 Rob Brown.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.