diff --git a/.gitignore b/.gitignore index 2a52798..2983f55 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /public/hot /public/storage /storage/*.key +/storage/stub/*.webp /vendor .env .env.backup diff --git a/composer.json b/composer.json index ccefe54..e3126b1 100644 --- a/composer.json +++ b/composer.json @@ -7,12 +7,13 @@ "require": { "php": "^8.0.2", "guzzlehttp/guzzle": "^7.2", + "jcupitt/vips": "2.0.0", "jenssegers/agent": "^2.6", "jenssegers/mongodb": "^3.9", + "kosinix/grafika": "^2.0", "laravel/framework": "^9.19", "laravel/sanctum": "^2.14.1", - "laravel/tinker": "^2.7", - "jcupitt/vips" : "2.0.0" + "laravel/tinker": "^2.7" }, "require-dev": { "brianium/paratest": "^6.5", diff --git a/composer.lock b/composer.lock index 729296a..4104022 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "aa091ad8935a98954cd65fdb252e3ab7", + "content-hash": "5ccb92d0caa97ee80e3508d0b7941f1c", "packages": [ { "name": "brick/math", @@ -1230,6 +1230,51 @@ ], "time": "2022-06-29T19:04:13+00:00" }, + { + "name": "kosinix/grafika", + "version": "2.0.8", + "source": { + "type": "git", + "url": "https://github.com/kosinix/grafika.git", + "reference": "211f61fc334b8b36616b23e8af7c5727971d96ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kosinix/grafika/zipball/211f61fc334b8b36616b23e8af7c5727971d96ee", + "reference": "211f61fc334b8b36616b23e8af7c5727971d96ee", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Grafika\\": "src/Grafika" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT", + "GPL-2.0+" + ], + "authors": [ + { + "name": "Nico Amarilla", + "homepage": "https://www.kosinix.com" + } + ], + "description": "An image manipulation library for PHP.", + "homepage": "http://kosinix.github.io/grafika", + "keywords": [ + "grafika" + ], + "support": { + "issues": "https://github.com/kosinix/grafika/issues", + "source": "https://github.com/kosinix/grafika/tree/develop" + }, + "time": "2017-06-20T03:13:49+00:00" + }, { "name": "laravel/framework", "version": "v9.21.6", diff --git a/public/.webp b/public/.webp new file mode 100644 index 0000000..14f3da0 Binary files /dev/null and b/public/.webp differ diff --git a/public/00.png b/public/00.png new file mode 100644 index 0000000..409766d Binary files /dev/null and b/public/00.png differ diff --git a/public/fuck.jpg b/public/fuck.jpg new file mode 100644 index 0000000..89bb551 Binary files /dev/null and b/public/fuck.jpg differ diff --git a/public/fuck.png b/public/fuck.png new file mode 100644 index 0000000..168766e Binary files /dev/null and b/public/fuck.png differ diff --git a/public/fuck.webp b/public/fuck.webp new file mode 100644 index 0000000..3be71e8 Binary files /dev/null and b/public/fuck.webp differ diff --git a/routes/web.php b/routes/web.php index e4a55a9..9ffa04a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,6 +5,7 @@ use App\Image\ImageProcessor; use App\Image\Processor; use App\Models\Collection; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Cookie; use Illuminate\Support\Facades\Route; use Jcupitt\Vips\Config; use Jcupitt\Vips\Extend; @@ -21,105 +22,275 @@ use Jcupitt\Vips\Utils; | contains the "web" middleware group. Now create something great! | */ -Route::get('/fuck',function(Request $request,ImageProcessor $imageProcessor) -{ - $image = Image::thumbnail(storage_path('stub') . '/image.png', getimagesize(storage_path('stub') . '/image.png')[1]); - $image->writeToFile(public_path(). '/fuck.jpg',['Q'=> 100]); - // $imageProcessor->process(public_path('image.png'),public_path('image-modified.webp')); - - // return response()->file(storage_path('stub') . '/image.png'); - return response()->file(public_path(). '/fuck.jpg'); -}); -Route::get('/', function (Request $request) { - - Collection::find(1)->getExts(); - - if (!isset($request->w) && !isset($request->h)) { - $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0]); - } - - if ($request->r) { - $rArray = explode(':', $request->r); - - if (isset($request->w) && !isset($request->h)) { - $request->h = $request->w * $rArray[1]; - $request->w = $request->w * $rArray[0]; - } - - - if (!isset($request->w) && isset($request->h)) { - $request->h = $request->h * $rArray[1]; - $request->w = $request->h * $rArray[0]; - } - if (!isset($request->w) && !isset($request->h)) { - $request->h = getimagesize('../public/image.png')[0] * $rArray[1]; - $request->w = getimagesize('../public/image.png')[0] * $rArray[0]; - } - } - - if (isset($request->w) && !isset($request->h)) { - $image = Image::thumbnail('../public/image.png', $request->w, ['height' => getimagesize('../public/image.png')[1]]); - } - - if (!isset($request->w) && isset($request->h)) { - $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0], ['height' => $request->h]); - } - - if (isset($request->w) && isset($request->h) && !($request->canv == true)) { - $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h, 'crop' => 'centre']); - } - - if (isset($request->w) && isset($request->h) && $request->canv == true) { - $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h]); - $widthH = ($request->h - $image->height) / 2; - $widthW = ($request->w - $image->width) / 2; - $image = $image->embed( - $widthW, - $widthH, - $request->w, - $request->h, - ['extend' => 'background','background'=>1024] - ); - } - - if (isset($request->brightness) || isset($request->saturation) || isset($request->hue)) { - $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); - } - - if ($request->rotation) { - $image = $image->rotate($request->rotation); - } - - if ($request->flip == "h") { - $image = $image->fliphor(); - } - - if ($request->flip == "v") { - $image = $image->flipver(); - } - - if ($request->flip == "hv") { - $image = $image->fliphor(); - $image = $image->flipver(); - } - - - $image->writeToFile(storage_path('image-modified.webp'), [ - 'Q' => isset($request->q) ? $request->q : 100 - ]); - - return response()->file(public_path("image-modified.webp" . $request->ext)); -}); - - - -Route::get('/upload',function(){ -return view('welcome'); -}); - -Route::post('/fuck',function(Request $request) -{ - $request->all(); - $storedImage = $request->file->storeAs('/addifsfsfsffuck', app()->uuid . '.' . 'webp', 'local'); - -}); + + +// Route::get('test1', function (Request $request) { +// // $image = Image::newFromFile(storage_path('stub') . '/00.png'); +// // $image1 = Image::newFromFile(storage_path('stub') . '/02.png'); +// // $image3 = $image->bandjoin($image1); +// // // Image::join +// // $image3->writeToFile(public_path() . '/fuck.webp'); +// // return response()->file(public_path() . '/fuck.webp'); + + + +// $arrayofimage = [ +// '00.webp', +// '01.webp', +// '02.webp', +// '03.webp', +// '04.webp', +// '05.webp', +// '06.webp', +// '07.webp', +// '08.webp', +// '09.webp', +// '10.webp', +// '11.webp', +// '13.webp', +// '14.webp', +// '16.webp', +// '17.webp', +// '19.webp', +// ]; + +// // [ +// // /var/www/html/storage/stub/00.webp +// // /var/www/html/storage/stub/01.webp +// // /var/www/html/storage/stub/02.webp +// // /var/www/html/storage/stub/03.webp +// // /var/www/html/storage/stub/04.webp +// // /var/www/html/storage/stub/05.webp +// // /var/www/html/storage/stub/06.webp +// // /var/www/html/storage/stub/07.webp +// // /var/www/html/storage/stub/08.webp +// // /var/www/html/storage/stub/09.webp +// // /var/www/html/storage/stub/10.webp +// // /var/www/html/storage/stub/11.webp +// // /var/www/html/storage/stub/13.webp +// // /var/www/html/storage/stub/14.webp +// // /var/www/html/storage/stub/16.webp +// // /var/www/html/storage/stub/17.webp +// // /var/www/html/storage/stub/19.webp +// // ] + +// // $i = null; +// // $theimage = null; +// // foreach ($arrayofimage as $key => $image) { +// // $defalt = Image::newFromFile(storage_path('stub') . '/00'.$i.'.png', ['access' => 'sequential']); +// // $watermark = Image::newFromFile(storage_path('stub') . '/'. $image); + +// // // if (!$watermark->hasAlpha() || $watermark->bands != 4) { +// // // echo("watermark image is not RGBA\n"); +// // // echo($key); +// // // exit(1); +// // // } + +// // $defalt = $defalt->composite2($watermark, 'over'); +// // $i++; +// // $defalt->writeToFile(storage_path('stub') . '/00'.$i.'.png',['Q' => 100]); + +// // } +// // $defalt = Image::newFromFile(storage_path('stub') . '/00'.$i.'.png', ['access' => 'sequential']); +// // $defalt->writeToFile(storage_path('stub') . '/00'.$i.'.webp',['Q' => 100]); + + + +// // return response()->file(storage_path('stub') . '/00'.$i.'.webp'); + + +// // $back = Vips\Image::arrayjoin([ +// // Vips\Image::newFromFile($files[0])->bandjoin(255), +// // Vips\Image::newFromFile($files[1]), 10, 'shim' +// // ]); +// // define('IMAGE', microtime()); +// // $arrayImage = []; +// // $back = Image::thumbnail_buffer(file_get_contents(storage_path('stub/' . $arrayofimage[0])),2000); + +// // foreach ($arrayofimage as $i => $file) { +// // array_push($arrayImage, Image::newFromFile(storage_path('stub/' . $file))); +// // } +// // $back = $back->composite($arrayImage, 'over'); + +// // $dddd = $back->writeToBuffer(storage_path('fuck.webp')); + + +// $back = Image::thumbnail_buffer(file_get_contents(storage_path('stub/' . $arrayofimage[0])),2000); + +// // $dddd = $back->writeToBuffer(storage_path('fuck.webp')); +// $arrya = []; +// foreach ($arrayofimage as $key => $value) { +// array_push($arrya ,Image::newFromFile(storage_path('stub/' . $value))); +// } +// $ffi = new \FFI; + +// $ffi->composite($arrya,storage_path('00000.webp'),'over'); + +// // $image2 = Image::newFromFile(storage_path('stub/' . $arrayofimage[0])); + + +// // header("Content-Type: image/png"); +// // echo $image2->writeToBuffer('.webp'); +// // // echo $dddd; +// // // return resp onse()->file(storage_path('fuck.webp')); +// // Config::shutDown(); + + +// // }); + +// Route::get('test', function () { +// // $image = Image::newFromFile(storage_path('stub') . '/00.png'); +// // $image1 = Image::newFromFile(storage_path('stub') . '/02.png'); +// // $image3 = $image->bandjoin($image1); +// // // Image::join +// // $image3->writeToFile(public_path() . '/fuck.webp'); +// // return response()->file(public_path() . '/fuck.webp'); + + + +// $arrayofimage = [ +// '00.png', +// '01.png', +// '02.png', +// '03.png', +// '04.png', +// '05.png', +// '06.png', +// '07.png', +// '08.png', +// '09.png', +// '10.png', +// '11.png', +// '13.png', +// '14.png', +// '16.png', +// '17.png', +// '19.png', +// ]; + +// $i = null; +// // dd(storage_path('stub') . '/00'.$i.'.png'); +// foreach ($arrayofimage as $key => $image) { +// $defalt = Image::newFromFile(storage_path('stub') . '/00' . $i . '.png', ['access' => 'sequential']); +// $watermark = Image::newFromFile(storage_path('stub') . '/' . $image); + +// // if (!$watermark->hasAlpha() || $watermark->bands != 4) { +// // echo("watermark image is not RGBA\n"); +// // echo($key); +// // exit(1); +// // } + +// $defalt = $defalt->composite2($watermark, 'over'); +// $i++; +// $defalt->writeToFile(storage_path('stub') . '/00' . $i . '.png', ['Q' => 100]); +// } +// $defalt = Image::newFromFile(storage_path('stub') . '/00' . $i . '.png', ['access' => 'sequential']); +// $defalt->writeToFile(storage_path('stub') . '/00' . $i . '.webp', ['Q' => 100]); + + + +// return response()->file(storage_path('stub') . '/00' . $i . '.webp'); +// }); + +// Route::get('/fuck',function(Request $request,ImageProcessor $imageProcessor) +// { +// $image = Image::thumbnail(storage_path('stub') . '/image.png', getimagesize(storage_path('stub') . '/image.png')[1]); +// $image->writeToFile(public_path(). '/fuck.jpg',['Q'=> 100]); +// // $imageProcessor->process(public_path('image.png'),public_path('image-modified.webp')); + +// // return response()->file(storage_path('stub') . '/image.png'); +// return response()->file(public_path(). '/fuck.jpg'); +// }); +// Route::get('/', function (Request $request) { + +// Collection::find(1)->getExts(); + +// if (!isset($request->w) && !isset($request->h)) { +// $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0]); +// } + +// if ($request->r) { +// $rArray = explode(':', $request->r); + +// if (isset($request->w) && !isset($request->h)) { +// $request->h = $request->w * $rArray[1]; +// $request->w = $request->w * $rArray[0]; +// } + + +// if (!isset($request->w) && isset($request->h)) { +// $request->h = $request->h * $rArray[1]; +// $request->w = $request->h * $rArray[0]; +// } +// if (!isset($request->w) && !isset($request->h)) { +// $request->h = getimagesize('../public/image.png')[0] * $rArray[1]; +// $request->w = getimagesize('../public/image.png')[0] * $rArray[0]; +// } +// } + +// if (isset($request->w) && !isset($request->h)) { +// $image = Image::thumbnail('../public/image.png', $request->w, ['height' => getimagesize('../public/image.png')[1]]); +// } + +// if (!isset($request->w) && isset($request->h)) { +// $image = Image::thumbnail('../public/image.png', getimagesize('../public/image.png')[0], ['height' => $request->h]); +// } + +// if (isset($request->w) && isset($request->h) && !($request->canv == true)) { +// $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h, 'crop' => 'centre']); +// } + +// if (isset($request->w) && isset($request->h) && $request->canv == true) { +// $image = Image::thumbnail('../public/image.png', $request->w, ['height' => $request->h]); +// $widthH = ($request->h - $image->height) / 2; +// $widthW = ($request->w - $image->width) / 2; +// $image = $image->embed( +// $widthW, +// $widthH, +// $request->w, +// $request->h, +// ['extend' => 'background','background'=>1024] +// ); +// } + +// if (isset($request->brightness) || isset($request->saturation) || isset($request->hue)) { +// $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); +// } + +// if ($request->rotation) { +// $image = $image->rotate($request->rotation); +// } + +// if ($request->flip == "h") { +// $image = $image->fliphor(); +// } + +// if ($request->flip == "v") { +// $image = $image->flipver(); +// } + +// if ($request->flip == "hv") { +// $image = $image->fliphor(); +// $image = $image->flipver(); +// } + + +// $image->writeToFile(storage_path('image-modified.webp'), [ +// 'Q' => isset($request->q) ? $request->q : 100 +// ]); + +// return response()->file(public_path("image-modified.webp" . $request->ext)); +// }); + + + +// Route::get('/upload',function(){ +// return view('welcome'); +// }); + +// Route::post('/fuck',function(Request $request) +// { +// $request->all(); +// $storedImage = $request->file->storeAs('/addifsfsfsffuck', app()->uuid . '.' . 'webp', 'local'); + +// }); diff --git a/storage/stub/00.webp b/storage/stub/00.webp new file mode 100644 index 0000000..0cb7eba Binary files /dev/null and b/storage/stub/00.webp differ diff --git a/storage/stub/000.png b/storage/stub/000.png new file mode 100644 index 0000000..e69de29 diff --git a/storage/stub/001.webp b/storage/stub/001.webp new file mode 100644 index 0000000..c667c6d Binary files /dev/null and b/storage/stub/001.webp differ diff --git a/storage/stub/0010.png b/storage/stub/0010.png new file mode 100644 index 0000000..111504f Binary files /dev/null and b/storage/stub/0010.png differ diff --git a/storage/stub/0011.png b/storage/stub/0011.png new file mode 100644 index 0000000..a483683 Binary files /dev/null and b/storage/stub/0011.png differ diff --git a/storage/stub/0012.png b/storage/stub/0012.png new file mode 100644 index 0000000..88e5bfc Binary files /dev/null and b/storage/stub/0012.png differ diff --git a/storage/stub/0013.png b/storage/stub/0013.png new file mode 100644 index 0000000..da307b5 Binary files /dev/null and b/storage/stub/0013.png differ diff --git a/storage/stub/0014.png b/storage/stub/0014.png new file mode 100644 index 0000000..6cfb859 Binary files /dev/null and b/storage/stub/0014.png differ diff --git a/storage/stub/0015.png b/storage/stub/0015.png new file mode 100644 index 0000000..61a622b Binary files /dev/null and b/storage/stub/0015.png differ diff --git a/storage/stub/0016.png b/storage/stub/0016.png new file mode 100644 index 0000000..c95e0ae Binary files /dev/null and b/storage/stub/0016.png differ diff --git a/storage/stub/0017.png b/storage/stub/0017.png new file mode 100644 index 0000000..cd9613c Binary files /dev/null and b/storage/stub/0017.png differ diff --git a/storage/stub/0017.webp b/storage/stub/0017.webp new file mode 100644 index 0000000..eb8f24e Binary files /dev/null and b/storage/stub/0017.webp differ diff --git a/storage/stub/002.png b/storage/stub/002.png new file mode 100644 index 0000000..43a7998 Binary files /dev/null and b/storage/stub/002.png differ diff --git a/storage/stub/003.webp b/storage/stub/003.webp new file mode 100644 index 0000000..1375e3b Binary files /dev/null and b/storage/stub/003.webp differ diff --git a/storage/stub/004.png b/storage/stub/004.png new file mode 100644 index 0000000..a21cf76 Binary files /dev/null and b/storage/stub/004.png differ diff --git a/storage/stub/005.png b/storage/stub/005.png new file mode 100644 index 0000000..fc7292e Binary files /dev/null and b/storage/stub/005.png differ diff --git a/storage/stub/006.png b/storage/stub/006.png new file mode 100644 index 0000000..d4121ae Binary files /dev/null and b/storage/stub/006.png differ diff --git a/storage/stub/007.png b/storage/stub/007.png new file mode 100644 index 0000000..6455931 Binary files /dev/null and b/storage/stub/007.png differ diff --git a/storage/stub/008.png b/storage/stub/008.png new file mode 100644 index 0000000..906a93c Binary files /dev/null and b/storage/stub/008.png differ diff --git a/storage/stub/009.png b/storage/stub/009.png new file mode 100644 index 0000000..9f78d6a Binary files /dev/null and b/storage/stub/009.png differ diff --git a/storage/stub/01.webp b/storage/stub/01.webp new file mode 100644 index 0000000..a73cd9d Binary files /dev/null and b/storage/stub/01.webp differ diff --git a/storage/stub/02.webp b/storage/stub/02.webp new file mode 100644 index 0000000..718604d Binary files /dev/null and b/storage/stub/02.webp differ diff --git a/storage/stub/03.webp b/storage/stub/03.webp new file mode 100644 index 0000000..dc996d5 Binary files /dev/null and b/storage/stub/03.webp differ diff --git a/storage/stub/04.webp b/storage/stub/04.webp new file mode 100644 index 0000000..01ad696 Binary files /dev/null and b/storage/stub/04.webp differ diff --git a/storage/stub/05.webp b/storage/stub/05.webp new file mode 100644 index 0000000..cb908f0 Binary files /dev/null and b/storage/stub/05.webp differ diff --git a/storage/stub/06.webp b/storage/stub/06.webp new file mode 100644 index 0000000..da8d47d Binary files /dev/null and b/storage/stub/06.webp differ diff --git a/storage/stub/07.webp b/storage/stub/07.webp new file mode 100644 index 0000000..709c627 Binary files /dev/null and b/storage/stub/07.webp differ diff --git a/storage/stub/08.webp b/storage/stub/08.webp new file mode 100644 index 0000000..c0d9731 Binary files /dev/null and b/storage/stub/08.webp differ diff --git a/storage/stub/09.webp b/storage/stub/09.webp new file mode 100644 index 0000000..56d5d59 Binary files /dev/null and b/storage/stub/09.webp differ diff --git a/storage/stub/10.webp b/storage/stub/10.webp new file mode 100644 index 0000000..890c12e Binary files /dev/null and b/storage/stub/10.webp differ diff --git a/storage/stub/100.png b/storage/stub/100.png new file mode 100644 index 0000000..8246387 Binary files /dev/null and b/storage/stub/100.png differ diff --git a/storage/stub/11.webp b/storage/stub/11.webp new file mode 100644 index 0000000..3d2ccfa Binary files /dev/null and b/storage/stub/11.webp differ diff --git a/storage/stub/13.webp b/storage/stub/13.webp new file mode 100644 index 0000000..709685f Binary files /dev/null and b/storage/stub/13.webp differ diff --git a/storage/stub/14.webp b/storage/stub/14.webp new file mode 100644 index 0000000..cecd24c Binary files /dev/null and b/storage/stub/14.webp differ diff --git a/storage/stub/16.webp b/storage/stub/16.webp new file mode 100644 index 0000000..4f0142e Binary files /dev/null and b/storage/stub/16.webp differ diff --git a/storage/stub/17.webp b/storage/stub/17.webp new file mode 100644 index 0000000..7df45c3 Binary files /dev/null and b/storage/stub/17.webp differ diff --git a/storage/stub/19.webp b/storage/stub/19.webp new file mode 100644 index 0000000..7e77c30 Binary files /dev/null and b/storage/stub/19.webp differ