Browse Source

test for modella project

pull/2/head
Mohammad Khazaee 2 years ago
parent
commit
47d395be84
  1. 1
      .gitignore
  2. 5
      composer.json
  3. 47
      composer.lock
  4. BIN
      public/.webp
  5. BIN
      public/00.png
  6. BIN
      public/fuck.jpg
  7. BIN
      public/fuck.png
  8. BIN
      public/fuck.webp
  9. 375
      routes/web.php
  10. BIN
      storage/stub/00.webp
  11. 0
      storage/stub/000.png
  12. BIN
      storage/stub/001.webp
  13. BIN
      storage/stub/0010.png
  14. BIN
      storage/stub/0011.png
  15. BIN
      storage/stub/0012.png
  16. BIN
      storage/stub/0013.png
  17. BIN
      storage/stub/0014.png
  18. BIN
      storage/stub/0015.png
  19. BIN
      storage/stub/0016.png
  20. BIN
      storage/stub/0017.png
  21. BIN
      storage/stub/0017.webp
  22. BIN
      storage/stub/002.png
  23. BIN
      storage/stub/003.webp
  24. BIN
      storage/stub/004.png
  25. BIN
      storage/stub/005.png
  26. BIN
      storage/stub/006.png
  27. BIN
      storage/stub/007.png
  28. BIN
      storage/stub/008.png
  29. BIN
      storage/stub/009.png
  30. BIN
      storage/stub/01.webp
  31. BIN
      storage/stub/02.webp
  32. BIN
      storage/stub/03.webp
  33. BIN
      storage/stub/04.webp
  34. BIN
      storage/stub/05.webp
  35. BIN
      storage/stub/06.webp
  36. BIN
      storage/stub/07.webp
  37. BIN
      storage/stub/08.webp
  38. BIN
      storage/stub/09.webp
  39. BIN
      storage/stub/10.webp
  40. BIN
      storage/stub/100.png
  41. BIN
      storage/stub/11.webp
  42. BIN
      storage/stub/13.webp
  43. BIN
      storage/stub/14.webp
  44. BIN
      storage/stub/16.webp
  45. BIN
      storage/stub/17.webp
  46. BIN
      storage/stub/19.webp

1
.gitignore

@ -3,6 +3,7 @@
/public/hot
/public/storage
/storage/*.key
/storage/stub/*.webp
/vendor
.env
.env.backup

5
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",

47
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",

BIN
public/.webp

Binary file not shown.

BIN
public/00.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 34 KiB

BIN
public/fuck.jpg

Binary file not shown.

After

Width: 600  |  Height: 1200  |  Size: 44 KiB

BIN
public/fuck.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 144 KiB

BIN
public/fuck.webp

Binary file not shown.

375
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');
// });

BIN
storage/stub/00.webp

Binary file not shown.

0
storage/stub/000.png

BIN
storage/stub/001.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 32 KiB

BIN
storage/stub/0010.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 614 KiB

BIN
storage/stub/0011.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 615 KiB

BIN
storage/stub/0012.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 616 KiB

BIN
storage/stub/0013.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 616 KiB

BIN
storage/stub/0014.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 618 KiB

BIN
storage/stub/0015.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 618 KiB

BIN
storage/stub/0016.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 618 KiB

BIN
storage/stub/0017.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 619 KiB

BIN
storage/stub/0017.webp

Binary file not shown.

BIN
storage/stub/002.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 155 KiB

BIN
storage/stub/003.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 328 KiB

BIN
storage/stub/004.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 577 KiB

BIN
storage/stub/005.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 597 KiB

BIN
storage/stub/006.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 598 KiB

BIN
storage/stub/007.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 600 KiB

BIN
storage/stub/008.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 615 KiB

BIN
storage/stub/009.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 614 KiB

BIN
storage/stub/01.webp

Binary file not shown.

BIN
storage/stub/02.webp

Binary file not shown.

BIN
storage/stub/03.webp

Binary file not shown.

BIN
storage/stub/04.webp

Binary file not shown.

BIN
storage/stub/05.webp

Binary file not shown.

BIN
storage/stub/06.webp

Binary file not shown.

BIN
storage/stub/07.webp

Binary file not shown.

BIN
storage/stub/08.webp

Binary file not shown.

BIN
storage/stub/09.webp

Binary file not shown.

BIN
storage/stub/10.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 9.9 KiB

BIN
storage/stub/100.png

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 642 B

BIN
storage/stub/11.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 12 KiB

BIN
storage/stub/13.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 11 KiB

BIN
storage/stub/14.webp

Binary file not shown.

BIN
storage/stub/16.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 9.8 KiB

BIN
storage/stub/17.webp

Binary file not shown.

After

Width: 1920  |  Height: 920  |  Size: 10 KiB

BIN
storage/stub/19.webp

Binary file not shown.
Loading…
Cancel
Save