|
|
|
|
|
by technimad
3232 days ago
|
|
I've created scripts like these as part of our home-brewed CMS system in the early 2000's. Nice and easy dos tool. Enumerate the width and height parameters and bring down the server fast. Better way to do it is to specify, or allow admins to specify, a set of named sizes and only allow these named sizes. You could also think about adding parameters to determine the crop, or force aspect ratio etc. (with the same risk of dos) |
|
So you could o a1jjajda.jpg?size=200x150 and it would check for the existence of a/l/jjajda/200x150.jpg and if it didn't exist it would create it from a/l/jjajda/original.jpg store it at the right place and serve it.
.htaccess file looks meant I didn't have to boot PHP to serve an image the second time (we where using laravel and even optimised it takes 30-40ms to come up) and in 95% of cases at all (particulary since I then wrote a shell script that trawled the paths, built a list of common sizes and named presets and requested them when the server was quiet).
It worked out pretty well actually and had the benefit of relying on extremely robust and well tested technology.
That was some hinky looking regexs though.