PHP / JS - 动态创建缩略图或存储为文件 [英] PHP/JS - Create thumbnails on the fly or store as files

查看:108
本文介绍了PHP / JS - 动态创建缩略图或存储为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于托管网络应用程序的图像:



对于我存储的图像,使用PHP(或其他)动态创建缩略图是否可行,或者我应该保存一个或多个不同大小的缩略图到磁盘并加载它们?



任何帮助都表示赞赏。

解决方案

将缩略图保存到磁盘。图像处理需要大量资源,并且根据图像的大小,可能会超出php的默认允许内存限制。如果你有自己的服务器只运行你的应用程序,但它仍然需要大量的CPU功率和内存来调整图像大小,这不是一个问题。如果您正在考虑动态创建缩略图,则无需进行太多更改 - 在第一次请求时,从源文件创建缩略图,将其保存到磁盘,并在后续请求时将其从磁盘上读取。 / p>

For an image hosting web application:

For my stored images, is it feasible to create thumbnails on the fly using PHP (or whatever), or should I save 1 or more different sized thumbnails to disk and just load those?

Any help is appreciated.

解决方案

Save thumbnails to disk. Image processing takes a lot of resources and, depending on the size of the image, might exceed the default allowed memory limit for php. It is less of a concern if you have your own server with only your application running but it still takes a lot of cpu power and memory to resize images. If you're considering creating thumbnails on the fly anyway, you don't have to change much - upon the first request, create the thumbnail from the source file, save it to disk and upon subsequent requests just read it off the disk.

这篇关于PHP / JS - 动态创建缩略图或存储为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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