{"id":13685957,"url":"https://github.com/malcommac/ImageSizeFetcher","last_synced_at":"2025-05-01T04:33:05.823Z","repository":{"id":55760878,"uuid":"147953800","full_name":"malcommac/ImageSizeFetcher","owner":"malcommac","description":"Finds the type/size of an image given its URL by fetching as little data as needed","archived":true,"fork":false,"pushed_at":"2018-09-15T10:16:38.000Z","size":34,"stargazers_count":442,"open_issues_count":4,"forks_count":25,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-10T00:07:39.566Z","etag":null,"topics":["fastimage","fastimagesize","image-size","prefetch-resources"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/malcommac.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":"2018-09-08T17:12:25.000Z","updated_at":"2025-03-30T15:03:30.000Z","dependencies_parsed_at":"2022-08-15T06:50:23.205Z","dependency_job_id":null,"html_url":"https://github.com/malcommac/ImageSizeFetcher","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FImageSizeFetcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FImageSizeFetcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FImageSizeFetcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/malcommac%2FImageSizeFetcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/malcommac","download_url":"https://codeload.github.com/malcommac/ImageSizeFetcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251824814,"owners_count":21649934,"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":["fastimage","fastimagesize","image-size","prefetch-resources"],"created_at":"2024-08-02T14:00:59.929Z","updated_at":"2025-05-01T04:33:05.544Z","avatar_url":"https://github.com/malcommac.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# ImageSizeFetcher\n### Finds the size or type of an image given its uri by fetching as little as needed\n\n[![Version](https://img.shields.io/cocoapods/v/ImageSizeFetcher.svg?style=flat)](http://cocoadocs.org/docsets/ImageSizeFetcher) [![License](https://img.shields.io/cocoapods/l/ImageSizeFetcher.svg?style=flat)](http://cocoadocs.org/docsets/ImageSizeFetcher) [![Platform](https://img.shields.io/cocoapods/p/ImageSizeFetcher.svg?style=flat)](http://cocoadocs.org/docsets/ImageSizeFetcher)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ImageSizeFetcher.svg)](https://img.shields.io/cocoapods/v/ImageSizeFetcher.svg)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Twitter](https://img.shields.io/badge/twitter-@danielemargutti-blue.svg?style=flat)](http://twitter.com/danielemargutti)\n\n\u003cp align=\"center\" \u003e★★ \u003cb\u003eStar me to follow the project! \u003c/b\u003e ★★\u003cbr\u003e\nCreated by \u003cb\u003eDaniele Margutti\u003c/b\u003e - \u003ca href=\"http://www.danielemargutti.com\"\u003edanielemargutti.com\u003c/a\u003e\n\u003c/p\u003e\n\n## What's ImageSizeFetcher\n\nYour app needs to find the size or type of an image but it's  not locally stored – it’s on another asset server, or in the cloud (Amazon S3 for example); your webservice does not expose the size via APIs.\n\nYou don’t want to download the entire image to your app server – it could be many tens of kilobytes, or even megabytes just to get this information.\n\nMoreover you can't wait the download of all images to adjust your layout (ie. UICollectionView/UITableView) and you can't do it incrementally without incur in a poor UX experience for your user.\n\nFor most common image types (GIF, PNG, BMP etc.), the size of the image is simply stored at the start of the file. For JPEG files it’s a little bit more complex, but even so you do not need to fetch much of the image to find the size.\n\nImageSizeFetcher does this minimal fetch just downloade few kb and doesn’t rely on installing external libraries; it's just in pure Swift.\n\n## Supported Formats\n\nCurrently ImageSizeFetcher supports the most common formats you can use in your app:\n\n- PNG\n- GIF\n- JPEG\n- BMP\n\nIn most cases the the downloaded data is below 50 KB.\n\n## How it works\n\nIf you are interested in knowing more about how it works I wrote an article you can found on my blog:\n\n[\"Prefetching images size without downloading them [entirely] in Swift\"](http://www.danielemargutti.com)\n\nTo use it you just need to instantiate (and keep a strong reference) to the `ImageSizeFetcher` class. It supports a local in-memory cache of the request and has a GCD queue to manage multiple request automatically; you just need to call the `sizeFor()` method:\n\n```swift\nlet imageURL: URL = ...\nfetcher.sizeFor(atURL: $0.url) { (err, result) in\n  // error check...\n  print(\"Image size is \\(NSStringFromCGSize(result.size))\")\n}\n```\n\n## Unit Tests\n\nUnit tests are available inside the `Tests` folder.\n\n## Requirements\n\nImageSizeFetcher is compatible with Swift 4.x.\n\n* iOS 8.0+\n* macOS 10.9+\n* tvOS 9.0+\n* watchOS 2.0+\n\n## Issues \u0026 Contributions\n\nPlease [open an issue here on GitHub](https://github.com/malcommac/ImageSizeFetcher/issues/new) if you have a problem, suggestion, or other comment.\nPull requests are welcome and encouraged.\n\n## Installation\n\n### Install via CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager which automates and simplifies the process of using 3rd-party libraries like ImageSizeFetcher in your projects. You can install it with the following command:\n\n```bash\n$ sudo gem install cocoapods\n```\n\n\u003e CocoaPods 1.0.1+ is required to build ImageSizeFetcher.\n\n#### Install via Podfile\n\nTo integrate ImageSizeFetcher into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '8.0'\n\ntarget 'TargetName' do\nuse_frameworks!\npod 'ImageSizeFetcher'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n\u003ca name=\"carthage\" /\u003e\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate ImageSizeFetcher into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"malcommac/ImageSizeFetcher\"\n```\n\nRun `carthage` to build the framework and drag the built `ImageSizeFetcher.framework` into your Xcode project.\n\n## Copyright\n\nImageSizeFetcher is available under the MIT license. See the LICENSE file for more info.\n\nDaniele Margutti: [hello@danielemargutti.com](mailto:hello@danielemargutti.com)\n\nTwitter: [@danielemargutti](https://twitter.com/danielemargutti)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcommac%2FImageSizeFetcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmalcommac%2FImageSizeFetcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmalcommac%2FImageSizeFetcher/lists"}