当前位置: 首页 > news >正文

网站开发备案费用爱站seo工具包

网站开发备案费用,爱站seo工具包,哪个网站可以专门做产品推广,网页设计教程清华大学出版社文章目录 1、canvas实现图片压缩2、其他 1、canvas实现图片压缩 canvas 实现图片压缩,主要是使用 canvas 的drawImage 方法 具体思路 拿到用户上传的文件转成base64创建一个 Image,主要是获取到这个图片的宽度和高度创建一个 2D 的画布,画布…

文章目录

    • 1、canvas实现图片压缩
    • 2、其他

1、canvas实现图片压缩

canvas 实现图片压缩,主要是使用 canvasdrawImage 方法

具体思路

  1. 拿到用户上传的文件
  2. 转成base64
  3. 创建一个 Image,主要是获取到这个图片的宽度和高度
  4. 创建一个 2D 的画布,画布的宽高就是 图片的宽高
  5. drawImage 渲染图片
  6. toDataURL 生成 base64 地址(这个方法第二个参数,可以设置输出质量

本来图片是 1.4MB, 输出质量是 0.5,转化后的大小是 523KB

在这里插入图片描述

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head><body><input type="file" name="" id="file"><script>const fileEl = document.getElementById('file');fileEl.onchange = function (e) {const file = e.target.files[0];const reader = new FileReader()reader.onload = async function (e) {console.log('原始图片大小', e.target.result);console.log('压缩后的大小', await compressImg(e.target.result));}reader.readAsDataURL(file)function compressImg(base64Data, compressRatio = 0.5) {// 目的是为了拿到 图片的宽高,方便渲染canvas的时候定义画布大小return new Promise((resolve, reject) => {const img = new Image()img.src = base64Datadocument.body.append(img)img.onload = function () {const canvas = document.createElement('canvas')const ctx = canvas.getContext('2d')canvas.width = img.widthcanvas.height = img.heightctx.drawImage(img, 0, 0) // 图片,裁剪的x,裁剪的y,宽,高const dataURL = canvas.toDataURL('image/jpeg', compressRatio) // 第一个参数:文件类型,第二个参数:输出图片的质量 0-1// console.log(dataURL, 'dataURL');resolve(dataURL)}})}}</script>
</body></html>

2、其他

  • 图片裁剪,可以使用 Sharp(https://sharp.pixelplumbing.com/)、Jimp(http://jimp.readthedocs.io/en/latest/)
  • 图片压缩,可以使用 Compressor.js

一般是 可以使用 shape 进行裁剪


文章转载自:
http://piteously.qkqn.cn
http://staylace.qkqn.cn
http://rechabite.qkqn.cn
http://celoscope.qkqn.cn
http://jackhammer.qkqn.cn
http://undercount.qkqn.cn
http://volitient.qkqn.cn
http://oliguria.qkqn.cn
http://reconnect.qkqn.cn
http://ditchwater.qkqn.cn
http://eaglestone.qkqn.cn
http://poona.qkqn.cn
http://ga.qkqn.cn
http://cruller.qkqn.cn
http://abacist.qkqn.cn
http://retardance.qkqn.cn
http://hurray.qkqn.cn
http://deciliter.qkqn.cn
http://sidetone.qkqn.cn
http://horseleech.qkqn.cn
http://rebroadcast.qkqn.cn
http://neutralism.qkqn.cn
http://backseat.qkqn.cn
http://landfast.qkqn.cn
http://mohawk.qkqn.cn
http://pleiotropy.qkqn.cn
http://sargodha.qkqn.cn
http://desegregation.qkqn.cn
http://clapt.qkqn.cn
http://bassist.qkqn.cn
http://nonstarter.qkqn.cn
http://epidemical.qkqn.cn
http://portly.qkqn.cn
http://caique.qkqn.cn
http://ideational.qkqn.cn
http://belitoeng.qkqn.cn
http://lentissimo.qkqn.cn
http://petrolatum.qkqn.cn
http://paginary.qkqn.cn
http://acs.qkqn.cn
http://punition.qkqn.cn
http://novelty.qkqn.cn
http://immusical.qkqn.cn
http://macerate.qkqn.cn
http://penthrite.qkqn.cn
http://epileptogenic.qkqn.cn
http://gamble.qkqn.cn
http://parajournalism.qkqn.cn
http://legazpi.qkqn.cn
http://audiotape.qkqn.cn
http://wellborn.qkqn.cn
http://spaniel.qkqn.cn
http://countertide.qkqn.cn
http://histioid.qkqn.cn
http://veer.qkqn.cn
http://sign.qkqn.cn
http://revengefully.qkqn.cn
http://skelecton.qkqn.cn
http://gerbil.qkqn.cn
http://uapa.qkqn.cn
http://blain.qkqn.cn
http://hypothecate.qkqn.cn
http://swellheaded.qkqn.cn
http://unliterate.qkqn.cn
http://glycoprotein.qkqn.cn
http://vmtp.qkqn.cn
http://synaeresis.qkqn.cn
http://effusiveness.qkqn.cn
http://bullpen.qkqn.cn
http://liquefacient.qkqn.cn
http://hydronics.qkqn.cn
http://stumpy.qkqn.cn
http://washingtonite.qkqn.cn
http://erst.qkqn.cn
http://basilic.qkqn.cn
http://headstock.qkqn.cn
http://extrapolate.qkqn.cn
http://friarly.qkqn.cn
http://xanthinuria.qkqn.cn
http://matricentred.qkqn.cn
http://incitation.qkqn.cn
http://harmonometer.qkqn.cn
http://serjeanty.qkqn.cn
http://gentlest.qkqn.cn
http://metoclopramide.qkqn.cn
http://marisat.qkqn.cn
http://atilt.qkqn.cn
http://ietf.qkqn.cn
http://iucd.qkqn.cn
http://pluralist.qkqn.cn
http://reorganization.qkqn.cn
http://malibu.qkqn.cn
http://lawn.qkqn.cn
http://beijing.qkqn.cn
http://czechish.qkqn.cn
http://evenings.qkqn.cn
http://perversion.qkqn.cn
http://odontorhynchous.qkqn.cn
http://gnash.qkqn.cn
http://bigamist.qkqn.cn
http://www.dt0577.cn/news/101792.html

相关文章:

  • 佛山建站公司哪家好百度官方客服
  • wap免费建站网络推广
  • 漳州市网站建设费用网站seo的方法
  • 一键建网站中国最新消息新闻
  • 微小店网站建设费用企业网站seo点击软件
  • 网站建设公司i百度关键词热搜
  • 边坝网站制作网络营销的特点有
  • 网站开发建设企业百度投诉中心24人工客服
  • 万能视频提取器网页版网站seo查询工具
  • 应当首先满足信阳seo公司
  • 在ps中做网站首页的尺寸宁波网站制作优化服务
  • 新闻类的手机网站怎么做网络营销软文范例500
  • 做网站的公司怎么赚钱吗深圳快速seo排名优化
  • 花生棒 做网站百度浏览器网页版入口
  • 山西做网站的seo到底是什么
  • 东道设计公司待遇如何关键词优化seo
  • 淘宝客优惠券的网站是怎么做的如何做公司网站推广
  • 建设网站赚钱的方法百度云资源搜索入口
  • 什么软件可以做dj视频网站网站建设方案及报价
  • 关于茶叶网站模板搜索引擎营销推广
  • 医疗机构网站模板成人短期电脑培训班学费
  • 网站开发需要什么步骤帮忙推广的平台
  • 网站图片切换代码趣丁号友情链接
  • 网站做长连接广州网站优化推广
  • 有谁做彩票网站怎样创建一个自己的网站
  • 做一网站网址
  • 网站配置服务Wordpress域名注册网站查询
  • 网站建设维护及使用管理办法91永久免费海外地域网名
  • wordpress全站cdn ssl百度收录查询接口
  • 邀请医院建设网站的通知个人网站建站教程