<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Image on Tech Explorer</title><link>https://byronhe.com/categories/image/</link><description>C++、Linux、算法、数据结构与密码学的学习笔记与实践记录。</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><copyright>© 2026 BH</copyright><lastBuildDate>Mon, 26 Aug 2019 00:00:00 +0000</lastBuildDate><atom:link href="https://byronhe.com/categories/image/index.xml" rel="self" type="application/rss+xml"/><item><title>gif 缩放算法及相关资料</title><link>https://byronhe.com/post/2019/08/26/gif-resize-algorithm-resources/</link><pubDate>Mon, 26 Aug 2019 00:00:00 +0000</pubDate><guid>https://byronhe.com/post/2019/08/26/gif-resize-algorithm-resources/</guid><description>&lt;p&gt;&lt;a href="http://giflib.sourceforge.net/whatsinagif/index.html" target="_blank" rel="noreferrer"&gt;http://giflib.sourceforge.net/whatsinagif/index.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html" target="_blank" rel="noreferrer"&gt;http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html&lt;/a&gt;&#10;&lt;figure&gt;&#10; &lt;img class="my-0 rounded-md" loading="lazy" decoding="async" alt="" src="https://byronhe.com/images/gif_file_stream.gif" width="700" height="220"&gt;&lt;/figure&gt;&#10;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;a href="https://gif.ski/" target="_blank" rel="noreferrer"&gt;https://gif.ski/&lt;/a&gt;&#10;gifski 可以从视频生成高质量的 gif&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;浓缩的才是精华：浅析 GIF 格式图片的存储和压缩&#10;&lt;a href="https://cloud.tencent.com/developer/article/1004763" target="_blank" rel="noreferrer"&gt;https://cloud.tencent.com/developer/article/1004763&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;用av1视频替代 gif&#10;&lt;a href="https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video" target="_blank" rel="noreferrer"&gt;https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&amp;ldquo;Replace animated GIFs with video for faster page loads&amp;rdquo; : &lt;a href="https://web.dev/replace-gifs-with-videos/" target="_blank" rel="noreferrer"&gt;https://web.dev/replace-gifs-with-videos/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://web.dev/efficient-animated-content/" target="_blank" rel="noreferrer"&gt;https://web.dev/efficient-animated-content/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html" target="_blank" rel="noreferrer"&gt;http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;每帧一个调色板，就可以消除噪点。&#10;&lt;a href="https://medium.com/@Peter_UXer/small-sized-and-beautiful-gifs-with-ffmpeg-25c5082ed733" target="_blank" rel="noreferrer"&gt;https://medium.com/@Peter_UXer/small-sized-and-beautiful-gifs-with-ffmpeg-25c5082ed733&lt;/a&gt;&lt;/p&gt;</description><content:encoded>&lt;p&gt;&lt;a href="http://giflib.sourceforge.net/whatsinagif/index.html" target="_blank" rel="noreferrer"&gt;http://giflib.sourceforge.net/whatsinagif/index.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html" target="_blank" rel="noreferrer"&gt;http://giflib.sourceforge.net/whatsinagif/bits_and_bytes.html&lt;/a&gt;&#10;&lt;figure&gt;&#10; &lt;img class="my-0 rounded-md" loading="lazy" decoding="async" alt="" src="https://byronhe.com/images/gif_file_stream.gif" width="700" height="220"&gt;&lt;/figure&gt;&#10;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;a href="https://gif.ski/" target="_blank" rel="noreferrer"&gt;https://gif.ski/&lt;/a&gt;&#10;gifski 可以从视频生成高质量的 gif&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;浓缩的才是精华：浅析 GIF 格式图片的存储和压缩&#10;&lt;a href="https://cloud.tencent.com/developer/article/1004763" target="_blank" rel="noreferrer"&gt;https://cloud.tencent.com/developer/article/1004763&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;用av1视频替代 gif&#10;&lt;a href="https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video" target="_blank" rel="noreferrer"&gt;https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&amp;ldquo;Replace animated GIFs with video for faster page loads&amp;rdquo; : &lt;a href="https://web.dev/replace-gifs-with-videos/" target="_blank" rel="noreferrer"&gt;https://web.dev/replace-gifs-with-videos/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://web.dev/efficient-animated-content/" target="_blank" rel="noreferrer"&gt;https://web.dev/efficient-animated-content/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html" target="_blank" rel="noreferrer"&gt;http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;每帧一个调色板，就可以消除噪点。&#10;&lt;a href="https://medium.com/@Peter_UXer/small-sized-and-beautiful-gifs-with-ffmpeg-25c5082ed733" target="_blank" rel="noreferrer"&gt;https://medium.com/@Peter_UXer/small-sized-and-beautiful-gifs-with-ffmpeg-25c5082ed733&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;if 本身的算法比较古老压缩率低下，和 h264/h265/vp9 之类的编码算法是没法比的，比如用 h264/VP9 mp4/webm 视频代替 gif，大概可以压缩到原大小的 1/5 ~ 1/10&lt;/p&gt;&#10;&lt;p&gt;&amp;ldquo;Replace animated GIFs with video for faster page loads&amp;rdquo; : &lt;a href="https://web.dev/replace-gifs-with-videos/" target="_blank" rel="noreferrer"&gt;https://web.dev/replace-gifs-with-videos/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;《页面加载性能之video替换GIF》: &lt;a href="https://www.bilibili.com/read/cv6905954" target="_blank" rel="noreferrer"&gt;https://www.bilibili.com/read/cv6905954&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&amp;ldquo;用av1视频替代 gif &amp;quot; &lt;a href="https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video" target="_blank" rel="noreferrer"&gt;https://www.singhkays.com/blog/its-time-replace-gifs-with-av1-video&lt;/a&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;gifsicle&#10;&lt;a href="https://www.lcdf.org/gifsicle/" target="_blank" rel="noreferrer"&gt;https://www.lcdf.org/gifsicle/&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;查看 gif 文件结构:&lt;/p&gt;&#10;&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gifsicle -I input.gif&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gcc -pthread -DHAVE_CONFIG_H quantize.c merge.c optimize.c gifunopt.c gifwrite.c gifsicle.c clp.c support.c giffunc.c xform.c gifread.c fmalloc.c -I ../include/ -I ../ -lm&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# gcc -pthread -DHAVE_CONFIG_H quantize.c merge.c optimize.c gifunopt.c gifwrite.c gifsicle.c clp.c support.c giffunc.c xform.c gifread.c fmalloc.c -I ../include/ -I ../ -lm&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;function scale(){&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; input=$1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; time ffmpeg -hide_banner -y -i $input -b 568k -r 20 -vf &amp;#39;fps=20,scale=w=162:h=-1:flags=lanczos,palettegen &amp;#39; ${input}.palettegen.png&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; time ffmpeg -hide_banner -y -i $input -i ${input}.palettegen.png -r 15 -lavfi &amp;#39;fps=15,scale=w=162:h=-1:flags=lanczos[x];[x][1:v]paletteuse&amp;#39; $2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; rm -f ${input}.palettegen.png&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;time ffmpeg -threads 1 -hide_banner -y -i 987.gif -vf &amp;#39;scale=w=162:h=-1:flags=lanczos &amp;#39; 987.gif.162.lanczos.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;scale 987.gif 987.gif.162.palettegen.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;gifsicle 987.gif --resize 162x_ -o 987.gif.162.gifsicle.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#ffmpeg -y -i 987.gif -filter_complex &amp;#34;[0:v] fps=15,scale=w=720:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1&amp;#34; avengers3.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#ffmpeg -y -i 987.gif -filter_complex &amp;#34;[0:v]scale=w=162:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1&amp;#34; 987.gif.162.ffmpeg_single.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ffmpeg -y -i 987.gif -filter_complex &amp;#34;[0:v]scale=w=162:h=-1:flags=lanczos,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1&amp;#34; 987.gif.162.ffmpeg_single.gif&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;time convert 987.gif -resize 162x1620 987.162.gif&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&#10;</content:encoded></item></channel></rss>