Repeat pattern to 1024x768 php [closed]
I have an image with dimensions 100x100 pixels, it is a seamless pattern png.
How do I tile it to the dimension 1024x768 pixels with php?
If you want to use php, it's not such a big deal with GD:
$file = imagecreatefrompng("pattern.png");
$newFile = imagecreatetruecolor(1024, 768);
for($i = 0; $i <= 1024; $i += 100) {
for($j = 0; $j <= 768; $j += 100) {
imagecopy($newFile, $file, $i, $j, 0, 0, 100, 100);
}
}
imagepng($newFile, "pattern-1024.png");
If you can use HTML and CSS:
.pattern {
width: 1024px;
height: 768px;
background: url("pattern.png") repeat;
}
I'm going to guess that you want the HTML page to display your pattern repeatedly. If that's the case, it is not done by PHP but by CSS. You could use a rule such as:
body
{
background-image:url('yourpattern.png');
background-repeat:repeat;
}
You could look into the GD functions (see example).
精彩评论