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