public function preview(Request $request, $mcid_id) { $headers = array('Cache-Control' => 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma' => 'no-cache', 'Expires' => 'Fri, 01 Jan 1990 00:00:00 GMT', 'Content-Type' => 'image/png'); $mcid = MCID::where('mcid', $mcid_id)->first(); $size = 600; if ($mcid != null && !$mcid->genuine && $mcid->skin != null) { $file = $this->manager->fileDetails($mcid->skin->url); $fileImage = File::get(public_path() . config('site.uploads.webpath') . $file['fullPath']); $im = imagecreatefromstring($fileImage); } else { $skin = $this->get_skin($mcid_id); $im = imagecreatefromstring($skin); } $g = 4; $p = $size / 100 * 5; $s = floor(($size - $p * 2) / (48 + $g * 3)); $p = floor(($size - $s * (48 + $g * 3)) / 2); $h = $s * 32 + $p * 2; $av = imagecreatetruecolor($size, $h); imagesavealpha($av, true); imagefill($av, 0, 0, imagecolorallocatealpha($av, 0, 0, 0, 127)); if (imagesy($im) > 32) { // 1.8+ Skin if (imagecolorat($im, 54, 20) >> 24 & 0x7f == 127) { // Alex Style Skin (3px Arm Width) // Front imagecopyresized($av, $im, $p + $s * 4, $p, 8, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8, 20, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p + $s * 1, $p + $s * 8, 44, 20, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * 12, $p + $s * 8, 36, 52, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8 + $s * 12, 4, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 8, $p + $s * 8 + $s * 12, 20, 52, $s * 4, $s * 12, 4, 12); // Right imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 0, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8, 40, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8 + $s * 12, 0, 20, $s * 4, $s * 12, 4, 12); // Back imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 24, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8, 32, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 25, $p + $s * 8, 43, 52, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 36, $p + $s * 8, 51, 20, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8 + $s * 12, 28, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 32, $p + $s * 8 + $s * 12, 12, 20, $s * 4, $s * 12, 4, 12); // Left imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 16, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8, 39, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8 + $s * 12, 24, 52, $s * 4, $s * 12, 4, 12); // Black Hat Issue imagecolortransparent($im, imagecolorat($im, 63, 0)); // Face Accessories imagecopyresized($av, $im, $p + $s * 4, $p, 40, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 32, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 56, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 48, 8, $s * 8, $s * 8, 8, 8); // Body Accessories imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8, 20, 36, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8, 32, 36, $s * 8, $s * 12, 8, 12); // Arm Accessores imagecopyresized($av, $im, $p + $s * 1, $p + $s * 8, 44, 36, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * 12, $p + $s * 8, 52, 52, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 25, $p + $s * 8, 59, 52, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 36, $p + $s * 8, 51, 36, $s * 3, $s * 12, 3, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8, 40, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8, 55, 52, $s * 4, $s * 12, 4, 12); // Leg Accessores imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8 + $s * 12, 4, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 8, $p + $s * 8 + $s * 12, 4, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8 + $s * 12, 0, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8 + $s * 12, 12, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 32, $p + $s * 8 + $s * 12, 12, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8 + $s * 12, 8, 52, $s * 4, $s * 12, 4, 12); } else { // Steve Style Skin (4px Arm Width) // Front imagecopyresized($av, $im, $p + $s * 4, $p, 8, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8, 20, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p, $p + $s * 8, 44, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 12, $p + $s * 8, 36, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8 + $s * 12, 4, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 8, $p + $s * 8 + $s * 12, 20, 52, $s * 4, $s * 12, 4, 12); // Right imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 0, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8, 40, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8 + $s * 12, 0, 20, $s * 4, $s * 12, 4, 12); // Back imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 24, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8, 32, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 24, $p + $s * 8, 44, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 36, $p + $s * 8, 52, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8 + $s * 12, 28, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 32, $p + $s * 8 + $s * 12, 12, 20, $s * 4, $s * 12, 4, 12); // Left imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 16, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8, 40, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8 + $s * 12, 24, 52, $s * 4, $s * 12, 4, 12); // Black Hat Issue imagecolortransparent($im, imagecolorat($im, 63, 0)); // Face Accessories imagecopyresized($av, $im, $p + $s * 4, $p, 40, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 32, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 56, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 48, 8, $s * 8, $s * 8, 8, 8); // Body Accessories imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8, 20, 36, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8, 32, 36, $s * 8, $s * 12, 8, 12); // Arm Accessores imagecopyresized($av, $im, $p, $p + $s * 8, 44, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 12, $p + $s * 8, 52, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 24, $p + $s * 8, 60, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 36, $p + $s * 8, 52, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8, 40, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8, 56, 52, $s * 4, $s * 12, 4, 12); // Leg Accessores imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8 + $s * 12, 4, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 8, $p + $s * 8 + $s * 12, 4, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8 + $s * 12, 0, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8 + $s * 12, 12, 52, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 32, $p + $s * 8 + $s * 12, 12, 36, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 42, $p + $s * 8 + $s * 12, 8, 52, $s * 4, $s * 12, 4, 12); } } else { $mi = imagecreatetruecolor(64, 32); imagecopyresampled($mi, $im, 0, 0, 64 - 1, 0, 64, 32, -64, 32); imagesavealpha($mi, true); imagefill($mi, 0, 0, imagecolorallocatealpha($mi, 0, 0, 0, 127)); // Front imagecopyresized($av, $im, $p + $s * 4, $p, 8, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8, 20, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $im, $p, $p + $s * 8, 44, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $mi, $p + $s * 12, $p + $s * 8, 16, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * 4, $p + $s * 8 + $s * 12, 4, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $mi, $p + $s * 8, $p + $s * 8 + $s * 12, 56, 20, $s * 4, $s * 12, 4, 12); // Right imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 0, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8, 40, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g + $s * 18, $p + $s * 8 + $s * 12, 0, 20, $s * 4, $s * 12, 4, 12); // Back imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 24, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p + $s * 8, 32, 20, $s * 8, $s * 12, 8, 12); imagecopyresized($av, $mi, $p + $s * $g * 2 + $s * 24, $p + $s * 8, 8, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 36, $p + $s * 8, 52, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $mi, $p + $s * $g * 2 + $s * 28, $p + $s * 8 + $s * 12, 48, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 32, $p + $s * 8 + $s * 12, 12, 20, $s * 4, $s * 12, 4, 12); // Left imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 16, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $mi, $p + $s * $g * 3 + $s * 42, $p + $s * 8, 20, 20, $s * 4, $s * 12, 4, 12); imagecopyresized($av, $mi, $p + $s * $g * 3 + $s * 42, $p + $s * 8 + $s * 12, 60, 20, $s * 4, $s * 12, 4, 12); // Black Hat Issue imagecolortransparent($im, imagecolorat($im, 63, 0)); // Accessories imagecopyresized($av, $im, $p + $s * 4, $p, 40, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g + $s * 16, $p, 32, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 2 + $s * 28, $p, 56, 8, $s * 8, $s * 8, 8, 8); imagecopyresized($av, $im, $p + $s * $g * 3 + $s * 40, $p, 48, 8, $s * 8, $s * 8, 8, 8); imagedestroy($mi); } // start buffering ob_start(); imagepng($av); imagedestroy($im); imagedestroy($av); $contents = ob_get_contents(); ob_end_clean(); return Response::make($contents, 200, $headers); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $mcid = MCID::findOrFail($id); $mcid->delete(); return redirect('/myid')->withSuccess("'{$mcid->mcid}' 已删除."); }