All Projects → Rillieux → PhotoSelectAndCrop

Rillieux / PhotoSelectAndCrop

Licence: MIT license
This package integrates a UIImagePickerController into a SwiftUI app. Obtain 1) a copy of the original image, 2) a scaled and / or cropped version of it, 3) a CGFloat and 4) CGPoint. The CGFloat and CGPoint represent the scale and position of the original image used to make the processed version.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to PhotoSelectAndCrop

ImagePickerView
🌇 PHPickerViewController / UIImagePickerController for SwiftUI
Stars: ✭ 18 (-68.42%)
Mutual labels:  imagepicker, swiftui
XGImagePickerController
iOS相册图片/视频选择器
Stars: ✭ 32 (-43.86%)
Mutual labels:  imagepicker, imagepickercontroller
ConvenientImagePicker
🏞🌅🌄🎇🌇🏙🌃🌉🌁the new iOS image picker. Beautiful, delicate, and customizable.
Stars: ✭ 44 (-22.81%)
Mutual labels:  imagepicker, imagepickercontroller
Tzimagepickercontroller
一个支持多选、选原图和视频的图片选择器,同时有预览、裁剪功能,支持iOS6+。 A clone of UIImagePickerController, support picking multiple photos、original photo、video, also allow preview photo and video, support iOS6+
Stars: ✭ 7,740 (+13478.95%)
Mutual labels:  imagepicker, imagepickercontroller
WAProfileImage
WAProfileImage - A library for Android for choosing and editing profile image like WhatsApp
Stars: ✭ 29 (-49.12%)
Mutual labels:  crop-image, imagepicker
Imagepicker
📸Image Picker for Android, Pick an image from Gallery or Capture a new image with Camera
Stars: ✭ 623 (+992.98%)
Mutual labels:  crop-image, imagepicker
Insgallery
📸 Instagram-like image picker for Android (一款 UI 炫酷高仿 Instagram 的图片、视频选择器)
Stars: ✭ 409 (+617.54%)
Mutual labels:  crop-image, imagepicker
SSImagePicker
Easy to use and configurable library to Pick an image from the Gallery or Capture an image using a Camera... 📸
Stars: ✭ 227 (+298.25%)
Mutual labels:  crop-image, imagepicker
vue-crop
[举个例子]https://codesandbox.io/s/910ro8ym9r [演示链接(戳我直达)]http://www.wwwwxy.top/html/blg/
Stars: ✭ 38 (-33.33%)
Mutual labels:  crop-image
NukeUI
Lazy image loading for Apple platforms: SwiftUI, UIKit, AppKit
Stars: ✭ 9 (-84.21%)
Mutual labels:  swiftui
SupportDocs
Generate help centers for your iOS apps. Hosted by GitHub and always up-to-date.
Stars: ✭ 135 (+136.84%)
Mutual labels:  swiftui
dashboard
iOS app + Today widget that monitors the status of my web apps. Updated for SwiftUI!
Stars: ✭ 41 (-28.07%)
Mutual labels:  swiftui
SwiftUIFormHelper
Helper functions for creating forms with SwiftUI
Stars: ✭ 23 (-59.65%)
Mutual labels:  swiftui
Note.it
A Cut Down, Simple, Text Editor For Mac And iOS. Built With SwiftUI (Mostly).
Stars: ✭ 20 (-64.91%)
Mutual labels:  swiftui
Guia-SwiftUI-Ilustrado
Projeto estendido do mini-challenge 5.5 @ Apple Developer Academy PUC-Rio
Stars: ✭ 24 (-57.89%)
Mutual labels:  swiftui
react-drop-n-crop
An opinionated implementation of react-dropzone and react-cropper
Stars: ✭ 17 (-70.18%)
Mutual labels:  crop-image
NXNavigationExtension
🔥 Lightweight, simple, and easy-to-use NavigationBar library.
Stars: ✭ 121 (+112.28%)
Mutual labels:  swiftui
Chord-Provider
A Chordpro parser/editor in SwiftUI 4 for macOS and iOS
Stars: ✭ 20 (-64.91%)
Mutual labels:  swiftui
Utai
Mini-Functional, Offensive, MP3 Tagger for Philharmoniques
Stars: ✭ 32 (-43.86%)
Mutual labels:  swiftui
WeatherSwiftUI
Implementation of the Weather app using SwiftUI and OpenWeather API.
Stars: ✭ 37 (-35.09%)
Mutual labels:  swiftui

Photo Select and Crop

This Swift Package integrates a UIImagePickerController into a SwiftUI app and allows a user to select, scale and position an image to be cropped and saved as a conatct's photo, similar to the stock iOS Contacts app. To accomplish this, the project uses a composeImageAttributes() function to send four variables via bindings to the parent view:

  1. a copy of the original UIImage,
  2. a scaled and / or cropped UIImage version of it,
  3. a CGFloat, and
  4. a CGPoint.

The CGFloat and CGPoint represent the scale and position of the original image used to make the processed version.

☝️ By saving the original image and scale and position markers and passing them to the ImageMoveAndScaleSheet view, if the user taps the "Change photo" button, the original photo is scaled and positioned to allow subsequent adjustments.

Implementation

Add an ImagePane view to your parent view like this:

`ImagePane(ImagePane(image: image, isEditMode: $isEditMode, renderingMode: renderingMode, colors: colors)

Using CoreData, one might do the following. Define two entities: Contact and ProfileImage, where Contact has a To One relationship to ProfileImage. The ProfileImage entity should have properties that can be mapped to the variables provided to the ImageDisplay struct after the user has selected an image from their library.

Then, an ImageAttributes class should be initialized with the properties from the Core Data entity. This ImageAttributes class is then passed to the ImagePane as in the above code. For the nil case, a second ImageAttributes struct is initialzed, this time with a default image named avatar which was saved to the project's Image Assets folder.

An ImageAttributes object can easily be defined as a placeholder.

With an SF Symbol: let placeholderAperture = ImageAttributes(withSFSymbol: "camera.aperture")

With an image from the Assets folder: let placeholderAvatar = ImageAttributes(withImage: "avatar")

Examples of working apps using this Package can be found at: https://github.com/Rillieux/Contacts (using CoreData), and https://github.com/Rillieux/PhotoSelectAndCropDemo (a basic working implementation which does not cover persistence).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].