Search notes:

Script: createImage.pl

createImage.pl can be used to create simple images from the command line.
For example
createImage.pl -width=300 -height=150 -red=20 -green=40 -blue=200
creates an 300x150 px image with an RGB background of #1428c8.
The name of the image is determined by its parameters. The example above would create img_300x150_20_40_200.png.
use warnings;
use strict;

use GD;
use Getopt::Long;

my $width     =   1;
my $height    =   1;
my $bgColor_r = 255;
my $bgColor_g = 255;
my $bgColor_b = 255;
my $bgAlpha   =   0; # 0 .. 127

die unless GetOptions (
  'width=i'                  => \$width,
  'height=i'                 => \$height,
  'red=i'                    => \$bgColor_r,
  'green=i'                  => \$bgColor_g,
  'blue=i'                   => \$bgColor_b,
  'alpha=i'                  => \$bgAlpha
);

my $image = new GD::Image($width, $height);

my $bgColor = $image->colorAllocateAlpha($bgColor_r, $bgColor_g, $bgColor_b, $bgAlpha);
$image -> fill(0, 0, $bgColor);

my $filename = "img_${width}x${height}_${bgColor_r}_${bgColor_g}_${bgColor_b}_${bgAlpha}.png";

open my $out, '>', $filename;
binmode $out;
print   $out $image->png;
close   $out;
Github repository scripts-and-utilities, path: /createImage.pl

See also

Scripts

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390852, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/tools/scripts/personal/createImage_pl(82): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78