|
|
|
|
|
by noir_lord
3232 days ago
|
|
I did both and used a .htaccess rule to look for a sharded filepath based on the hash of the image requested and parameters in the url. 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. RewriteCond %{QUERY_STRING} ^presets=([a-zA-Z0-9_]+)?$
RewriteRule ^files/(.*)/(.*)/(.*)/(.*) files/$1/$2/$3/%1_$4? [L,QSA]
RewriteCond %{QUERY_STRING} ^options=[\[|\{]?([0-9]*x[0-9]*)[\]|\}]?$
RewriteRule ^files/(.*)/(.*)/(.*)/(.*) files/$1/$2/$3/%1_$4? [L,QSA]
|
|
Still pretty dangerous stuff i.e. ?size=10000x2000000