开发者

Create many images on the server or do resizing in the browser?

at the moment I'm designing a new gallery and I have quite a lot of different image sizes for different ways pf presentation in the frontend. And now I'm wondering if I should create every size on the server or just create a few and then use browser resizing and HTLM/CSS "croping".

So it's many images on the server, a lot of space on the disk and also a lot of requests from the client against fewer requests, fewer space and resizing/cropping with the browser.

I tend to think the second solution is more advanced and modern, but also more complicated?

Thanks for开发者_如何学JAVA any advice!


It's really a trade-off as you've said yourself. Performance is increasingly important though, and even affects page ranking, which is a good reason to keep various sizes on the server, i.e. only send thumbnails when that's all the user needs to see.

If you wanted to go to the programming effort, you could use a library like ImageMagick to generate smaller images from large ones. This way, you only need to store the large images on the server. The downside being programming effort and extra server load; since space is cheap, probably not worth it unless you need to serve many different variants.


You could create a handler to serve up your images. When a request is made for an image in a size you don't yet have stored in the file system on your server, you could do the resize, save the file and send it to the client.

That way you only have the files that are needed on the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜