使用 PHP 处理动画图像

发布于 2024-09-25 01:31:33 字数 100 浏览 0 评论 0原文

我已经编写了一个允许用户上传图像的 PHP 脚本,但我希望能够允许我的用户上传动画图像。我需要在当前代码中添加什么才能允许使用 PHP 生成动画图像?一个快速的代码示例会对我有很大帮助。

I already wrote a PHP script that allows users to upload images but I want to be able to allow my users to upload animated images. What do I need to add to my current code to allow animated images using PHP? A quick code example would help me out a lot.

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

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

发布评论

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

评论(2

赴月观长安 2024-10-02 01:31:33

我需要添加什么到我当前的
允许使用动画图像的代码
PHP?

没有什么。动画图像都是图像。


编辑:如果您使用 GD 调整图像大小,您将丢失动画,因为 GD 无法正确处理它。
如果您安装了 ImageMagick 插件,则应该使用它而不是GD:

$thumb = new Imagick('myimage.gif');

$thumb->resizeImage(320,240,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('mythumb.gif');

$thumb->destroy(); 

另请参阅:在不破坏动画的情况下调整动画 gif 文件的大小

What do I need to add to my current
code to allow animated images using
PHP?

Nothing. Animated images are images all the same.


EDIT: If you are resizing your images using GD, you'll lose the animation, since GD can't handle it correctly.
If you have the ImageMagick plugin installed, you should use it instead of GD:

$thumb = new Imagick('myimage.gif');

$thumb->resizeImage(320,240,Imagick::FILTER_LANCZOS,1);
$thumb->writeImage('mythumb.gif');

$thumb->destroy(); 

See also: Resize animated gif file without destroying animation

半衾梦 2024-10-02 01:31:33

如果您的脚本接受 gif 和 png,您应该已准备就绪。

If your script accepts gifs and pngs you should be all set.

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