Skip to content

Commit 25d8377

Browse files
feat(imago): add aspect format ID for formatPath()
1 parent 2b3db06 commit 25d8377

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/imago/src/path.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const _ = undefined;
3131
* - sha1/224/256/384/512: truncated hash of output
3232
* - w: current width
3333
* - h: current height
34+
* - aspect: "p" (portrait), "l" (landscape) or "sq" (square)
3435
* - date: yyyyMMdd
3536
* - time: HHmmss
3637
* - year: 4-digit year
@@ -79,6 +80,10 @@ export const formatPath = (
7980
return String(ctx.size[0]);
8081
case "h":
8182
return String(ctx.size[1]);
83+
case "aspect": {
84+
const [w, h] = ctx.size;
85+
return w > h ? "l" : w < h ? "p" : "sq";
86+
}
8287
case "date":
8388
return FMT_yyyyMMdd_ALT(_, true);
8489
case "time":

0 commit comments

Comments
 (0)