-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagebackground.php
executable file
·50 lines (40 loc) · 1.23 KB
/
imagebackground.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/php -f
<?php
/*
* USAGE:
* prog source-image destination-basename
*/
//debugging
error_reporting(E_ALL);
ini_set('display_errors', '1');
$chars = array("0", "3", "6", "9", "C", "F");
$colors = array();
foreach ($chars as &$a) {
foreach ($chars as &$b) {
foreach ($chars as &$c) {
$colors[] = "0x" . $a . $a . $b . $b . $c . $c;
}
}
}
$source = imagecreatefromstring(file_get_contents($_SERVER['argv'][1]));
$width = imagesx($source);
$height = imagesy($source);
$filename = $_SERVER['argv'][2];
foreach ($colors as &$color) {
$destination = imagecreatetruecolor($width, $height);
imagefill($destination, 0, 0, $color);
imagecopy($destination, $source, 0, 0, 0, 0, $width, $height);
imagepng($destination, $filename . $color . ".png");
}
/* OLD VERSION
//usage php set_bg_color.php original.{png|jpg|...} color output.png
$col = $_SERVER['argv'][2];
$src_im = imagecreatefromstring( file_get_contents( $_SERVER['argv'][1] ) );
$src_w = imagesx( $src_im );
$src_h = imagesy( $src_im );
$dst_im = imagecreatetruecolor( $src_w, $src_h );
imagefill( $dst_im, 0, 0, $_SERVER['argv'][2] );
imagecopy( $dst_im, $src_im, 0, 0, 0, 0, $src_w, $src_h );
imagepng( $dst_im, $_SERVER['argv'][3] );
*/
?>