How to create a wallpaper
We have some image and we want to create different sized wallpapers from it, like 800x600, 1024x768 or 1600开发者_如何学Pythonx1200.
For example, we have this image http://colourlovers.com.s3.amazonaws.com/images/patterns/1440/1440297.png?1303733122
How do we create wallpapers by php?
So the patterns are tiled backgrounds, they are repeated in all axes, we start from the top:0 and left:0 and continue while it doesn't fit needed size.
Here is an example, in the right block (get this pattern image) http://www.colourlovers.com/pattern/1440297/Spring_Forward
$width = 1440;
$height = 900;
$pattern = imagecreatefrompng('1440297.png');
$image = imagecreatetruecolor($width, $height);
imagesettile($image, $pattern);
imagefill($image, 0, 0, IMG_COLOR_TILED);
header('Content-type: image/png');
imagepng($image);
Check out this tutorial, it will show you how to create nice and reusable class for resizing image
http://net.tutsplus.com/tutorials/php/image-resizing-made-easy-with-php/
精彩评论