imagemagick使用_使用ImageMagick获取动画GIF的第一帧

imagemagick使用

ImageMagick has been the industry standard for image manipulation for as long as I can remember.  Hell, I remember using the ImageMagick extension when I first learned PHP over a decade ago.  Anyways, I've noticed recently that many sites which host animated GIFs will have a static image initially and will swap the static image for the animated upon scroll or click/tap.  The strategy makes sense because animated GIFs can be taxing on the CPU and costly to download so I needed to know the best way to do it...and ImageMagick again showed its face to me.

据我所知,ImageMagick一直是图像处理的行业标准。 地狱,我记得十年前第一次学习PHP时使用ImageMagick扩展。 无论如何,我最近注意到,许多托管GIF动画的网站最初都会具有静态图像,并会在滚动或单击/点击时将静态图像交换为动画。 该策略之所以有意义,是因为动画GIF可能会占用大量CPU资源,并且下载成本很高,因此我需要了解实现此效果的最佳方法...然后ImageMagick再次向我展示了它的面目。

Creating the image is actually a simple command line execution, assuming you have ImageMagick installed:

假设您已安装ImageMagick,则创建映像实际上是一个简单的命令行执行:


convert 'monkey.gif[0]' monkey-frame.gif


That command takes the first frame of the animated gif and generates its own image.  At first it was weird to see the [o] but I'm glad ImageMagick recognizes it as a frame position.  So with that second image you can add a click listener to swap out the src to start the gif, and you can revert to static upon another click.

该命令获取动画gif的第一帧并生成自己的图像。 刚开始看到[o]很奇怪,但是我很高兴ImageMagick将其识别为框架位置。 因此,使用第二个图像,您可以添加一个单击侦听器以换出src以启动gif,并且可以在再次单击时恢复为静态。

I love that utilities like ImageMagick exist -- they're a pillar of their functionality and make all of our lives easier.  Utilizing this "double image" strategy may also speed up your sites!

我喜欢像ImageMagick这样的实用程序存在-它们是功能的Struts,使我们的生活更加轻松。 利用这种“双重形象”策略也可以加快您的网站速度!

Depending on your path to the install, you'll need to adjust where you pull ImageMagick from.

根据您的安装路径,您需要调整从中拉取ImageMagick的位置。

翻译自: https://davidwalsh.name/first-frame-animated-gif

imagemagick使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值