Home » Php » Image manipulation not updated in cache

Image manipulation not updated in cache

Posted by: admin June 30, 2018 Leave a comment

Questions:

On a page where users can rotate their uploaded picture, there is a button to rotate the picture. This is done using Intervention image, but the same result (and problem) has been achieved using PHP.

The problem is that the image rotation works, but the rotated image is not shown in the browser. This is probably due to cache, because when manually emptying the cache, the rotated picture is indeed shown in the browser.

public function rotate($picture_id) {

    // get picture location
    $path = Picture::where('id',$picture_id)->first()->location;

    // Rotate the picture
    $path_orig = storage_path('app/public/'.$path);
    $img_orig = Image::make($path_orig)
                ->rotate(-90)
                ->save($path_orig);

    // Rotate thumbnails etc
    ...

    return Redirect::back();
}
Answers: