G'day. Just playing around with listening to events provided by fof/upload. The goal is to modify an image into greyscale before it's uploaded and stored permanently.
How do i correctly reference the uploaded file for the Intervention image manager to play with it?
How do i override the uploaded image after modifying it?
Here's what i've got:
<?php
use FoF\Upload\Events\File\WillBeUploaded;
use Intervention\Image\Exception\NotReadableException;
use Intervention\Image\Image;
use Intervention\Image\ImageManager;
use Psr\Http\Message\UploadedFileInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class ModifyUploadedImage
{
public function __construct(ImageManager $imageManager)
{
$this->imageManager = $imageManager;
}
public function handle(WillBeUploaded $event)
{
$img = $this->imageManager->make($event->file->path)->greyscale();
return $img;
}
}```
```Error: `Intervention\Image\Exception\NotReadableException: Image source not readable in ````