同步操作将从 屈阿零/cdn-manager 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
根据@dadi/cdn 制作的脚手架,专门处理云转码上边的图片,自动剪切处理,标准化海报。
workspace/recipes/poster.json
{
"recipe": "poster",
"settings": {
"format": "jpg",
"quality": "90",
"height": "240",
"ratio": "16-9",
"resizeStyle": "entropy"
}
}
设置预处理模块,将图片处理成 16:9 的比例,高度 240PX,并且格式为 jpg,质量为 90%的格式。 config/config.production.json
{
"server": {
"host": "127.0.0.1",
"port": 8001
},
"images": {
"remote": {
"enabled": true,
"path": "#"
}
}
}
设置运行端口 8001,设置远程连接 path,比如云转码 express-ffmpeg 绑定的域名https://www.moejj.com.
比如https://www.moejj.com/videos/5bc721ef87af60065e31735e/1.jpg 是云转码上边的图片。 访问http://127.0.0.1:8001/poster/videos/5bc721ef87af60065e31735e/1.jpg 则会直接返回自动处理成 16:9 格式为 jpg 质量为 90%,高度为 240px,智能剪切的图片。 预处理设置的链接为 poster,详见上方 recipes 的配置,可以自行进行更改。
https://github.com/dadi/cdn 参考此库。
config/config.production.json 运行环境配置文件
"caching": {
"ttl": 3600,
"expireAt": "0 5 0 * * *"
}
expireAt 配置解释
ttl 配置解释
"images": {
"directory": {
"enabled": true,
"path": "relative/path/to/your/images"
},
"remote": {
"enabled": true,
"path": "https://server1.somedomain.tech/images"
},
"s3": {
"enabled": true,
"accessKey": "your-access-key",
"secretKey": "your-secret",
"bucketName": "your-bucket",
"region": "your-region",
"endpoint": "ams3.digitaloceanspaces.com"
}
}
images 配置项 一共有三种用法,一种是直接服务同主机图片,服务本地图片,一种是服务远程图片,最后一种是亚马逊和 Digital Ocean Space 云储存。
directory 服务本地文件,直接指定 path 为文件夹地址即可直接处理本地图片。例如/www/express-ffmpeg/public,然后将图片地址 host 更改为 CDN 地址即可。
remote 服务远程文件,直接设置 path 为远程 url,例如 www.moejj.com,最后把地址替换成 cdn 地址即可。
s3 云储存 可扩展的云储存,可以直接缓存各种云储存上边的图片。
"assets": {
"directory": {
"enabled": true,
"path": "/Users/absolute/path/to/your/assets"
}
}
除了把 images 换成 assets,其他用法一样,设置之后会缓存除了 jpg 的各种文件,包括视频文件。
workspace/recipes/recipe.json 配置文件
{
"recipe": "poster",
"settings": {
"format": "jpg",
"quality": "90",
"height": "240",
"ratio": "16-9",
"resizeStyle": "entropy"
}
}
recipe 文件是预配置格式处理文件,在 workspace/recipes 文件夹中建立。
设置完成之后,比如 recipe 为 poster,则访问链接为 cdnhost/poster/yourpath/1.jpg
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。