在PHP中上传图像后,图像被剥离 [英] Having an image stripped of metadata upon upload in PHP

查看:186
本文介绍了在PHP中上传图像后,图像被剥离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近知道的一个网站把他们的频带从每月2.5TB升级到了3.5TB。

原因是他们最近超过了2.5倍的限制。他们抱怨说他们不知道如何降低带宽的使用。

我还没有看到他们考虑的一件事是JPEG和其他图像在网站上显示(这是一个图像大的网站)可以包含元数据。拍照的地方等等。

事实是,这个信息在这个网站上并不重要。它不会被使用,永远。但它仍然增加了带宽,因为它将每个图像的文件大小从几个字节增加到了几千字节。

在占用了2个以上的站点上,每月5TB,剥离数千张图片的元数据将有助于减少带宽使用量,至少每月几千兆字节,我认为,如果不是更多的话。

那么

有没有办法在PHP中做到这一点?而且,对于已有的文件,是否有人知道自动元数据移除器?我知道 JPEG& PNG Stripper ,但是这不是很好...可能是有用的初始清理,虽然... ...

解决方案

查看 Smush.it! 它将从图像中去除所有不可知的信息。他们有 API ,您可以使用它们来压缩图片。注意: 按设计,它 可能 改变你的文件类型。这是有意的。如果另一个文件类型可以以相同的质量显示相同的图像,使用更少的字节,它会给你一个新的文件。


A certain site I know recently upgraded their bandwith from 2,5 TB monthly to 3,5 TB.

Reason is they went over the 2,5 limit recently. They're complaining they don't know how to get down the bandwidth usage.

One thing I haven't seen them consider is the fact that JPEG and other images that are displayed on the site(and it is an image-heavy site) can contain metadata. Where the picture was taken and such.

Fact of the matter is, this information is of no importance whatsoever on that site. It's not gonna be used, ever. Yet it's still adding to the bandwidth, since it increases the filesize of every images from a few bytes to a few kilobytes.

On a site that uses up more then 2,5 TB per month, stripping the several thousands images of their metadata will help decrease the bandwidth usage at least by a few Gigabytes per month I think, if not more.

So is there a way to do this in PHP? And also, for the allready existing files, does anybody know a good automatic metadata remover? I know of JPEG & PNG Stripper, but that's not very good... Might be usefull for initial cleaning though...

解决方案

Check out Smush.it! It will strip all un-necs info from an image. They have an API you can use to crunch the images.

Note: By Design, it may change the filetype on you. This is on purpose. If another filetype can display the same image with the same quality, with less bytes it will give you a new file.

这篇关于在PHP中上传图像后,图像被剥离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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