lundi 24 août 2015

Serving images without extension using Intervention image library and laravel

I have the uploads folder, which stores user uploaded images. Users can crop and resize these images, also add effects and do loads of things. At the same time, they need to have access to the original files, unaltered in any way.

There are two options I came up with.

First one is to store the original image separately and every single time they alter an image, save these new images in their (users') folder somewhere.

This means that each user will have many physical images basically.

Second option I thought about doing was - store a single image (that original image) and then save all the manipulations as templates (in Intervention's terms - filters).

For example, the UI captures width, height, x, y of a cropped image and also captures all the filters the user has used - grayscale, blur and so on, and these properties are then saved in DB using a unique name, for example: DjxUakWjrKElqdjO, along with the original image URL, for example: public/images/someimage.jpg

When displaying an image, I would let PHP generate the manipulated / altered images on the fly.

I would also use Intervention / Imagecache library to cache these generated images.

So on the front-end, when displaying on-the-fly-manipulated images, they would sit under the URL that looks something like:

/image/DjxUakWjrKElqdjO

Which essentially refers to the template / filter name in the database.

The reason why I like this option is that first of all it saves space. Yes, the cached images will take space as well but they will expire be deleted, right?

Also, user would be able to edit these templates / filters.

So my question is, would this cause any issues in the long run?

And also, is it OK to serve images without extensions (just like the above example)?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NPfa2o
via IFTTT

Aucun commentaire:

Enregistrer un commentaire