源码:随机背景图 Node.js实现

2018年8月7日 | 分类: 【源码】

参考:https://amon.org/randombg 实证未遂。缺少文件。
参考:https://amon.org/rotatebg ‎实证成功。

【介绍】

官网:https://picsum.photos/
源码:https://github.com/DMarby/picsum-photos
图库:https://picsum.photos/images

讨论:https://www.v2ex.com/t/168131

【部署】

参考:https://amon.org/nodejs

先安装必要的包:

npm link async
npm link sharp
npm link moment

临时创建源码中缺少的文件夹和文件:

/opt/unsplash-it/images.json
/opt/photos/metadata.json

执行命令:

node index.js

【用法】

Put your image size (width & height) after our URL and you’ll get a placeholder.

https://picsum.photos/200/300

To get a square image, just put the size you want.

https://picsum.photos/200

Random image

https://picsum.photos/200/300/?random

Grayscale

Use the /g/ path to greyscale the image.

https://picsum.photos/g/200/300

List images

https://picsum.photos/list

Specific Image

Get a specific image by appending ?image to the end of the url.

https://picsum.photos/200/300?image=0

Blurred image

Get a blurred image by appending ?blur to the end of the url.

https://picsum.photos/200/300/?blur

Crop Gravity

Select the cropping gravity by adding ?gravity to the end of the url.

Valid options are: north, east, south, west, center

https://picsum.photos/200/300/?gravity=east