{"id":16900077,"url":"https://github.com/runlevel5/aspect_ratio","last_synced_at":"2026-05-11T02:40:58.770Z","repository":{"id":62421533,"uuid":"285795577","full_name":"runlevel5/aspect_ratio","owner":"runlevel5","description":"A TypeScript module for image aspect calculation","archived":false,"fork":false,"pushed_at":"2020-08-07T10:06:59.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-25T12:28:00.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/runlevel5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-07T09:53:38.000Z","updated_at":"2021-11-23T11:11:31.000Z","dependencies_parsed_at":"2022-11-01T17:31:52.927Z","dependency_job_id":null,"html_url":"https://github.com/runlevel5/aspect_ratio","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Faspect_ratio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Faspect_ratio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Faspect_ratio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/runlevel5%2Faspect_ratio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/runlevel5","download_url":"https://codeload.github.com/runlevel5/aspect_ratio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244610361,"owners_count":20480968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T17:51:29.201Z","updated_at":"2026-05-11T02:40:53.728Z","avatar_url":"https://github.com/runlevel5.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aspect_ratio\n\nImage aspect ratio utilities module for Deno\n\nThis module is a TypeScript port of [node-aspectratio](https://github.com/Turistforeningen/node-aspectratio)\n\n## API\n\n```ts\nimport { crop, resize } from 'https://deno.land/x/aspect_ratio@v1.0.0/mod.ts';\n```\n\n### crop(**integer** `width`, **integer** `height`, **string** `ratio`)\n\nApply a fixed aspect `ratio` crop without distoring the image aspect ratio.\n\n* **integer** `width` - original image width\n* **integer** `height` - original image height\n* **string** `ratio` - new image ratio\n\n\u003e The `ratio` must be on the following format: `x`:`y` where `x` and `y` are\n\u003e integers. The order of `x` and `z` does not matter and `3:4` will be treated\n\u003e as `4:3`.\n\n\u003e By default #crop() will match the orientation of the original image unless a\n\u003e forced orientation is given on the follwing format: `x`:`y`!`z` where `z` is\n\u003e the orientation (`v` for vertical, or `h` for horizontal).\n\n#### Return\n\nThis will return an `Array` of four values:\n\n1. **integer** `x` - top lef x coordinate\n2. **integer** `y` - top lef y coordinate\n3. **integer** `width` - new image width\n4. **integer** `height` - new image height\n\n#### Example\n\n```js\nvar crop = aspect.crop(2048, 768, '4:3');\n// [512, 768, 1024, 768]\n```\n\nImage: [Crop with fixed ratio](./image.png)\n\n### resize(**integer** `x`, **integer** `y`, **integer** `maxX`, **integer** `maxY`)\n\nGet resized height and width of an image while perserving the aspect ratio of\nthe image.\n\n* **integer** `x` - original image width\n* **integer** `y` - original image height\n* **integer** `maxX` - max image width\n* **integer** `maxY` - max image height\n\n### Return\n\nReturns an `Array` of the resized `x` and `y` values:\n\n* **integer** `x` - resized image width\n* **integer** `y` - resized image height\n\n## [MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunlevel5%2Faspect_ratio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frunlevel5%2Faspect_ratio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frunlevel5%2Faspect_ratio/lists"}