快速调整PHP映像大小与存储调整大小的映像 [英] PHP image resize on the fly vs storing resized images

查看:66
本文介绍了快速调整PHP映像大小与存储调整大小的映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个图像共享站点,并且想知道使用PHP快速调整图像大小并存储调整大小的图像的利弊.

哪个更快?

哪个更可靠?

这两种方法在速度和性能上的差距有多大?

请注意,图像通过PHP脚本进行统计(例如视图)或允许进行热链接等方式的任何一种方式,因此,如果我选择存储调整大小的图像,则它不是图像的直接链接. /p>

对于您对此主题的评论或任何有用的链接,我们将不胜感激.

解决方案

这听起来像是过早的优化.您知道您的站点将拥有多少用户/您的服务器将具有多少计算量吗?选择最简单的(维护方式)选项,即即时调整大小,直到性能成为问题,然后从那里找出要做什么.

如果重新缩放后的图像可能会遭到重复击打,则可能需要对服务器进行某种形式的服务器端缓存,但这是一个主意,但我认为这种需求不会扩展到显式的预渲染.

I'm building a image sharing site and would like to know the pros and cons of resizing images on the fly with PHP and having the resized images stored.

Which is faster?

Which is more reliable?

How big is the gap between the two methods in speed and performance?

Please note that either way the images go through a PHP script for statistics like views or if hotlinking is allow etc... so is not like it will be a direct link for images if I opt to store the resize images.

I'll appreciated your comments or any helpful links on the subject.

解决方案

This sounds like premature optimisation. Do you know how many users your site will have/ how much computational grunt your server(s) will have? Go with the simplest (maintenance-wise) option, i.e. resize on the fly, until performance becomes an issue, then figure out from there what to do.

It might be an idea to implement some sort of server side caching of your rescaled images, if they're likely to be repeatedly hit, but I don't think this need extend as far as explicit pre-rendering.

这篇关于快速调整PHP映像大小与存储调整大小的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆