html导出图片-可以将canvas图片导入各种格式图片的jQuery插件

2023-09-05 0 9,507 百度已收录

ExportCanvas是一个非常实用的jQuery插件html导出图片html导出图片,可以将canvas图像导入到各种格式的图片中。 canvas图片导入插件利用浏览器的下载功能将canvas中的图片下载到本地,可以指定各类图片格式:PNG、JPEG、GIF、BMP、WEBP。

用法

在页面中引入jQuery和export-canvas.js文件。


            
              

导入图片

按照下面的格式编译js代码,canvas中的图片就可以通过浏览器下载到本地了。

// The ID of canvas element you want to export
var exampleCanvasID = "myCanvas";
var exportCanvas = new ExportCanvas();
// Load the config & language javascript files
exportCanvas.loadConfigFile("core/config/config.js");
exportCanvas.loadLanguageFile("core/language/de.js");
// Set the MIMEType
exportCanvas.setMimeType("image/jpeg");
// Set the quality level when exporting (0.1 - 1.0)
exportCanvas.setExportQuality(1.0);
// The export method    
exportCanvas.export(exampleCanvasID, function() {
              
  // callback function
              
}, function(getLastReport) {
              
  // callback function fired after the download has failed
              
});
// Export canvas without callbacks
exportCanvas.export(exampleCanvasID);
// Export canvas on document ready
window.onload = function() {
  exportCanvas.export(exampleCanvasID);
              

该插件提供两种语言:英语和俄语。 可以通过.loadLanguageFile()进行切换。 setMimeType()方法用于设置导入图像的类型。 setExportQuality()是导入图像的质量,值在0.1-1.0之间。 最后可以使用导出的方式导入图片。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悟空资源网 html html导出图片-可以将canvas图片导入各种格式图片的jQuery插件 https://www.wkzy.net/game/195208.html

常见问题

相关文章

官方客服团队

为您解决烦忧 - 24小时在线 专业服务