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

网站被黑了h5免费

网站被黑了,h5免费,网站的基本功能,会计是做什么的Sharp是一个基于libvips的高性能Node.js图像处理库#xff0c;它提供了广泛的功能#xff0c;包括调整大小、裁剪、旋转、格式转换等。Sharp可以处理多种图像格式#xff0c;并且能够高效地转换图像格式。 相关说明及用法看#xff1a;https://sharp.nodejs.cn/ 安装#…Sharp是一个基于libvips的高性能Node.js图像处理库它提供了广泛的功能包括调整大小、裁剪、旋转、格式转换等。Sharp可以处理多种图像格式并且能够高效地转换图像格式。 相关说明及用法看https://sharp.nodejs.cn/ 安装Sharpnpm install sharp 以及安装npm install --save text-to-svg text-to-svg将文本转换为SVG路径而无需本地依赖,相关用法及说明看https://www.npmjs.com/package/text-to-svg 上代码 const sharprequire(sharp); const fsrequire(fs); const textToSvgrequire(text-to-svg);const basePicture${__dirname}/img/123.jpg;//转化Buffer流对象并将buffer流合并成一个并期约返回 function streamToBuffer(stream) {return new Promise((resolve,reject){const bufferList[];//图片流数据stream.on(data,data{bufferList.push(data);})stream.on(error,err{reject();})//end为追加数据stream.on(end,(){//这里是合并buffer对象resolve(Buffer.concat(bufferList));})}) }//生成新图片并追加新图片的格式大小覆盖区域等 function dealWithStream(basePicture) {const readableStreamfs.createReadStream(basePicture);const transformersharp().resize({width:100,height:100,fit:sharp.fit.cover,position:sharp.strategy.entropy})//console.log(transformer);//将transformer流数据追加进行处理readableStream.pipe(transformer);streamToBuffer(transformer).then(function(newPicBuffer){//写入新图片中fs.writeFile(${__dirname}/img/water.png,newPicBuffer,function(err){if(err){console.log(err);return;}console.log(done);})})}//dealWithStream(basePicture); //将图片转为jpeg,并对jpeg文件进行处理 function dealWithBuffer(basePicture) {sharp(basePicture).resize(800,600,{fit:sharp.fit.inside,withoutEnlargement:true}).toFormat(webp).toBuffer().then(function(outputBuffer){fs.writeFile(${__dirname}/img/3.webp,outputBuffer,function(err){if(err){console.log(err);return;}console.log(done);})}) }//dealWithBuffer(basePicture); //添加文字水印 function addText(basePicture,font,newFilePath) {const {fontSize,text,color,left,top}font;const textToSvgSynctextToSvg.loadSync();const attributes{fill:color};const options{fontSize,anchor:top,attributes};const svgTextBufferBuffer.from(textToSvgSync.getSVG(text,options));//添加文字sharp(basePicture).composite([{input:svgTextBuffer,top,left}]).withMetadata() // 在输出图像中包含来自输入图像的所有元数据(EXIF、XMP、IPTC)。.toFormat(webp) //生成新的图片格式为webp.toFile(newFilePath) .then(info{if(!!info){console.log(水印已经生成);}}).catch(err{console.log(err);}) }/* addText(basePicture,{fontSize:24,text:喜气洋洋,color:white,left:200,top:200 },${__dirname}/img/6.webp); *///添加图片水印,水印图片一定要小于原图 function addWatermark(basePicture,watermarkPicture,newFilePath) {sharp(basePicture)//.rotate(180) //旋转180度.composite([{input:watermarkPicture,blend:overlay,globalAlpha:0.5,left:50,top:50 }])//在左上坐标(10,10)位置添加水印图片,composite为合成图片.withMetadata().webp({quality:90}).toFile(newFilePath).then(result{if(result){console.log(水印已经添加);}}).catch(err{console.log(err);})sharp.cache(false); }//dealWithStream(./img/300.jfif); let waterPic${__dirname}/img/water.png addWatermark(basePicture,waterPic,./img/7.webp);
http://www.hkea.cn/news/14375198/

相关文章:

  • zencart 网站老是跳转到原地址如何做网上销售网站
  • 公司内部 网站开发抖音上的小程序怎么赚钱
  • 栖霞建设招标网站wordpress 不同页面
  • 网站建设必须要服务器吗小程序报价单模板
  • 佛山网站公司建立网站链接结构的基本方式是
  • wordpress怎么上传乐视频听排名优化软件点击
  • 徐州做网站的公司有哪些长宁区网站建设公司
  • 网站什么做的精品网站建设
  • dedecms导航网站电子商务公司网站怎么建
  • 南宁网站推广流程公司关键词排名优化
  • 安徽黄山网站建设小程序搭建系统
  • 网站在哪里变更备案信息网络公司什么意思
  • 网站建设的视频教程wordpress+调用多媒体
  • 贵州网站建设设计南昌做企业网站
  • 怎么做网站上打字体宁波外贸公司电话名单
  • 网站建设推进情况哈尔滨怎样快速建站
  • 微信的网站怎么做洛阳青峰网络公司做网站
  • 网站开发财务费用网站 wap
  • 国内卡一卡二卡三网站视频在线支付的网站怎么做
  • 徐州做网站的公司有几家工作细胞第一季
  • 有没有网站做胡兼职上海最好网站建设公司
  • 网站seo优化查询怎么看网站的建站公司是哪个
  • 高端网站设计公司广告策划方案
  • 新公司网站怎么做推广东营网站建设那家好
  • 有哪些做软件的网站传奇新服网
  • 网站做什么推广好类似头条的网站怎么做
  • 自己做网站导航页wordpress导航怎么添加连接
  • 网站架构的组成部分智慧团建登录网站入口
  • 中型网站每天访问量seo的优化方案
  • 网站页面相关产品链接怎么做网站策划的基本过程