PHP动态调整大小和水印图像或创建多个版本? [英] PHP resize and watermarking images on the fly or create multiple versions?

查看:193
本文介绍了PHP动态调整大小和水印图像或创建多个版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有500多张图片的集合,这些图片已经重新调整为最大800px x 533px,需要根据特定类别中的数字显示各种尺寸的缩略图,因此截面宽度比如650px填充在2/3/4列的照片中。这些图像计划在许多不同的域上使用,每个域都有一个单独的水印。

I have a collection of 500+ images which have been re-sized to a maximum of 800px x 533px with a need to display thumbnails of these in a variety of sizes depending on the number in a particular category, so a section width of say 650px is filled in either 2/3/4 columns of photos. These images will are planned to bed used on a number of different domains each with a seperate watermark.

因此我写了一个脚本,根据某些参数重新调整图像大小(宽度/高度/宽高比)然后在运行中添加水印。我之所以这样做,是因为我希望节省服务器空间并尽可能保持动态显示,这样可以让水印缩略图和完整照片在不同的域上以不同的尺寸显示。

Therefore i wrote a script which re-sizes images based on certain parameters (width / height / aspect) and then adds a watermark on the fly. I did this because i wanted to save server space and be as dynamic as possible to display which will allow the both the watermarked thumbnail and full photos to be displayed at different sizes on a number of domains.

我的问题是:


  1. 我做了正确的事吗?使用即时水印方法?

  1. Have i done the right thing in terms of using the on-the-fly watermarking approach?

最好是以较小尺寸(300px x 200px)保存未加水印的照片副本并参考缩略图的那些?

Would i better off saving a copy of the unwatermarked photos in lesser dimensions (300px x 200px) and reference those for the thumbnail?

我是否应该为每张照片(也可能是缩略图)创建一个带有指定徽标的水印,并将其保存到个别域名文件夹?即使这意味着大量复制

Should i create a separate copy of each photo (and maybe thumbnail as well) already watermarker with the specified logo and save it to the individual domain folder? Even though this would mean mass duplication

非常感谢您的建议

推荐答案

你使用Image Magick吗?

Do you use Image Magick?

你有理由想要动态地做这个以及你为什么不这样做T。两种方法都是有效的。以下是优点和缺点:

There are reasons why you would want to do it dynamically and why you wouldn't. Both approaches are valid. Here are pros and cons:


  • 如果缓存图像,性能会更好。服务器空间 - 您认为这是一个问题 - 现在很便宜,不应该成为一个因素。另一方面,延迟会导致糟糕的用户体验。

  • 您的脚本可能无权执行您编写的图像处理脚本,如果您动态执行此脚本,则更依赖服务器。

  • 如果您决定更改缩略图的大小,则在动态方案中,您不需要重新生成所有缩略图,因为您不存储缩略图。

  • 水印:选择为要保护的图像添加水印。如果缩略图用于快速查看大文件(敏感资产),则不要为缩略图添加水印。

  • performance is better if you cache the images. Server space - which you see as a concern - is cheap these days and shouldn't be a factor. Latency on the other hand creates a poor user experience
  • Your scripts may not have the right to execute the image processing script you wrote and you depend on the server more if you do it dynamically.
  • If you decide to change the size of your thumbnails, in a dynamic scenario, you won't need to regenerate all the thumbnails since you don't store them.
  • watermarking: choose to watermark the images you want to protect. If thumbnails are used for quick viewing of a large file (the "sensitive" asset) then don't watermark your thumbnails.

这些只是一般规则。没有什么是一成不变的。

These are just general rules. Nothing set in stone.

在我自己的服务器上(我使用wordpress),在图片上传时生成缩略图。当访客点击我的页面时,这给了我更好的观看表现。但是,如果我决定重新设计我的网站并更改缩略图格式,我必须重新生成所有图片。

On my own server (where I use wordpress), thumbnails are generated at picture upload time. That gives me better viewing performances when visitors hit my page. BUT, if I decide to redesign my website and change the thumbnail format, I have to regenerate all the pictures.

这篇关于PHP动态调整大小和水印图像或创建多个版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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