RunMyBusiness\Initialcon\Initialcon::getImageData PHP Метод

getImageData() публичный Метод

Get an Initialcon PNG image data.
public getImageData ( string $initials, string $identifier, integer $size = 64, string $hexaColor = null ) : string
$initials string
$identifier string
$size integer
$hexaColor string
Результат string
    public function getImageData($initials, $identifier, $size = 64, $hexaColor = null)
    {
        $img = $this->generateImage($initials, $identifier, $size, $hexaColor);
        return $img->encode('png');
    }

Usage Example

Пример #1
0
 /**
  * Generates an avatar based on the current users initials.
  *
  * @param $image UploadedFile
  *
  * @throws \Exception
  *
  * @return bool
  */
 protected function generate(UploadedFile $image = null)
 {
     $user = Auth::user();
     if ($user->has_avatar) {
         // If the user has an avatar already, we'll make sure
         // we delete it before generating another.
         $user->avatar()->delete();
     }
     if ($image) {
         // Generate the uploaded images file name.
         $fileName = sprintf('%s.%s', $user->id, $image->getClientOriginalExtension());
         // If we've been given an uploaded image we'll retrieve the contents.
         $image = $this->resize($image)->stream();
     } else {
         // Generate the initials image file name.
         $fileName = $user->id . '.jpg';
         // Otherwise we'll generate and retrieve the initials image contents.
         $image = $this->initialcon->getImageData($user->present()->initials(), $user->email, $this->size);
     }
     // Generate the storage path.
     $path = $this->path($fileName);
     // Move the file into storage.
     Storage::put($path, $image);
     // Add the file to the user.
     return $user->addAvatar($path);
 }