https://github.com/andylindebros/profileimageeditor
Create Profile images to use in your Swift/SwiftUI project
https://github.com/andylindebros/profileimageeditor
editor imagemanipulation profileimage swift swiftui
Last synced: 5 months ago
JSON representation
Create Profile images to use in your Swift/SwiftUI project
- Host: GitHub
- URL: https://github.com/andylindebros/profileimageeditor
- Owner: andylindebros
- License: mit
- Created: 2024-08-21T22:23:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-22T14:42:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-17T01:37:39.287Z (over 1 year ago)
- Topics: editor, imagemanipulation, profileimage, swift, swiftui
- Language: Swift
- Homepage:
- Size: 4.75 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ProfileImageEditor
ProfileImageEditor is a Swift package designed for creating custom profile images based on a specified view and its dimensions. Users can select a photo from their photo library and easily adjust its composition by dragging the image within the view to achieve the desired layout. Once the layout is finalized, the package will generate a new image with your desired dimensions, which can then be exported for use in your project.

## Installation
1. In Xcode, with your app project open, navigate to `File > Add Packages`.
1. When prompted, add the Firebase Apple platforms SDK repository:
```
https://github.com/andylindebros/profile-image-editor
```
3. Select the SDK version that you want to use.
When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.
## Implementation
Add the ProfileImageEditor to desired SwiftUI view.
``` Swift
import Combine
import ProfileImageEditor
class ContentViewModel: ObservableObject {
init() {
profileImageEditorViewModel = ProfileImageEditorViewModel()
subscriber = profileImageEditorViewModel.imageExportAction.sink { [weak self] model in
// Save or integrate the exported images with your project here.
}
}
private var subscriber: Cancellable?
let profileImageEditorViewModel: ProfileImageEditorViewModel
}
struct ContentView: View {
@ObservedObject var viewModel = ContentViewModel()
// The aspect ratio should be 1:1 so we specify width and height with this value
let exportSize: CGFloat = 100
var body: some View {
ZStack {
ProfileImageEditor(viewModel: viewModel.profileImageEditorViewModel)
.padding()
VStack {
Spacer()
Button(action: {
viewModel.profileImageEditorViewModel.dispatch(.exportImage(withSize: exportSize))
}) {
Text("Export")
}
}
}
}
}
```
## Export Images
The Export delivery model generates two UIImages: the original image and a resized version with the specified dimensions. Both images maintain a 1:1 aspect ratio.
## Example project
Explore the example project included in this package to learn more about how the ProfileImageEditor works.
Let me know what you think and drop me a line: andylindebros@gmail.com