Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here's another take on the same idea.
I often find myself wanting to output
temporary color spacer gif's for html design
and layout purposes.
Adjust the width, height and color of
a gif file and output without an image module (ie ImageMagick, GD).
#!/usr/bin/perl -w # this script outputs a gif # set color, width, and height use strict; &printGIF("0000FF","33","10"); ###################################### sub printGIF{ my $color = $_[0]; my $WH = sprintf("%lX",$_[1]); my $HH = sprintf("%lX",$_[2]); $color =~ s/(..)(..)(..)/$1\|$2\|$3/; my($RH,$GH,$BH)=split(/\|/,$color); print STDOUT "Content-type:image/gif\n\n"; my @gif=( "47", "49", "46", "38", "37", "61", "$WH", "00", "$HH", "00", "A1", "01", "00", "$RH", "$GH", "$BH", "FF", "FF", "FF", "00", "00", "00", "00", "00", "00", "21", "F9", "04", "05", "00", "00", "01", "00", "2C", "00", "00", "00", "00", "$WH", "00", "$HH", "00", "40", "02", "$HH", "84", "8F", "A9", "CB", "ED", "0F", "A3", "9C", "B4", "DA", "8B", "B3", "DE", "9C", "17", "00", "3B" ); binmode (STDOUT); # if needed foreach my $bit(@gif){ my $bita = hex($bit); $bita = pack("C",$bita); print STDOUT $bita; } }#################################### end printGIF
jtrue

In reply to Output a GIF file with Perl, set width, height and color by true
in thread On-demand single-pixel GIFs by dws

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-24 18:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found