1 Star 1 Fork 0

renzhezhilu / gifsicle-wasm-browser

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

En | 中文

Gifsicle Wasm Browser

在浏览器中运行 Gifsicle,对 GIFs 进行压缩、裁剪、操作帧、调整尺寸等等操作。

功能

  • 完整还原 Gifsicle 1.92 的功能
  • 支持多个 GIFs 的输入和输出
  • 支持多条命令
  • 小巧(Gzip≈150KB)
  • 无依赖

Demo

基础用法

更多命令请查阅Gifsicle手册

压缩 操作帧 裁剪 尺寸 其他
轻量
普通
极限






选中最后2帧
选中前3帧和后3帧
删除前20帧
将3-6帧替换成其他GIF
倒带
将2个GIF交替
导出所有帧



根据左上角和右下角
根据左上角和高宽
旋转后裁剪
翻转后裁剪
裁剪掉多余透明




修改宽度为100px
缩小50%
修改纵横比








循环次数
读取信息
合并图片
播放速度




完整示例

gifsicleTool.js 通过将多条命令组合起来,完成比较实用的功能。

快速开始

npm 安装

import in vue

$ npm i gifsicle-wasm-browser --save
import gifsicle from "gifsicle-wasm-browser";

gifsicle.run({
  input: [{
      file: "./cat.gif",
      name: "1.gif",
  }],
  command: [`
    -e -U 
    --resize 100x_ 
    1.gif 
    -o /out/out.gif`],
})
.then(outGifFiles => {
  console.log(outGifFiles);
  // [File,File,File ...]
});

cdn

cdn demo

<script type="module">
  import gifsicle from 'https://unpkg.com/gifsicle-wasm-browser/dist/gifsical.min.js'
  // or
  import gifsicle from 'https://cdn.jsdelivr.net/npm/gifsicle-wasm-browser/dist/gifsicle.min.js'
      ...
  })
</script>

Api

gifsicle.run(input=[], command=[])

input

  • Array: 输入的 Gif 文件
  • file

    • String: GIF的网络url
    • FileBlobArrayBuffer: 通过<input type="file">获取的本地文件
  • name

    • String: 将在 command 中使用的文件名

command

  • Array: 执行的命令

folder

  • Array: (可选的) 将在 command 中使用的文件夹名称

isStrict

  • Boolean: (可选的) command 发生错误或警告时立即结束
  • default:false

返回

GIF File数组

注意事项

  • input 中的 name 可以自定义,但是不能重复。
  • command 的最后一条必须包含-o /out/**.gif,
  • 默认可用的目录有 //out/tem,当 command 执行完成后会将/out的所有文件导出
  • command 将按顺序逐个执行, 需要对多个 GIFs 同时处理时请使用多个 gifsicle.run()按顺序执行 | 同时执行

作者

gifsicle-wasm-browser 是 @renzhezhiluwasm-codecs/gifsiclegifsicle 基础上开发。

To do

  • 单个 Gif 输入和输出
  • 多个 Gif 输入输出(完整版)
  • Npm
  • 多核处理(SharedArrayBuffer)
MIT License Copyright (c) 2021 renzhezhilu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

在浏览器中使用worker和WebAssembly运行Gifsicle,对Gif图片进行压缩,旋转,裁剪等操作 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/renzhezhilu/gifsicle-wasm-browser.git
git@gitee.com:renzhezhilu/gifsicle-wasm-browser.git
renzhezhilu
gifsicle-wasm-browser
gifsicle-wasm-browser
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891