я использую в своем проекте пакет изображений Intervention-Image
чтобы добавить водяной знак к каждому загруженному изображению, я использую код, но у меня ошибка при хешировании
хэширование дает мне хэш watermark.png только каждый раз
Route::post('/upload_image',function (Request $request)
{
$real_path = Image::make($request->file('image')->getRealPath());
$img_for_hash = Image::make($real_path);
$img = Image::make($real_path);
// calculate md5 hash of encoded image
$hash = md5($img_for_hash->__toString());
// use hash as a name
$path = "images/{$hash }.jpg";
$watermark = Image::make(public_path('watermark.png'));
$img->insert($watermark, 'bottom-right', 10, 10);
// save it locally to ~/public/images/{$hash}.jpg
$img->save(public_path($path));
return $hash ;
})->name('upload_image');
просмотр
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Upload Image</title>
</head>
<body>
<form action="{{ route('upload_image') }}" method="post" enctype="multipart/form-data" >
@csrf
<input type="file" name="image">
<button type="submit"> upload </button>
</form>
</body>
</html>
любое решение использовать перезвонить или это, потому что водяной знак ?? я не знаю, почему этот код каждый раз дает мне один и тот же хэш.