PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 11, 2022

[FIXED] How to create a wallpaper

 October 11, 2022     gd, image, image-manipulation, php, wallpaper     No comments   

Issue

We have some image and we want to create different sized wallpapers from it, like 800x600, 1024x768 or 1600x1200.

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


Solution

$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);


Answered By - Tim Cooper
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing