You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
4.1 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <?php
  2. use App\Http\Controllers\FileController;
  3. use App\Image\ImageProcessor;
  4. use App\Image\Processor;
  5. use App\Models\Collection;
  6. use Illuminate\Http\Request;
  7. use Illuminate\Support\Facades\Route;
  8. use Jcupitt\Vips\Config;
  9. use Jcupitt\Vips\Extend;
  10. use Jcupitt\Vips\Image;
  11. use Jcupitt\Vips\Utils;
  12. /*
  13. |--------------------------------------------------------------------------
  14. | Web Routes
  15. |--------------------------------------------------------------------------
  16. |
  17. | Here is where you can register web routes for your application. These
  18. | routes are loaded by the RouteServiceProvider within a group which
  19. | contains the "web" middleware group. Now create something great!
  20. |
  21. */
  22. Route::get('/fuck',function(Request $request,ImageProcessor $imageProcessor)
  23. {
  24. $image = Image::thumbnail(storage_path('stub') . '/image.png', getimagesize(storage_path('stub') . '/image.png')[1]);
  25. $image->writeToFile(public_path(). '/fuck.jpg',['Q'=> 100]);
  26. // $imageProcessor->process(public_path('image.png'),public_path('image-modified.webp'));
  27. // return response()->file(storage_path('stub') . '/image.png');
  28. return response()->file(public_path(). '/fuck.jpg');
  29. });
  30. Route::get('/', function (Request $request) {
  31. Collection::find(1)->getExts();
  32. if (!isset($request->w) && !isset($request->h)) {
  33. $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0]);
  34. }
  35. if ($request->r) {
  36. $rArray = explode(':', $request->r);
  37. if (isset($request->w) && !isset($request->h)) {
  38. $request->h = $request->w * $rArray[1];
  39. $request->w = $request->w * $rArray[0];
  40. }
  41. if (!isset($request->w) && isset($request->h)) {
  42. $request->h = $request->h * $rArray[1];
  43. $request->w = $request->h * $rArray[0];
  44. }
  45. if (!isset($request->w) && !isset($request->h)) {
  46. $request->h = getimagesize('../public/image.png')[0] * $rArray[1];
  47. $request->w = getimagesize('../public/image.png')[0] * $rArray[0];
  48. }
  49. }
  50. if (isset($request->w) && !isset($request->h)) {
  51. $image = Image::thumbnail('../public/image.png', $request->w, ['height' => getimagesize('../public/image.png')[1]]);
  52. }
  53. if (!isset($request->w) && isset($request->h)) {
  54. $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0], ['height' => $request->h]);
  55. }
  56. if (isset($request->w) && isset($request->h) && !($request->canv == true)) {
  57. $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h, 'crop' => 'centre']);
  58. }
  59. if (isset($request->w) && isset($request->h) && $request->canv == true) {
  60. $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h]);
  61. $widthH = ($request->h - $image->height) / 2;
  62. $widthW = ($request->w - $image->width) / 2;
  63. $image = $image->embed(
  64. $widthW,
  65. $widthH,
  66. $request->w,
  67. $request->h,
  68. ['extend' => 'background','background'=>1024]
  69. );
  70. }
  71. if (isset($request->brightness) || isset($request->saturation) || isset($request->hue)) {
  72. $image = Processor::brightness($image, isset($request->brightness) ? $request->brightness : 1.0, isset($request->saturation) ? $request->saturation : 1.0, isset($request->hue) ? $request->hue : 0.0);
  73. }
  74. if ($request->rotation) {
  75. $image = $image->rotate($request->rotation);
  76. }
  77. if ($request->flip == "h") {
  78. $image = $image->fliphor();
  79. }
  80. if ($request->flip == "v") {
  81. $image = $image->flipver();
  82. }
  83. if ($request->flip == "hv") {
  84. $image = $image->fliphor();
  85. $image = $image->flipver();
  86. }
  87. $image->writeToFile(storage_path('image-modified.webp'), [
  88. 'Q' => isset($request->q) ? $request->q : 100
  89. ]);
  90. return response()->file(public_path("image-modified.webp" . $request->ext));
  91. });
  92. Route::get('/upload',function(){
  93. return view('welcome');
  94. });
  95. Route::post('/fuck',function(Request $request)
  96. {
  97. $request->all();
  98. $storedImage = $request->file->storeAs('/addifsfsfsffuck', app()->uuid . '.' . 'webp', 'local');
  99. });