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
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()

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.