Skip to content

Commit

Permalink
feat(misc/picture.md): 图片格式化更多规则
Browse files Browse the repository at this point in the history
  • Loading branch information
SessionHu committed Jul 25, 2024
1 parent 4969573 commit 5851a02
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions docs/misc/picture.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
# 图片格式化

对于\*.hdslb.com/bfs下的图片文件都可以使用以下格式化参数
对于 `*.hdslb.com/bfs` 下的图片文件都可以使用以下可选格式化参数.

> \*.hdslb.com/bfs/\*/\*.\[jpg/png/gif\]@{width}w\_{high}h\_{quality}q.{format}
使用 `@` 开始参数 (无论格式如何, 无论是否有参数, 通过计算 HASH 发现, 使用 `@` 均会导致返回图片不同), 多个参数以 `_` 分隔, 图片格式无需分隔且必须放在最后

| 可选参数 | 含义 | 备注 |
| -------- | ---------------- | ---------------- |
| width | 图片最大限制宽度 | |
| high | 图片最大限制高度 | |
| quality | 图片质量百分比 | 仅限webp |
| format | 图片格式 | 仅限png/jpg/webp/[avg_color](#avg_color格式说明) |
参见: [#191](https://github.com/SocialSisterYi/bilibili-API-collect/issues/191)

注: jpg 即 jpeg, 二者等效. 网页端常用 AVIF, WebP.

| 参数 | 格式 | 含义 | 备注 |
| ---- | ------- | ---------------- | ---------------- |
| w | ${int}w | 图片最大限制宽度 | 范围 [1, 9223372036854775807] |
| h | ${int}h | 图片最大限制高度 | 范围 [1, 9223372036854775807] |
| s | ${int}s | 作用尚不明确 | 不影响输出结果, 范围 [1, 9223372036854775807] |
| e | $(int)e | 改变大小 | 0: 保留比例取其小, 1: 保留比例取其大, 2: 不保留原比例 |
| p | $(int)p | 缩放倍数 | 默认100, 范围 [1, 1000] |
| o | $(int)o | 作用尚不明确 | 不影响输出结果 范围 [0, 1] |
| q | ${int}q | 图片质量百分比 | 仅限webp/jpeg/avif |
| c | ${int}c | 裁切图片(如果宽高允许) | 0: 不裁切但会修改图片, 1: 上传时的预设规则(若无则右下), 2: 左上, 3: 右上 |
| f | ${int}f | 作用尚不明确 | [0, 1]: 不改变图片, 2: 会改变图片 |
| progressive | progressive | 图片编码方式 | 仅限 jpeg(无: baseline, 有: progressive)/png(无:non-interlaced, 有: interlaced) |
| ! | !${str} | 加载来源 | web-home-carousel-cover, header, web-dynamic, web-avatar-space-header, ... |
| . | .${str} | 图片格式 | 仅限 png/jpeg/webp/avif/[avg_color](#avg_color格式说明) |

**示例:**

<details>
<summary>查看示例:</summary>

原始图片

https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg
Expand Down Expand Up @@ -43,6 +58,7 @@ https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg@1q

![](https://i1.hdslb.com/bfs/archive/e5fff1472bad1c0c6bcb3004205f9be23b58ffc0.jpg@1q.webp)

</details>

## avg_color格式说明

Expand Down

0 comments on commit 5851a02

Please sign in to comment.