I have become a big fan of on-the-fly image resizing and cropping with throwaway caching. It allows me to simultaneously reduce the overall media footprint and maintain flexibility for changing UI requirements.
I've had a long look at URL based manipulation using intervention/image or league/glide.
To me, they both have some flaws when we are talking about high traffic scenarios dealing with thousands of requests in a short period time (the creators admit as much).
The is because for obvious reasons, PHP has to get involved to test whether a cached version is available, vs just returning an image directly from the web server, or better yet, a CDN. Although I haven't put this to the test, I really can't see performance being great when every single image request for all time must go via Laravel.
Intervention supports caching via Laravel Cache, I may be wrong but I can't see a viable way of scaling up when dealing with hundreds of GBs of images.
Glide is a little better on the scaling side in that it supports any Filesystem adapter, but in practice this is actually worse if the server first must first ask Rackspace/Amazon whether a cached file exists then piping the result back, and the roundtrip involved in that.
Glide is effectively putting a hard requirement on using Laravel on every request because of the URL parameter method it uses, whereas Intervention supports a nifty template method without url params.
I think the ideal implementation looks something like this:
- cached images have to be saved in a format without url params
- the app needs to be able to determine if a cached image exists, whether it be using a cache driver or the db
- assuming a cached version exists, the app can then return a CDN or local URL to that file which circumvents the need to call PHP
Has anyone crossed this bridge with either Intervention or Glide? Did you loosely follow this approach or do something different?
Is there a better package out there that solves all this?