Ejemplo n.º 1
0
 private function copyAvatar($image, GWF_User $user, $pos = 1)
 {
     # Logo
     $filename = $user->getAvatarFilename();
     if (false === ($avatar = imagecreatefromstring(file_get_contents($filename)))) {
         echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array($filename));
         return false;
     }
     # Resize
     if (false === ($avatar2 = GWF_Image::resize($avatar, self::WIDTH, self::HEIGHT))) {
         echo GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
         return false;
     }
     $w = imagesx($avatar2);
     $h = imagesy($avatar2);
     $this->box_avatar->w = $w;
     $this->box_avatar->h = $h;
     if ($pos === 2) {
         $this->box_avatar->x = $this->box_stats->getX2() + 1 - $w;
     } else {
         $this->box_avatar->x = $this->box_stats->x;
         $this->box_stats->x += $w;
     }
     if (!imagecopy($image, $avatar2, $this->box_avatar->x, $this->box_avatar->y, 0, 0, $w, $h)) {
         echo GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
         return false;
     }
     imagedestroy($avatar2);
     $this->box_stats->w -= $w;
     return true;
 }