We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import SuperGif from 'libgif' var file = e.target.files[0]; console.log(file.type.indexOf('image/gif')); load_gif(file); function load_gif(gif_source) { var gifImg = document.getElementById('gifImg'); // gif库需要img标签配置下面两个属性 gifImg.setAttribute('rel:animated_src', URL.createObjectURL(gif_source)) gifImg.setAttribute('rel:auto_play', '0') // 新建gif实例 var rub = new SuperGif({ gif: gifImg } ); var running = false; rub.load(function(){ var img_list = []; var j = 0; console.log(rub.get_length()); for (var i=1; i <= rub.get_length(); i++) { // 遍历gif实例的每一帧 rub.move_to(i); var imgImage = new Image(); //canvas生成base64图片数据 imgImage.src = rub.get_canvas().toDataURL('image/jpeg',0.8); } }
import GIF from 'gif.js' var gif = new GIF({ workers: 2, quality: 10, workerScript: 'js/gif.worker.js' }); var j = 0; var canvas= document.createElement("canvas"); var ctx = tCanvas.getContext('2d'); for (var i=1; i <= len; i++) { var imgImage = new Image(); imgImage.src = img; imgImage.onload = function (e) { //Canvas绘制图片 canvas.width = width; canvas.height = height; console.log(width,height) //铺底色 ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.drawImage(imgImage, 0, 0, width, height); gif.addFrame(canvas,{copy:true,delay:50}); j++; //图片 if(j>=len) { gif.render() }; } } gif.on('finished', function(blob) { //生成图片链接 var url = URL.createObjectURL(blob); }
The text was updated successfully, but these errors were encountered:
hankliu62
No branches or pull requests
案例
分解GIF
图片合成
The text was updated successfully, but these errors were encountered: