Skip to content

Instantly share code, notes, and snippets.

@CompSciRocks
Last active December 5, 2018 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CompSciRocks/888af3826331ebc327a214bfb56a396b to your computer and use it in GitHub Desktop.
Save CompSciRocks/888af3826331ebc327a214bfb56a396b to your computer and use it in GitHub Desktop.
Tiny script to create solid color images using PHP and GD Library for https://colorswatches.info - blog post at https://compsci.rocks/solid-color-image-in-php/
<?php
$red = 100;
$blue = 150;
$green = 200;
$my_img = imagecreate( 1000, 1000 );
$background = imagecolorallocate( $my_img, $red, $green, $blue );
header( "Content-type: image/png" );
imagepng( $my_img );
imagecolordeallocate( $my_img, $background );
imagedestroy( $my_img );
die();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment