{"id":27553037,"url":"https://github.com/benedom/swiftycrop","last_synced_at":"2025-04-19T11:59:12.194Z","repository":{"id":218752404,"uuid":"706718350","full_name":"benedom/SwiftyCrop","owner":"benedom","description":"Crop your images easily using SwiftUI","archived":false,"fork":false,"pushed_at":"2025-02-14T03:40:59.000Z","size":78947,"stargazers_count":200,"open_issues_count":3,"forks_count":41,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T00:33:08.592Z","etag":null,"topics":["image-cropper","image-cropping","image-processing","ios","swift","swift-package-manager","swift5","swiftui"],"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/benedom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-10-18T13:40:32.000Z","updated_at":"2025-04-11T20:22:14.000Z","dependencies_parsed_at":"2024-04-16T10:26:40.539Z","dependency_job_id":"949f9dbb-dd9d-4054-bda8-17425e22a976","html_url":"https://github.com/benedom/SwiftyCrop","commit_stats":null,"previous_names":["benedom/swiftycrop"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedom%2FSwiftyCrop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedom%2FSwiftyCrop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedom%2FSwiftyCrop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benedom%2FSwiftyCrop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benedom","download_url":"https://codeload.github.com/benedom/SwiftyCrop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249690359,"owners_count":21311308,"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-cropper","image-cropping","image-processing","ios","swift","swift-package-manager","swift5","swiftui"],"created_at":"2025-04-19T11:59:11.626Z","updated_at":"2025-04-19T11:59:12.187Z","avatar_url":"https://github.com/benedom.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftyCrop - SwiftUI\n[![Build](https://github.com/benedom/SwiftyCrop/actions/workflows/build-swift.yml/badge.svg?branch=master)](https://github.com/benedom/SwiftyCrop/actions/workflows/build-swift.yml)\n![Static Badge](https://img.shields.io/badge/Platform%20-%20iOS%20-%20light_green)\n![Static Badge](https://img.shields.io/badge/iOS%20-%20%3E%2016.0%20-%20light_green)\n![Static Badge](https://img.shields.io/badge/Swift%20-%20%3E%205.9%20-%20orange)\n\u003ca href=\"https://github.com/benedom/SwiftyCrop/blob/master/LICENSE.md\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/License%20-%20MIT%20-%20blue\" alt=\"License - MIT\"\u003e\n\u003c/a\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/benedom/SwiftyCrop/blob/master/Assets/demo.gif\" style=\"margin: auto; width: 250px\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://github.com/benedom/SwiftyCrop/blob/master/Assets/crop_circle.png\" style=\"margin: auto; width: 250px\"/\u003e\n    \u003cimg src=\"https://github.com/benedom/SwiftyCrop/blob/master/Assets/crop_square.png\" style=\"margin: auto; width: 250px\"/\u003e\n\u003c/p\u003e\n\n## 🔭 Overview\nSwiftyCrop allows users to seamlessly crop images within their SwiftUI applications. It provides a user-friendly interface that makes cropping an image as simple as selecting the desired area.\n\nWith SwiftyCrop, you can easily adjust the cropping area, maintain aspect ratio, zoom in and out for precise cropping. You can also specify the cropping mask to be a square or circle.\n\nThe following languages are supported \u0026 localized:\n- 🇬🇧 English\n- 🇩🇪 German\n- 🇫🇷 French\n- 🇮🇹 Italian\n- 🇷🇺 Russian\n- 🇪🇸 Spanish\n- 🇹🇷 Turkish\n- 🇺🇦 Ukrainian\n- 🇭🇺 Hungarian\n- 🇧🇷 Brazilian Portuguese\n- 🇰🇷 Korean\n- 🇯🇵 Japanese\n- 🇨🇳 Chinese\n\nThe localization file can be found in `Sources/SwiftyCrop/Resources`.\n\n## 📕 Contents\n\n- [Requirements](#-requirements)\n- [Installation](#-installation)\n- [Demo App](#📱-demo-app)\n- [Usage](#-usage)\n- [Contributors](#-contributors)\n- [Author](#-author)\n- [License](#-license)\n\n## 🧳 Requirements\n\n- iOS 16.0 or later\n- Xcode 15.0 or later\n- Swift 5.9 or later\n\n\n## 💻 Installation\nThere are two ways to use SwiftyCrop in your project:\n- using Swift Package Manager\n- manual install (embed Xcode Project)\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.\n\nTo integrate `SwiftyCrop` into your Xcode project using Xcode 15.0 or later, specify it in `File \u003e Swift Packages \u003e Add Package Dependency...`:\n\n```ogdl\nhttps://github.com/benedom/SwiftyCrop\n```\n\n### Manually\n\nIf you prefer not to use any of dependency managers, you can integrate `SwiftyCrop` into your project manually. Put `Sources/SwiftyCrop` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.\n\n## 📱 Demo App\n\nTo get a feeling how `SwiftyCropView` works you can run the demo app (thanks to [@leoz](https://github.com/leoz)).\n\n## 🛠️ Usage\n\n### Quick Start\nThis example shows how to display `SwiftyCropView` in a full screen cover after an image has been set.\n```swift\nimport SwiftUI\nimport SwiftyCrop\n\nstruct ExampleView: View {\n    @State private var showImageCropper: Bool = false\n    @State private var selectedImage: UIImage?\n\n    var body: some View {\n        VStack {\n            /*\n            Update `selectedImage` with the image you want to crop,\n            e.g. after picking it from the library or downloading it.\n\n            As soon as you have done this, toggle `showImageCropper`.\n            \n            Below is a sample implementation:\n             */\n\n             Button(\"Crop downloaded image\") {\n                Task {\n                    selectedImage = await downloadExampleImage()\n                    showImageCropper.toggle()\n                }\n             }\n\n        }\n        .fullScreenCover(isPresented: $showImageCropper) {\n            if let selectedImage = selectedImage {\n                SwiftyCropView(\n                    imageToCrop: selectedImage,\n                    maskShape: .square\n                ) { croppedImage in\n                    // Do something with the returned, cropped image\n                }\n            }\n        }\n    }\n\n    // Example function for downloading an image\n    private func downloadExampleImage() async -\u003e UIImage? {\n        let urlString = \"https://picsum.photos/1000/1200\"\n        guard let url = URL(string: urlString),\n              let (data, _) = try? await URLSession.shared.data(from: url),\n              let image = UIImage(data: data)\n        else { return nil }\n\n        return image\n    }\n}\n```\n\n:bangbang: NOTE :bangbang:\n```\nIf you want to display `SwiftyCrop` inside a sheet, use `NavigationView` instead of `NavigationStack` in case you want to wrap it.\n```\n\nSwiftyCrop supports two different mask shapes for cropping:\n- `circle`\n- `square`\n- `rectangle`\n\nThis is only the shape of the mask the user will see when cropping the image. The resulting, cropped image will always be a square by default when using `circle` or `square`. To get a circular cropped image, you can override this using a configuration.\n\nYou can also configure `SwiftyCropView` by passing a `SwiftyCropConfiguration`. A configuration has the following properties:\n\n| Property      | Description |\n| ----------- | ----------- |\n| `maxMagnificationScale` | `CGFloat`: The maximum scale factor that the image can be magnified while cropping. Defaults to `4.0`. |\n| `maskRadius` | `CGFloat`: The radius of the mask used for cropping. Defaults to `130`. A good way is to make it dependend on the screens size. |\n| `cropImageCircular` | `Bool`: When using the cropping mask `circle`, whether the resulting image should also be masked as circle. Defaults to `false`. |\n| `rotateImage` | `Bool`: Whether the image can be rotated when cropping using pinch gestures. Defaults to `false`. |\n| `zoomSensitivity` | `CGFloat`: Zoom sensitivity when cropping. Increase to make zoom faster / less sensitive. Defaults to `1.0`. |\n| `rectAspectRatio` | `CGFloat`: The aspect ratio to use when a rectangular mask shape is used. Defaults to `4:3`. |\n| `texts` | `Texts`: Defines custom texts for the buttons and instructions. Defaults to using localized strings from resources. |\n| `fonts` | `Fonts`: Defines custom fonts for the buttons and instructions. Defaults to using system font. |\n| `colors` | `Colors`: Defines custom colors for the texts and background. Defaults to white text and black background. |\n\nCreate a configuration like this:\n```swift\nlet configuration = SwiftyCropConfiguration(\n    maxMagnificationScale: 4.0,\n    maskRadius: 130,\n    cropImageCircular: false,\n    rotateImage: true,\n    zoomSensitivity: 1.0,\n    rectAspectRatio: 4/3,\n    texts: SwiftyCropConfiguration.Texts(\n        cancelButton: \"Cancel\",\n        interactionInstructions: \"Custom instruction text\",\n        saveButton: \"Save\"\n    ),\n    fonts: SwiftyCropConfiguration.Fonts(\n        cancelButton: Font.system(size: 12),\n        interactionInstructions: Font.system(size: 14),\n        saveButton: Font.system(size: 12)\n    ),\n    colors: SwiftyCropConfiguration.Colors(\n        cancelButton: Color.red,\n        interactionInstructions: Color.white,\n        saveButton: Color.blue,\n        background: Color.gray\n    )\n)\n```\nand use it like this:\n```swift\n.fullScreenCover(isPresented: $showImageCropper) {\n            if let selectedImage = selectedImage {\n                SwiftyCropView(\n                    imageToCrop: selectedImage,\n                    maskShape: .square,\n                    // Use the configuration\n                    configuration: configuration\n                ) { croppedImage in\n                    // Do something with the returned, cropped image\n                }\n            }\n        }\n```\n\n## 👨‍💻 Contributors\n\nAll issue reports, feature requests, pull requests and GitHub stars are welcomed and much appreciated.\n\nThanks to [@leoz](https://github.com/leoz) for adding the circular crop mode, the demo app and the rotation functionality 🎉\n\nThanks to [@kevin-hv](https://github.com/kevin-hv) for adding the hungarian localization 🇭🇺\n\nThanks to [@Festanny](https://github.com/Festanny) for helping with the recangular cropping functionality 🎉\n\nThanks to [@lipej](https://github.com/lipej) for adding the brazilian portugese localization 🇧🇷🇵🇹\n\nThanks to [@insub](https://github.com/insub4067) for adding the korean localization 🇰🇷\n\nThanks to [@yhirano](https://github.com/yhirano) for adding the japanese localization 🇯🇵\n\nThanks to [@yefimtsev](https://github.com/yefimtsev) for adding the ability to customize fonts and colors 🖼️\n\nThanks to [@SuperY](https://github.com/SuperY) for adding the chinese localization 🇨🇳\n\n## ✍️ Author\n\nBenedikt Betz\n\n## 📃 License\n\n`SwiftyCrop` is available under the MIT license. See the [LICENSE](https://github.com/benedom/SwiftyCrop/blob/master/LICENSE.md) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedom%2Fswiftycrop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenedom%2Fswiftycrop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenedom%2Fswiftycrop/lists"}