/**
* Private method to run the imagecopyresampled() function with the parameters that have been set up.
* This method is used by the save() and show() methods.
*/
private function createResampledImage()
{
/* change ImageCreateTrueColor to ImageCreate if your GD not supported ImageCreateTrueColor function*/
if ( isset($this->image["sizex_thumb"]) && isset($this->image["sizey_thumb"]) ) {
$this->image["des"] = ImageCreateTrueColor($this->image["sizex_thumb"], $this->image["sizey_thumb"]);
$this->preserveAlpha();
imagecopyresampled($this->image["des"], $this->image["src"], 0, 0, $this->image["targetx"], $this->image["targety"], $this->image["sizex_thumb"], $this->image["sizey_thumb"], $this->image["sizex"], $this->image["sizey"]);
} else {
$this->image["des"] = ImageCreateTrueColor($this->image["sizex"], $this->image["sizey"]);
$this->preserveAlpha();
imagecopyresampled($this->image["des"], $this->image["src"], 0, 0, $this->image["targetx"], $this->image["targety"], $this->image["sizex"], $this->image["sizey"], $this->image["sizex"], $this->image["sizey"]);
}
}
/**
* preserve alpha channel
* @return boolean true:enable transparency alpha blending
*/
private function preserveAlpha($bool=true){
imagealphablending($this->image["des"], !$bool);
imagesavealpha($this->image["des"], $bool);
}