Answer the question
In order to leave comments, you need to log in
How to generate a GIF of a given size from a string?
There is a function that generates a 1x1 px gif. You need to change it so that you can set the size. I can not understand from the specification where to specify the dimensions.
function gifStr($r = 0, $g = 0, $b = 0, $transparent = true)
{
return pack('C*',
71, 73, 70, 56, 57, 97, // "GIF89a"
// Logical screen descriptor
1, 0, // logical screen width
1, 0, // logical screen height
128, // global color table | color resolution(3) | sort flag | size of global color table (3)
0, // background color index
0, // pixel aspect ratio
$r, $g, $b, 0, 0, 0, // global color table
// Graphic control extension
0x21, // extension introducer
0xF9, // graphic control label
4, // block size
1, // disposal method(3) | user input(3) | transparency |
0, 0, // delay time
$transparent ? 0 : 1, // transparent color index
0, // block terminator
// Image descriptor
0x2C, // image seperator
0, 0, // image left position
0, 0, // image top position
1, 0, // image height
1, 0, // image width
0, // local color | interlaced | ordered | reserved(2) | size of color table (3)
2, 2, 68, 1, 0, // image data
59); // gif trailer
}
function gifStr($width = 1, $height = 1, $r = 0, $g = 0, $b = 0, $transparent = true) {...}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question