/**
  * Generate a new image resource var
  *
  * @param integer $width
  * @param integer $height
  * @param string $color
  * @param integer $opacity
  *
  * @return resource
  */
 public static function generateImage($width = 100, $height = 100, $color = 'ffffff', $opacity = 127)
 {
     $RGBColors = ImageWorkshopLib::convertHexToRGB($color);
     $image = imagecreatetruecolor($width, $height);
     imagesavealpha($image, true);
     $color = imagecolorallocatealpha($image, $RGBColors['R'], $RGBColors['G'], $RGBColors['B'], $opacity);
     imagefill($image, 0, 0, $color);
     return $image;
 }
 /**
  * Resize the background of a layer
  *
  * @param integer $newWidth
  * @param integer $newHeight
  */
 public function resizeBackground($newWidth, $newHeight)
 {
     $oldWidth = $this->width;
     $oldHeight = $this->height;
     $this->width = $newWidth;
     $this->height = $newHeight;
     $virginLayoutImage = ImageWorkshopLib::generateImage($this->width, $this->height);
     imagecopyresampled($virginLayoutImage, $this->image, 0, 0, 0, 0, $this->width, $this->height, $oldWidth, $oldHeight);
     unset($this->image);
     $this->image = $virginLayoutImage;
 }
 /**
  * Initialize a new virgin layer
  * 
  * @param integer $width
  * @param integer $height
  * @param string $backgroundColor
  * 
  * @return ImageWorkshopLayer
  */
 public static function initVirginLayer($width = 100, $height = 100, $backgroundColor = null)
 {
     $opacity = 0;
     if (!$backgroundColor || $backgroundColor == 'transparent') {
         $opacity = 127;
         $backgroundColor = 'ffffff';
     }
     return new ImageWorkshopLayer(ImageWorkshopLib::generateImage($width, $height, $backgroundColor, $opacity));
 }