Jump to content

Creating Images from images in PHP


AshleyByrom

Recommended Posts

Okay well I am trying to make a 'dynamic' calender image with PHP.

 

I have images like this:

 

2vb1tso.png

 

and:

2rf6iy8.png

 

Obv I have an image for each day of the month (1 - 31) and I have images for each month.

 

if i created a file named, cal.php i want to be able to use that in an img tag and it will mix two images together (month with day below it) and will show today's date.

 

Any guidance, links to tutorials etc? Thanks in advance!!

Link to comment
https://forums.phpfreaks.com/topic/178974-creating-images-from-images-in-php/
Share on other sites

Here's a quick example I put together for you, this will create an image with the two things you provided:

<?php
// Set the Content-type to image/png to output a PNG image
header('Content-type: image/png');

// Create a new image resource(49x49)
$im = imagecreatetruecolor(49, 49);

//Merge the Month image onto $im, which will be our final image.
imagecopy($im, imagecreatefrompng('http://i36.tinypic.com/2vb1tso.png'), 0, 0, 0, 0, 49, 15);

//Merge the Day image onto $im
imagecopy($im, imagecreatefrompng('http://i37.tinypic.com/2rf6iy8.png'), 0, 15, 0, 0, 49, 34);

// Output $im, the image resource
imagepng($im);
?>

 

Things you'll want to read up about:

 

PHP GD Library

 

imagecopy()

imagecreatetruecolor()

imagepng()

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.