Skip to content

Commit

Permalink
feat(imago): add aspect format ID for formatPath()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 1, 2024
1 parent 2b3db06 commit 25d8377
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/imago/src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const _ = undefined;
* - sha1/224/256/384/512: truncated hash of output
* - w: current width
* - h: current height
* - aspect: "p" (portrait), "l" (landscape) or "sq" (square)
* - date: yyyyMMdd
* - time: HHmmss
* - year: 4-digit year
Expand Down Expand Up @@ -79,6 +80,10 @@ export const formatPath = (
return String(ctx.size[0]);
case "h":
return String(ctx.size[1]);
case "aspect": {
const [w, h] = ctx.size;
return w > h ? "l" : w < h ? "p" : "sq";
}
case "date":
return FMT_yyyyMMdd_ALT(_, true);
case "time":
Expand Down

0 comments on commit 25d8377

Please sign in to comment.