存储大量图像 [英] Storing a large number of images

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

问题描述

我正在考虑开发自己的基于 PHP 的图库,用于存储大量图片,可能数以万计.

I'm thinking about developing my own PHP based gallery for storing lots of pictures, maybe in the tens of thousands.

在数据库中,我将指向图像的 url,但问题是:我知道将所有这些都放在服务器中的同一目录中是不切实际的,因为这会降低对爬网的访问速度,因此,你将如何存储所有这些?某种基于 jpeg/png 名称的树?

At the database I'll point to the url of the image, but here's the problem: I know is impractical to have all of them sitting at the same directory in the server as it would slow access to a crawl, so, how would you store all of them? Some kind of tree based on the name of the jpeg/png?

你会推荐我什么规则来划分图像?

What rules to partition the images would you recommend me?

(它将专注于在cheapo dot coms中使用,因此不可能对服务器进行修改)

(It will focused for using in cheapo dot coms, so no mangling with the server is possible)

推荐答案

我们过去也遇到过类似的问题.并找到了一个不错的解决方案:

We had a similar problem in the past. And found a nice solution:

  • 给每张图片一个唯一的 guid.
  • 为每个图像创建一个数据库记录,其中包含子图像的名称、位置、guid 和可能的位置(缩略图、缩小尺寸等).
  • 使用 guid 的前一个(一个或两个)字符来确定顶级文件夹.
  • 如果文件夹中有太多文件,请再次拆分.更新参考资料,您就可以开始了.
  • 如果文件数量和访问次数过多,您可以将文件夹分散到不同的文件服务器上.

我们的经验是,使用 guid 会得到或多或少统一的划分.它的作用就像一个魅力.

We have experienced that using the guids, you get a more or less uniform division. And it worked like a charm.

可能有助于生成唯一 ID 的链接:

Links which might help to generate a unique ID:

这篇关于存储大量图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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