PHP:图像上传、缩略图、特定作物

发布于 2024-09-12 11:55:01 字数 515 浏览 2 评论 0原文

我创建了一个脚本,它实现 jCrop 以在显示图像之前裁剪图像。在 CMS 中,客户需要能够上传徽标,该徽标适合我们设计师确定的特定尺寸。

所以我想我正在寻找可以裁剪、调整大小和保存原始版本、特定大小的版本以及可能的其他缩略图大小的东西。

请问有人可以为此建议一个好的可靠且漂亮的防弹方法吗?到目前为止,我正在使用 GD 并传入 jCrop 坐标来创建图像。这给客户带来了混乱,因为他们上传巨大的图像和小图像,并且显然存在结果不正确的各种问题。

我认为一个类可能是一个想法,我发现了这个, http://pear.php.net /package/Image_Transform 虽然我还没有真正尝试过。

由于图像上传现在已成为网站的主流功能,那么人们处理这种潜在的用户输入黑洞的技巧是什么?

目前我验证上传 <100kb 和 bmp、gif、jpg 和 png

I've created a script which implements jCrop to crop an image before displaying it. In the CMS the client needs to be able to upload logos, which fit a specific size as determined by our designer.

So I think I'm looking for something which can crop, resize and save out the original, a specific sized version and potentially other thumbnail sizes.

Please can anyone suggest a good solid, and pretty bullet proof method for this? So far I am using GD and passing in jCrop coords to create an image. It's causing chaos for the client, as they are uploading huge images and small ones and obviously having all kinds of issues with the results not being correct.

I figured that a class might be an idea, and I found this, http://pear.php.net/package/Image_Transform although I haven't actually tried it out yet.

As image uploads are such a mainstream feature of sites now, what are peoples tips for handling this potential black hole of user input?

Presently I validate on upload for <100kb and bmp, gif, jpg and png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如梦初醒的夏天 2024-09-19 11:55:01

此链接有一个非常可靠的图像操作类: http://www.codewalkers.com/c/a/GUI-Code/PHP-Image-Manipulation-Class-10/

摘自上面链接的页面:

该 PHP 类可用于执行
几种类型的图像处理
操作。

它可以:

  • 重新缩放图像以适应给定的宽度或高度,保持(或不)
    原始宽高比
  • 水平或垂直翻转图像
  • 按给定角度旋转图像,用给定角度填充空白区域
    颜色
  • 所有操作都保持透明!
  • 该类对源和目标进行所有错误检查
    文件,这样你就不用担心
    那个

该类支持加载和保存
GIF、JPEG 和 PNG 格式的图像
格式。

代码有很好的文档记录并且
有一个很好的文档并且
帮助您入门的示例

There is a pretty solid image manip class at this link: http://www.codewalkers.com/c/a/GUI-Code/PHP-Image-Manipulation-Class-10/

Excerpt from the page linked above:

This PHP class can be used to perform
several types of image manipulation
operations.

It can:

  • Rescale images to fit in a given width or height keeping (or not) the
    original aspect ratio
  • Flip images horizontally or vertically
  • Rotate images by a given angle, filling the empty spaces with a given
    color
  • All operations preserve transparency!
  • The class does all the error checking for the source and target
    file so you don't need to worry about
    that

The class supports loading and saving
images in the GIF, JPEG and PNG
formats.

The code is very well documented and
there is a good documentation and
example to get you started

茶花眉 2024-09-19 11:55:01

设法使用 PEAR 类获得足够可靠的解决方案! :D

Managed to get a solid enough solutions using the PEAR class! :D

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文