{"id":18836498,"url":"https://github.com/ojii/imgsize","last_synced_at":"2025-04-14T05:31:07.892Z","repository":{"id":136860347,"uuid":"59197573","full_name":"ojii/imgsize","owner":"ojii","description":"Python library to get the type and size of an image quickly","archived":false,"fork":false,"pushed_at":"2024-08-25T05:53:08.000Z","size":3265,"stargazers_count":7,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-25T06:44:20.368Z","etag":null,"topics":["image","python"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ojii.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-19T10:42:24.000Z","updated_at":"2024-08-20T04:29:59.000Z","dependencies_parsed_at":"2024-07-13T07:49:05.221Z","dependency_job_id":"be3e5911-dddb-4630-935b-463dcf9d18da","html_url":"https://github.com/ojii/imgsize","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ojii%2Fimgsize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ojii%2Fimgsize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ojii%2Fimgsize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ojii%2Fimgsize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ojii","download_url":"https://codeload.github.com/ojii/imgsize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223620532,"owners_count":17174575,"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":["image","python"],"created_at":"2024-11-08T02:22:30.529Z","updated_at":"2024-11-08T02:22:31.128Z","avatar_url":"https://github.com/ojii.png","language":"Rust","readme":"# imgsize\n\nGiven some data, determines whether the data is likely an image and if so, what size and type it is and whether it is\nanimated or not.\n\n## Formats\n\nSupported formats:\n\n* PNG/APNG\n* JPEG\n* GIF\n* AVIF/AVIS\n* BMP\n\n## Usage\n\n```python\nfrom imgsize import get_size\n\nsome_image_data: bytes = ...\n\nsize = get_size(some_image_data)\nif size is None:\n    print(\"Could not handle data\")\nelse:\n    size.width\n    size.height\n    size.mime_type\n    size.is_animated\n```\n\nYou should not pass the entire image data, the first kilobyte or so should suffice.\n\n### API\n\n#### `imgsize.get_size(data: bytes) -\u003e imgsize.Size | None`\n\nGiven the data in the bytes provided, attempts to determine the image format, size and whether it\nis an animated image or not, otherwise returns None.\n\n#### `imgsize.Size`\n\nA class with four properties: `width: int`, `height: int`, `mime_type: str`, `is_animated: bool`.\n\nInstances of `imgsize.Size` are equatable, hashable and iterable (yielding `width` and `height`).\n\nInstances of `imgsize.Size` have a `as_dict()` method which returns the properties as a dictionary.\n\n## Notes\n\n`imgsize` does not validate whether the data passed is a valid image or not. The intended use of\nthis library is to reject data early and quickly if it does not appear to be an image format you\nintend to support. If you need to validate the entire image, the suggested workflow is to use this\nlibrary to reject data that is not images, is not a file format you support, has dimensions beyond\nwhat you wish to support or is animated if you only want static images, then pass it to a library\nthat does actual image parsing to determine if the data is actually an image.\n\n`imgsize` only supports a few formats, the supported formats is mostly based on what browsers support,\nand does not necessarily support all features or variants of those formats, as a result, there might be\nfalse positives and false negatives.\n\n## Building\n\nUse [maturin](https://www.maturin.rs/) to build: `maturin build`\n\nTo build \u0026 install into your local env: `maturin develop`\n\n## Testing\n\n### Rust\n\n`cargo test`\n\n### Python\n\nThe following must be run in a virtual env:\n\n```\npip install '.[test]'\npytest python-tests\n```\n\n## Release\n\n1. Change the version number in `Cargo.toml`\n2. Push to the main branch on GitHub (preferably via Pull Request)\n3. Create a Release (git tag) on GitHub\n4. Release will automatically be pushed to PyPI","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fojii%2Fimgsize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fojii%2Fimgsize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fojii%2Fimgsize/lists"}