Beispiel #1
0
 /**
  * Loads an image from $string
  *
  * @param string $filename
  * @return GDImage
  */
 public static function fromString($string)
 {
     $image = new GDImage(1, 1);
     imagedestroy($image->image);
     if (!($image->image = @imagecreatefromstring($string))) {
         return null;
     }
     if (!imageistruecolor($image->image)) {
         $tcimage = imagecreatetruecolor(imagesx($image->image), imagesy($image->image));
         imagecopy($tcimage, $image->image, 0, 0, 0, 0, imagesx($image->image), imagesy($image->image));
         imagedestroy($image->image);
         $image->image = $tcimage;
     }
     if (!$image->image) {
         return null;
     }
     $image->saveAlpha();
     $image->alphaBlending();
     $image->type = 'jpg';
     return $image;
 }