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的位置。
imagemagick使用