node.js实现图片裁剪+获取图片大小+加logo水印

2018-01-12 13:51:02

1、装npm install images插件

 代码如下:     

var fs = require("fs");var images=require('images');
.(,(req,res,next) {    =;//生成的图片    =;//原图片    =;//logo水印    =().width()-().width();=().height()-().height();
    ()    .(,)            :
      });    = .statSync().size;});

相关资料:https://github.com/zhangyuanwei/node-images          
          http://nodejs.cn/api/fs

以上是使用images插件


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


使用:sharp插件速度相对来说比gmimages块,失贞程度也比较低。

npm install sharp --save



var sharp=require('sharp');



(+)
   .overlayWith(+'/../    .resize(null,)//按照height去压缩
    .toFile(+,(error) {    .(error);    .(.(error));    (.(error)){        .();        .();    }{        .();    }});sharp总比来说比其他插件好用。sharp项目主页:https://github.com/lovell/sharpsharp项目中有源码,可以根据源码中的demo去写自己的模块。


  • 2017-12-25 11:07:58

    mogodb 备份

    error connecting to db server: server returned error on SASL authentication

  • 2017-12-25 15:53:15

    MongoDB3.4版本配置详解

    配置文件方面,mongod和mongos有很多相同之处,下文中如有区别之处将会特别指出。 在一个节点上,通常同时启动mongod和mongos进程是正常的,他们之间不存在资源竞争,但是为了避免冲突,我们希望它们使用各自的配置文件,比如mongod.conf、mongos.conf;mongodb的某些平台下的安装包中没有自带配置文件,需要开发者自己创建。