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.
128 lines
4.0 KiB
128 lines
4.0 KiB
<?php
|
|
|
|
use App\Http\Controllers\FileController;
|
|
use App\Image\ImageProcessor;
|
|
use App\Image\Processor;
|
|
use App\Models\Collection;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Jcupitt\Vips\Config;
|
|
use Jcupitt\Vips\Extend;
|
|
use Jcupitt\Vips\Image;
|
|
use Jcupitt\Vips\Utils;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Web Routes
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Here is where you can register web routes for your application. These
|
|
| routes are loaded by the RouteServiceProvider within a group which
|
|
| contains the "web" middleware group. Now create something great!
|
|
|
|
|
*/
|
|
Route::get('/fuck.webp',function(Request $request,ImageProcessor $imageProcessor)
|
|
{
|
|
$option = [
|
|
'w' => $request->w,
|
|
'h' => $request->h,
|
|
'r' => $request->r,
|
|
'canv' => $request->canv,
|
|
];
|
|
$imageProcessor->process(public_path('image.png'),public_path('image-modified.webp'),$option);
|
|
|
|
return response()->file(public_path('image-modified.webp'));
|
|
});
|
|
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');
|
|
|
|
});
|