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

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

问题描述

我正在考虑开发自己的基于PHP的图库来存储大量的图片,可能有数万个。



在数据库中,我会指向但是这里有个问题:我知道把它们全部放在服务器的同一个目录下是不切实际的,因为这会降低对爬虫的访问速度,所以,你将如何存储所有这些文件?某些基于jpeg / png名称的树?



什么规则来分割图像,你会推荐我吗?

(这将重点放在cheapo dot com中使用,所以不要与服务器混合在一起)

解决方案

我们过去也有类似的问题。并找到一个很好的解决方案:


  • 给每个图像一个唯一的guid。
  • 创建一个数据库记录每个图像包含名称,位置,guid和子图像的可能位置(缩略图,缩小尺寸等)。
  • 使用guid的第一个(一个或两个)字符来确定顶层文件夹。

  • 如果文件夹文件太多,请重新分割。更新引用,然后准备就绪。

  • 如果文件数量和访问量过高,则可以将文件夹分散到不同的文件服务器上。



我们已经体会到,使用guid,你会得到一个差不多一致的划分。它可以帮助我们生成一个唯一的ID:


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

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?

(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:

  • Give each image an unique guid.
  • Create a database record for each image containing the name, location, guid and possible location of sub images (thumbnails, reducedsize, etc.).
  • Use the first (one or two) characters of the guid to determine the toplevel folder.
  • If the folders have too much files, split again. Update the references and you are ready to go.
  • If the number of files and the accesses are too high, you can spread folders over different file servers.

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

Links which might help to generate a unique ID:

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

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