开发者

Repeat pattern to 1024x768 php [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago. 开发者_开发百科

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜