Jump to content

PHP Image Building.


MrSheen

Recommended Posts

Hey guys, im looking into building a website which has avatar creation programs on it.

 

Now ive seen some websites, and you can buy like clothes to put on the character. Then when you view the character, it builds up your avatars to show what clothes you are wearing.

 

It looks like

 

char.png?t=00

 

How is building up a image in php possible? Say i want to have:

 

1.png, 2.png, 3.png all layered up on top of each other.

 

Is this possible?

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/55716-php-image-building/
Share on other sites

okay let's say you have three images that you want to be placed on each other

 

 

first you create an image resource

 

$im1 = imagecreatefromjpeg("img1.jpg");
$im2 = imagecreatefromjpeg("img2.jpg");
$im3 = imagecreatefromjpeg("img3.jpg");

 

now you want to place $im2 on $im1

 

where $x,$y is the position which you want to place $im2 knowing that the origin is at the top left corner

and $x1,$y1 is the point where you want to start the copying probably it will jsut be 0,0 to copy the whole image

 

imagecopyresampled ($im1, $im2, $x, $y, $x1, $y1, imagesx($im1), imagesy($im1), imagesx($im2), imagesx($im2) )

 

and repeat with $im3

 

as for transperancy you can use

where $im1 is the image resource and $color is an RBG color created using imagecolorallocate($im1,255,255,255)

imagecolortransparent($im1,$color)

Link to comment
https://forums.phpfreaks.com/topic/55716-php-image-building/#findComment-275919
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.