gif动态图gif出处_我喜欢GIF的怪异事物

gif动态图gif出处

I was recently reminded that I never wrote down all the weird things I learned about the GIF file format when implementing GIF decoding/playback at work last year. (I was reminded of this because I wrote a line in a corporate blog post draft that started with “If there’s one thing I love more than debugging rendering bugs, it’s reading specs about internet technologies,” and someone thought surely I was being sarcastic. I was not!) Without further ado, some strange things about GIFs (hard G because language evolves):

最近,我想起了我去年在工作中实施GIF解码/播放时从未写下过关于GIF文件格式的所有奇怪知识。 (我之所以被提醒,是因为我在公司博客文章草稿中写了一行,开头是“如果我除调试渲染错误外还爱上一件事,那就是在阅读有关互联网技术的规范,”有人认为我在讽刺。我不是!)事不宜迟,关于GIF的一些奇怪的事情(由于语言不断发展,所以用了硬G):

GIF中使用的压缩算法早在一天前就获得专利保护, (The compression algorithm used in GIFs was, way back in the day, under patent,)

and in the 90s, some kerfuffles ensued about this, resulting in someone inventing PNG. PNG used to be PING, which stood for “Ping Is Not GIF.”

在90年代,随之而来的是一些混混,导致有人发明了PNG。 PNG以前是PING,代表“ Ping不是GIF”。

GIF规范提供了对多张图像进行编码的功能,但没人能将其编码(The GIF spec provides for encoding multiple images, but no one ever codified what this meant.)

The most common usage of this is, of course, encoding multiple images to yield an animating image. But you could also use it to fit lots of colors into one image (since each image maxes out at 256 colors)! [See here.]

当然,最常见的用法是对多个图像进行编码以生成动画图像。 但是您也可以使用它在一张图像中放入很多颜色(因为每个图像最多可以容纳256色)! [ 见这里。 ]

后来的扩展(Netscape应用程序块)引入了“循环计数”的概念,以指示动画图像应循环多少次。 (A later extension (the Netscape Application Block) introduced the concept of “loop count,” to indicate how many times the animating image should loop.)

If you read this and think “loop count=1 loops once,” you would not be alone, and you’d be wrong:

如果您阅读此书并认为“ loop count=1循环一次”,您将不会孤单,而且您会错:

|| loop count         || GIF plays N times      ||
||--------------------||------------------------||
|| unset || 1 ||
|| 0 || infinite ||
|| 1 || 2 ||
|| 2 || 3 ||

A value of 0 causes the GIF to loop infinitely; otherwise, browsers choose to interpret this value as “play the GIF once, then play n=loop more times” (an alternative interpretation might have been something like “play the GIF n times,” but then there are two different ways to play the GIF once, which is a bit weird).

值为0会使GIF无限循环。 否则,浏览器选择来解释这个值作为“玩GIF一次,然后打n=loop多次”(另一种解释可能是类似“打GIF n次,”但当时有两种不同的方式玩GIF一次,这有点奇怪)。

GIF帧具有一个指示帧延迟的字段(即,在继续下一帧之前显示此帧的时间)。 (GIF frames have a field to indicate frame delay (i.e. how long to show this frame before moving on to the next one).)

But (in the interest of saving space), delays are encoded in hundredths of a second, not milliseconds, so 100 indicates one full second, which is a little strange.

但是(为了节省空间),延迟以百分之一秒而不是毫秒为单位进行编码,因此100表示一整秒,这有点奇怪。

It gets weirder: in the old days of the internet, a bunch of newfangled advertisers tried to make really annoying ad images by encoding super fast frames to flash wildly at people. Browser vendors decided this was not cool (and would kill browser performance, at that time), so at some point someone decided not to show frames with delays of <11 milliseconds, and to correct those frames by setting those delays to 100 milliseconds, and now this is what all GIF renderers do. So a frame encoded with delay=2 will render 5x faster than a frame encoded with delay=1 or delay=0. (See: [old Chromium bug with a Star Trek test case], [Webkit patch], [some Chromium code]). Here, then, is a GIF with delays encoded to 1 (10 milliseconds):

它变得越来越奇怪:在互联网的旧时代,一群新奇的广告客户试图通过编码超快帧以向人们疯狂闪烁来制作令人讨厌的广告图像。 浏览器供应商认为这并不酷(并会降低浏览器的性能),因此在某些时候,某人决定不显示延迟小于11毫秒的帧,并通过将这些延迟设置为100毫秒来纠正这些帧,并且现在,这就是所有GIF渲染器所做的。 因此,使用delay=2编码的帧将比使用delay=1delay=0编码的帧渲染速度快5倍。 (请参阅:[ 带有Star Trek测试用例的旧Chromium错误 ],[ Webkit补丁 ]和[ 一些Chromium代码 ])。 那么,这里是一个延迟编码为1 (10毫秒)的GIF:

vs. the same GIF with delays of 2 (20 milliseconds):

与同一个GIF相比,延迟为2 (20毫秒):

Very fast animation of raccoon sweeping.

GIF具有纯文本扩展名, (GIF has a plain text extension,)

where you can encode plain text that is meant to be rendered on top of the GIF. In other words, rather than rasterizing text on top of a GIF, you can just hardcode the text itself into the binary code, along with its intended position data and colors. If this doesn’t sound bananas to you, I must tell you: this is an absolutely bananas way to design an image format spec. (Browsers don’t actually render this block; you can check it out when you get to BOB_89A, below.)

您可以在其中编码要在GIF顶部呈现的纯文本。 换句话说,您可以仅将文本本身连同预期的位置数据和颜色一起硬编码为二进制代码 ,而不是光栅化GIF顶部的文本 。 如果这对您来说听起来不像香蕉,那我必须告诉您:这是设计图像格式规格的绝对香蕉方式。 (浏览器实际上并未渲染此块;您可以在进入下面的BOB_89A时检出该块。)

GIF也有评论扩展名, (GIF has a comment extension as well,)

where you can encode plain text comments not meant to be rendered on top of the GIF. Which means you can bloat the size of your GIF by encoding a secret message that people can only see if they know to decode and inspect your GIF.

您可以在其中编码纯文本注释,而不是要在GIF顶部呈现的注释。 这意味着您可以通过编码一条秘密消息来膨胀GIF的大小,而秘密消息只有在人们知道要解码和检查您的GIF时才能看到。

您可以使用一个用户输入标志来表明这一点, (There’s a user input flag that you can use to indicate that,)

instead of autoplaying the next frame after n hundredths of a second delay, we should wait until the user clicks or presses any key to advance frames. So yes, if everyone still respected the GIF spec, you could absolutely use GIFs as full-fledged slideshows.

而不是在百分之一秒的延迟后自动播放下一帧,我们应该等到用户单击或按任意键以前进帧。 因此,是的,如果每个人仍然尊重GIF规范,那么您绝对可以将GIF用作完整的幻灯片。

Bob Berry, one of the creators of the file format, created a GIF to demonstrate all the new features in GIF89a (most of the good stuff — animation and transparency — came in ’89), and to teach people how to pronounce “GIF.” This is that GIF:

文件格式的创建者之一鲍勃·贝瑞(Bob Berry)创建了一个GIF,以演示GIF89a中的所有新功能(大多数好东西-动画和透明度-始于89年),并教人们如何发音“ GIF。 ” 这就是GIF:

Non-animating image of a man standing in front of rocks in Sedona.

As you can see, it doesn’t look like an exciting GIF, because browsers don’t render the plain text extension; you need a special GIF inspector/custom renderer to view it. Behold, in all of its glory, BOB_89A (if you expand “Comments” in the bottom right, you can read the comments Bob encoded into this GIF about his Arizona vacation).

如您所见,它看起来并不像一个激动人心的GIF,因为浏览器不会呈现纯文本扩展名。 您需要特殊的GIF检查器/自定义渲染器才能查看它。 看哪,在其所有荣耀中, 都是BOB_89A (如果您扩展右下角的 “评论”,则可以阅读Bob编码在此GIF中有关他的亚利桑那州度假的评论)。

There are a bunch more old-school GIFs that use all the weird features, but apparently a lot of old-school internet dudes were gross and pervy, so a few of these involve naked cartoon women, and I’m not going to link them here.

还有更多使用所有怪异功能的老式GIF,但是显然许多老式Internet帅哥都是粗俗的,所以其中一些涉及裸露的卡通女性,我不打算将它们链接起来这里。

Instead, my favorite GIF (my dog Thea reacting to men mansplaining things to me on video calls):

取而代之的是我最喜欢的GIF(我的狗Thea对男人在视频通话中向我施压的React):

Dog rolling her eyes

翻译自: https://medium.com/@lbudorick/weird-things-i-love-about-gifs-e2fed7ccce03

gif动态图gif出处

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值