@escape-game-over/atlas 0.1.35 → 0.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/share-images.md +10 -5
- package/package.json +1 -1
- package/src/astro/images.ts +6 -4
package/docs/share-images.md
CHANGED
|
@@ -22,11 +22,16 @@ So **1200×630 for everything**, and let the square surfaces crop.
|
|
|
22
22
|
|
|
23
23
|
That crop is the whole reason `shareImage` takes a fit at all:
|
|
24
24
|
|
|
25
|
-
| The page's art | `shareImage` call
|
|
26
|
-
| --------------------- |
|
|
27
|
-
| A photograph | `shareImage(src)` — `cover`
|
|
28
|
-
| A logo, square source | `shareImage(src, { fit: "contain", background })` | scaled to 630×630 and centred, so a square crop lands **exactly on the logo** |
|
|
29
|
-
| A logo under ~630px | neither — compose one or get a bigger file
|
|
25
|
+
| The page's art | `shareImage` call | Why |
|
|
26
|
+
| --------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
27
|
+
| A photograph | `shareImage(src)` — `cover`, `jpeg` | edges are scenery; a square crop takes the middle, which is the subject |
|
|
28
|
+
| A logo, square source | `shareImage(src, { fit: "contain", background, format: "png" })` | scaled to 630×630 and centred, so a square crop lands **exactly on the logo** |
|
|
29
|
+
| A logo under ~630px | neither — compose one or get a bigger file | `contain` would enlarge it, and `shareImage` refuses rather than ship a blurred card |
|
|
30
|
+
|
|
31
|
+
The format follows the art, not the surface. A photograph is `jpeg`, the default:
|
|
32
|
+
as `png` it runs to 1–2MB, and WhatsApp shows no preview for an image past
|
|
33
|
+
about 300kB. A logo on a flat field is `png`, which is smaller and sharper for
|
|
34
|
+
flat colour than `jpeg`'s blocks.
|
|
30
35
|
|
|
31
36
|
Both examples use the second row for their catalogue pages: a room's own mark on
|
|
32
37
|
the brand field, so a chat thumbnail shows which room it is rather than a
|
package/package.json
CHANGED
package/src/astro/images.ts
CHANGED
|
@@ -30,9 +30,11 @@ interface ShareImageBase {
|
|
|
30
30
|
/** Defaults to 630. */
|
|
31
31
|
readonly height?: number;
|
|
32
32
|
/**
|
|
33
|
-
* Defaults to `
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* Defaults to `jpeg`: accepted by every scraper, and a 1200×630 photograph
|
|
34
|
+
* lands near 150kB where `png` makes it 1–2MB — past the ~300kB WhatsApp
|
|
35
|
+
* will fetch for a preview at all. Ask for `png` for flat art, a logo on
|
|
36
|
+
* its field, where it is both smaller and sharper. Avoid `avif`, which
|
|
37
|
+
* several scrapers still cannot read.
|
|
36
38
|
*/
|
|
37
39
|
readonly format?: "png" | "jpeg" | "webp";
|
|
38
40
|
/** Ignored by `png`, which is lossless. */
|
|
@@ -146,7 +148,7 @@ export async function shareImage(
|
|
|
146
148
|
): Promise<ImageAsset> {
|
|
147
149
|
const width = options.width ?? SHARE_WIDTH;
|
|
148
150
|
const height = options.height ?? SHARE_HEIGHT;
|
|
149
|
-
const format = options.format ?? "
|
|
151
|
+
const format = options.format ?? "jpeg";
|
|
150
152
|
const fit = options.fit ?? "cover";
|
|
151
153
|
|
|
152
154
|
// Astro's image service never enlarges: ask for a box bigger than the
|