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.

296 lines
10 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
  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\Cookie;
  8. use Illuminate\Support\Facades\Route;
  9. use Jcupitt\Vips\Config;
  10. use Jcupitt\Vips\Extend;
  11. use Jcupitt\Vips\Image;
  12. use Jcupitt\Vips\Utils;
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Web Routes
  16. |--------------------------------------------------------------------------
  17. |
  18. | Here is where you can register web routes for your application. These
  19. | routes are loaded by the RouteServiceProvider within a group which
  20. | contains the "web" middleware group. Now create something great!
  21. |
  22. */
  23. // Route::get('test1', function (Request $request) {
  24. // // $image = Image::newFromFile(storage_path('stub') . '/00.png');
  25. // // $image1 = Image::newFromFile(storage_path('stub') . '/02.png');
  26. // // $image3 = $image->bandjoin($image1);
  27. // // // Image::join
  28. // // $image3->writeToFile(public_path() . '/fuck.webp');
  29. // // return response()->file(public_path() . '/fuck.webp');
  30. // $arrayofimage = [
  31. // '00.webp',
  32. // '01.webp',
  33. // '02.webp',
  34. // '03.webp',
  35. // '04.webp',
  36. // '05.webp',
  37. // '06.webp',
  38. // '07.webp',
  39. // '08.webp',
  40. // '09.webp',
  41. // '10.webp',
  42. // '11.webp',
  43. // '13.webp',
  44. // '14.webp',
  45. // '16.webp',
  46. // '17.webp',
  47. // '19.webp',
  48. // ];
  49. // // [
  50. // // /var/www/html/storage/stub/00.webp
  51. // // /var/www/html/storage/stub/01.webp
  52. // // /var/www/html/storage/stub/02.webp
  53. // // /var/www/html/storage/stub/03.webp
  54. // // /var/www/html/storage/stub/04.webp
  55. // // /var/www/html/storage/stub/05.webp
  56. // // /var/www/html/storage/stub/06.webp
  57. // // /var/www/html/storage/stub/07.webp
  58. // // /var/www/html/storage/stub/08.webp
  59. // // /var/www/html/storage/stub/09.webp
  60. // // /var/www/html/storage/stub/10.webp
  61. // // /var/www/html/storage/stub/11.webp
  62. // // /var/www/html/storage/stub/13.webp
  63. // // /var/www/html/storage/stub/14.webp
  64. // // /var/www/html/storage/stub/16.webp
  65. // // /var/www/html/storage/stub/17.webp
  66. // // /var/www/html/storage/stub/19.webp
  67. // // ]
  68. // // $i = null;
  69. // // $theimage = null;
  70. // // foreach ($arrayofimage as $key => $image) {
  71. // // $defalt = Image::newFromFile(storage_path('stub') . '/00'.$i.'.png', ['access' => 'sequential']);
  72. // // $watermark = Image::newFromFile(storage_path('stub') . '/'. $image);
  73. // // // if (!$watermark->hasAlpha() || $watermark->bands != 4) {
  74. // // // echo("watermark image is not RGBA\n");
  75. // // // echo($key);
  76. // // // exit(1);
  77. // // // }
  78. // // $defalt = $defalt->composite2($watermark, 'over');
  79. // // $i++;
  80. // // $defalt->writeToFile(storage_path('stub') . '/00'.$i.'.png',['Q' => 100]);
  81. // // }
  82. // // $defalt = Image::newFromFile(storage_path('stub') . '/00'.$i.'.png', ['access' => 'sequential']);
  83. // // $defalt->writeToFile(storage_path('stub') . '/00'.$i.'.webp',['Q' => 100]);
  84. // // return response()->file(storage_path('stub') . '/00'.$i.'.webp');
  85. // // $back = Vips\Image::arrayjoin([
  86. // // Vips\Image::newFromFile($files[0])->bandjoin(255),
  87. // // Vips\Image::newFromFile($files[1]), 10, 'shim'
  88. // // ]);
  89. // // define('IMAGE', microtime());
  90. // // $arrayImage = [];
  91. // // $back = Image::thumbnail_buffer(file_get_contents(storage_path('stub/' . $arrayofimage[0])),2000);
  92. // // foreach ($arrayofimage as $i => $file) {
  93. // // array_push($arrayImage, Image::newFromFile(storage_path('stub/' . $file)));
  94. // // }
  95. // // $back = $back->composite($arrayImage, 'over');
  96. // // $dddd = $back->writeToBuffer(storage_path('fuck.webp'));
  97. // $back = Image::thumbnail_buffer(file_get_contents(storage_path('stub/' . $arrayofimage[0])),2000);
  98. // // $dddd = $back->writeToBuffer(storage_path('fuck.webp'));
  99. // $arrya = [];
  100. // foreach ($arrayofimage as $key => $value) {
  101. // array_push($arrya ,Image::newFromFile(storage_path('stub/' . $value)));
  102. // }
  103. // $ffi = new \FFI;
  104. // $ffi->composite($arrya,storage_path('00000.webp'),'over');
  105. // // $image2 = Image::newFromFile(storage_path('stub/' . $arrayofimage[0]));
  106. // // header("Content-Type: image/png");
  107. // // echo $image2->writeToBuffer('.webp');
  108. // // // echo $dddd;
  109. // // // return resp onse()->file(storage_path('fuck.webp'));
  110. // // Config::shutDown();
  111. // // });
  112. // Route::get('test', function () {
  113. // // $image = Image::newFromFile(storage_path('stub') . '/00.png');
  114. // // $image1 = Image::newFromFile(storage_path('stub') . '/02.png');
  115. // // $image3 = $image->bandjoin($image1);
  116. // // // Image::join
  117. // // $image3->writeToFile(public_path() . '/fuck.webp');
  118. // // return response()->file(public_path() . '/fuck.webp');
  119. // $arrayofimage = [
  120. // '00.png',
  121. // '01.png',
  122. // '02.png',
  123. // '03.png',
  124. // '04.png',
  125. // '05.png',
  126. // '06.png',
  127. // '07.png',
  128. // '08.png',
  129. // '09.png',
  130. // '10.png',
  131. // '11.png',
  132. // '13.png',
  133. // '14.png',
  134. // '16.png',
  135. // '17.png',
  136. // '19.png',
  137. // ];
  138. // $i = null;
  139. // // dd(storage_path('stub') . '/00'.$i.'.png');
  140. // foreach ($arrayofimage as $key => $image) {
  141. // $defalt = Image::newFromFile(storage_path('stub') . '/00' . $i . '.png', ['access' => 'sequential']);
  142. // $watermark = Image::newFromFile(storage_path('stub') . '/' . $image);
  143. // // if (!$watermark->hasAlpha() || $watermark->bands != 4) {
  144. // // echo("watermark image is not RGBA\n");
  145. // // echo($key);
  146. // // exit(1);
  147. // // }
  148. // $defalt = $defalt->composite2($watermark, 'over');
  149. // $i++;
  150. // $defalt->writeToFile(storage_path('stub') . '/00' . $i . '.png', ['Q' => 100]);
  151. // }
  152. // $defalt = Image::newFromFile(storage_path('stub') . '/00' . $i . '.png', ['access' => 'sequential']);
  153. // $defalt->writeToFile(storage_path('stub') . '/00' . $i . '.webp', ['Q' => 100]);
  154. // return response()->file(storage_path('stub') . '/00' . $i . '.webp');
  155. // });
  156. // Route::get('/fuck',function(Request $request,ImageProcessor $imageProcessor)
  157. // {
  158. // $image = Image::thumbnail(storage_path('stub') . '/image.png', getimagesize(storage_path('stub') . '/image.png')[1]);
  159. // $image->writeToFile(public_path(). '/fuck.jpg',['Q'=> 100]);
  160. // // $imageProcessor->process(public_path('image.png'),public_path('image-modified.webp'));
  161. // // return response()->file(storage_path('stub') . '/image.png');
  162. // return response()->file(public_path(). '/fuck.jpg');
  163. // });
  164. // Route::get('/', function (Request $request) {
  165. // Collection::find(1)->getExts();
  166. // if (!isset($request->w) && !isset($request->h)) {
  167. // $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0]);
  168. // }
  169. // if ($request->r) {
  170. // $rArray = explode(':', $request->r);
  171. // if (isset($request->w) && !isset($request->h)) {
  172. // $request->h = $request->w * $rArray[1];
  173. // $request->w = $request->w * $rArray[0];
  174. // }
  175. // if (!isset($request->w) && isset($request->h)) {
  176. // $request->h = $request->h * $rArray[1];
  177. // $request->w = $request->h * $rArray[0];
  178. // }
  179. // if (!isset($request->w) && !isset($request->h)) {
  180. // $request->h = getimagesize('../public/image.png')[0] * $rArray[1];
  181. // $request->w = getimagesize('../public/image.png')[0] * $rArray[0];
  182. // }
  183. // }
  184. // if (isset($request->w) && !isset($request->h)) {
  185. // $image = Image::thumbnail('../public/image.png', $request->w, ['height' => getimagesize('../public/image.png')[1]]);
  186. // }
  187. // if (!isset($request->w) && isset($request->h)) {
  188. // $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0], ['height' => $request->h]);
  189. // }
  190. // if (isset($request->w) && isset($request->h) && !($request->canv == true)) {
  191. // $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h, 'crop' => 'centre']);
  192. // }
  193. // if (isset($request->w) && isset($request->h) && $request->canv == true) {
  194. // $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h]);
  195. // $widthH = ($request->h - $image->height) / 2;
  196. // $widthW = ($request->w - $image->width) / 2;
  197. // $image = $image->embed(
  198. // $widthW,
  199. // $widthH,
  200. // $request->w,
  201. // $request->h,
  202. // ['extend' => 'background','background'=>1024]
  203. // );
  204. // }
  205. // if (isset($request->brightness) || isset($request->saturation) || isset($request->hue)) {
  206. // $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);
  207. // }
  208. // if ($request->rotation) {
  209. // $image = $image->rotate($request->rotation);
  210. // }
  211. // if ($request->flip == "h") {
  212. // $image = $image->fliphor();
  213. // }
  214. // if ($request->flip == "v") {
  215. // $image = $image->flipver();
  216. // }
  217. // if ($request->flip == "hv") {
  218. // $image = $image->fliphor();
  219. // $image = $image->flipver();
  220. // }
  221. // $image->writeToFile(storage_path('image-modified.webp'), [
  222. // 'Q' => isset($request->q) ? $request->q : 100
  223. // ]);
  224. // return response()->file(public_path("image-modified.webp" . $request->ext));
  225. // });
  226. // Route::get('/upload',function(){
  227. // return view('welcome');
  228. // });
  229. // Route::post('/fuck',function(Request $request)
  230. // {
  231. // $request->all();
  232. // $storedImage = $request->file->storeAs('/addifsfsfsffuck', app()->uuid . '.' . 'webp', 'local');
  233. // });