1.0.0 • Published 3 years ago

wptoimage v1.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

wptoimage

通过puppeteer的网页截图功能实现把网页转换为图片

开发涉及到的工具:

功能实现:

通过puppeteer的网页截屏功能实现网页转换为图片。

实现方式:

wptoimage <本地文件名/URL> <图片名称>

参数说明

参数名参数全名类型参数说明
-x--shot-w设置图片宽度,full-page为true时,若x大于页面内容实际宽度,x为图片宽度,若x小于页面内容实际宽度,页面最小宽度为图片宽度, 不存在页面最小宽度时请设置x的值;full-page为false时,x为图片宽度
-y--shot-h设置图片高度,full-page为true时,若y大于页面内容实际高度,y为图片高度,若y小于页面内容实际高度,页面最小高度为图片高度;full-page为false时,y为图片高度
-q--shot-q设置图片质量,只有jpg类型生效,1-100之间
--no-full-page--取消截取完整页面, 默认宽为860, 高为600

安装方式:

由于是nodejs开发的命令行工具,所以首先需要安装nodejs。
其次:

npm i wptoimage -g
or
yarn global add wptoimage

安装过程中可能会出现的问题:

1、由于依赖的puppeteer需要下载Chromium,下载过程中不知道是权限问题还是网络问题导致发生错误。在windows下使用管理员权限能够正常的下载,但是在linux下切换到root依然无法下载。
建议使用

cnpm i wptoimage -g

2、在linux下还可能会出现其他的问题https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md 主要是因为沙箱和Chromium依赖包未安装的原因。
3、CentOS6需要在~/.bashrc文件配置环境变量

文件末尾添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/firefox/bundled/lib64
1.0.0

3 years ago

0.1.0

5 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago