Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get the head from the player uploaded skin
- * Cut the hat and place it on the top of the cut head.
- * Rectangle for head is (8, 8, 8, 8)
- * Rectangle for hat is (40, 8, 8, 8)
- * Based on x, y, width, height
- * @param int $size - The size of the head
- * @return mixed - The image/png response of the head with the hat.
- */
- public function getHead($username, $size = 64) {
- $user = User::with('profile')->where('username', $username)->first();
- $source = null;
- if($user != null) {
- if($user->profile != null) {
- if($user->profile->skin != null) {
- $source = Image::make(public_path().$user->profile->skin);
- }
- }
- }
- if($source == null) {
- $source = Image::make(public_path().'/images/skins/astronaute.png');
- }
- $source2 = clone $source;
- $head = $source->crop(8,8,8,8);
- $hat = $source2->crop(8, 8, 40, 8);
- $image = $head->insert($hat);
- return $image->resize($size, $size)->response();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement