I am pretty sure it isnt the code, I have tried it on numerous other images, such as Google's logo, and it works fine.
Code: Select all
<?php
/**
* Generated an overlay onto a template
* @author Zu
* @version 0.2
* @package ImageManipulation
*/
class GenerateOverlayImage
{
/**
* The URL of the original image
* @access private
* @var string
*/
private $originalLocation;
/**
* The URL of the template image
* @access private
* @var string
*/
private $templateLocation;
/**
* The overlay image
* @access private
* @var string
*/
private $overlay;
/**
* The template image
* @access private
* @var string
*/
private $template;
/**
* The final image
* @access private
* @var string
*/
private $image;
/**
* Class constructor
* @access public
*/
public function GenerateOverlayImage()
{
$this -> originalLocation = 'http://www.webhostingstuff.com/uptimestatus/1.gif';
$this -> templateLocation = 'template.gif';
$this -> generateOverlay();
$this -> generateTemplate();
}
/**
* Generates the overlay image
* @access private
*/
private function generateOverlay()
{
// Get the image, then get a small part of it
$tempImage = imagecreatefromgif($this -> originalLocation);
$crop = imagecreatetruecolor(75, 20);
// Shrink that small part of the image
imagecopy($crop, $tempImage, 0, 0,
40, 13,
75, 20);
imagecopyresampled($crop, $crop, 0, 0, 0, 0,
55, 20,
imagesx($crop),
imagesy($crop));
// Remove the unessecary excess from the crop
$this -> overlay = imagecreatetruecolor(55, 20);
imagecopy($this -> overlay, $crop, 0, 0,
0, 0,
55, 20);
imagepng($this -> overlay, 'uptime.png');
}
/**
* Generates the template image
* @access private
*/
private function generateTemplate()
{
// The overlay image
//$this -> overlay = imagecreatefrompng($this -> overlay);
$this -> overlay = imagecreatefrompng('uptime.png');
// The template image
$this -> template = imagecreatefromgif($this -> templateLocation);
// Create the basic graphic holder
$this -> image = imagecreatetruecolor(90, 50);
// Put the template in the image
imagecopyresampled($this -> image, $this -> template,
0, 0, 0, 0,
90, 50,
80, 50);
// Begin the overlaying
imagecopymerge($this -> image, $this -> overlay,
30, 12,
0, 0,
imagesx($this -> overlay), imagesy($this -> overlay),
99);
}
/**
* Returns the image
* @access public
* @return string overlayed template image
*/
public function getImage()
{
return imagepng($this -> image);
}
}