$newImage //Destination image link resource imgImport //Source image link resource x //x-coordinate of destination point $imgName_h - $y - 1 //y-coordinate of destination point x //x-coordinate of source point y // y-coordinate of source point 1 //Source width 1 //Source height
Now that we have actually copied the image and placed it on the destination image.
Lines & Shapes
We can create lines and other shapes in PHP. This allows us to create many nice looking effects like creating graphs or adding additional graphics to images dynamically.
imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
image //An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().
x1 // x-coordinate for first point y1 //y-coordinate for first point x2 // x-coordinate for second point y2 //y-coordinate for second point color // The line color. A color identifier created with imagecolorallocate()
As you can see we have 2 y cords and 2 x cords. Now this can be explained how these work using the diagram below.
You are able to create nice looking rectangles, but they can also look like squares.
imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
image //An image resource, returned by one of the image creation functions, such as imagecreatetruecolor(). x1 //x-coordinate for point 1 y1 //y-coordinate for point 1 x2 //x-coordinate for point 2 y2 //y-coordinate for point 2 color //The fill color. A color identifier created with imagecolorallocate()
They are some of the basic of shapes and the easiest. Next we shall be talking about Circles in the next chapter Part 3
You really do plan this stuff out well, man. I really like this series of guides.
However, I have a few requests for the next couple of guides:
1) Explain the relation between coordinates and pixels, please O.o
2) If we use header(Content-type:image/png), how can GD be useful in lets say, a gallery, if it doesn't output more than an image?
3) Can you do a side-by-side of GD and the other image thing... Imagick?