All Projects → timonus → Uiimageheic

timonus / Uiimageheic

Licence: bsd-3-clause
UIImage category that adds familiar HEIC encoding.

Projects that are alternatives of or similar to Uiimageheic

SafeAreaExample
The example project which allows you to play with safe areas introduced in iOS 11
Stars: ✭ 64 (-48.8%)
Mutual labels:  uikit, ios11
Swiftuiimageeffects
Swift port of Apple UIImage+UIImageEffecs category.
Stars: ✭ 213 (+70.4%)
Mutual labels:  uikit, uiimage
Cards
Awesome iOS 11 appstore cards in swift 5.
Stars: ✭ 4,017 (+3113.6%)
Mutual labels:  ios11, uikit
KBImageView
UIImageView with Ken Burns effect.
Stars: ✭ 48 (-61.6%)
Mutual labels:  uikit, uiimage
Cardkit
iOS 11 cards in Swift
Stars: ✭ 47 (-62.4%)
Mutual labels:  ios11, uikit
Elepy
Elepy, The Headless Content Management Framework
Stars: ✭ 109 (-12.8%)
Mutual labels:  uikit
Distancepicker
Custom UIKit control to select a distance with a pan gesture, written in Swift
Stars: ✭ 118 (-5.6%)
Mutual labels:  uikit
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+8464.8%)
Mutual labels:  uikit
Ios11 Pdfkit Example
Sample code for PDFKit on iOS 11.
Stars: ✭ 105 (-16%)
Mutual labels:  ios11
Awesome Tca
Awesome list for The Composable Architecture
Stars: ✭ 124 (-0.8%)
Mutual labels:  uikit
Gskstretchyheaderview
A generic stretchy header for UITableView and UICollectionView
Stars: ✭ 1,624 (+1199.2%)
Mutual labels:  uikit
Arplayer
Playback videos using ARKit and AVFoundation.
Stars: ✭ 117 (-6.4%)
Mutual labels:  ios11
Uikit React
UIkit components built with React
Stars: ✭ 111 (-11.2%)
Mutual labels:  uikit
Movieflex ios
iOS application for Movie / Actor information with clean / intuitive UI and MVVM architecture.
Stars: ✭ 119 (-4.8%)
Mutual labels:  uikit
Exermote
Using Machine Learning to predict the type of exercise from movement data
Stars: ✭ 108 (-13.6%)
Mutual labels:  ios11
Arkit Unity3d
Access ARKit features like world-tracking, live video rendering, plane estimation and updates, hit-testing API, ambient light estimation, and raw point cloud data.
Stars: ✭ 124 (-0.8%)
Mutual labels:  ios11
Aiolos
A floating panel for your iOS Apps
Stars: ✭ 1,544 (+1135.2%)
Mutual labels:  uikit
Vue Notus
Vue Notus: Free Tailwind CSS UI Kit and Admin
Stars: ✭ 108 (-13.6%)
Mutual labels:  uikit
Arkit Floorislava
Basic ARKit example that detects planes and makes them lava.
Stars: ✭ 120 (-4%)
Mutual labels:  ios11
Whatsnew
Showcase new features after an app update similar to Pages, Numbers and Keynote.
Stars: ✭ 1,512 (+1109.6%)
Mutual labels:  ios11

UIImageHEIC

Apple introduced widespread HEIC support with iOS 11, but the APIs for it are somewhat low level. This tiny project adds a familiar interface for encoding UIImages into HEIC data similar to what we're used to doing with JPEG or PNG data.

Installation

Add the UIImage+HEIC.h and UIImage+HEIC.m source files to your project. At the moment you must be using Xcode 9 / building with the iOS 11 SDK to use this.

Usage

Converting UIImages to HEIC

This adds a function named tj_UIImageHEICRepresentation that behaves just like UIImageJPEGRepresentation. The method returns nil in the event that HEIC encoding isn't possible on the current device.

So, where you used to have

UIImage *image = /**/;
NSData *imageData = UIImageJPEGRepresentation(image, 0.8);

You could now have

UIImage *image = /**/;
NSData *imageData = tj_UIImageHEICRepresentation(image, 0.8);
if (imageData.length == 0) {
    imageData = UIImageJPEGRepresentation(image, 0.8);
}

UIGraphicsImageRenderer Extensions

This project also adds a category to UIGraphicsImageRenderer for HEIC exporting support with fallbacks to PNG or JPEG. It's used just like you use UIGraphicsImageRenderer's existing PNG and JPEG exporting methods.

Before

UIGraphicsImageRenderer *renderer = /**/;
NSData *data = [renderer PNGDataWithActions:/**/];

After with no fallback

UIGraphicsImageRenderer *renderer = /**/;
NSData *data = [renderer tj_HEICDataWithCompressionQuality:1.0 actions:/**/];

After falling back to PNG

UIGraphicsImageRenderer *renderer = /**/;
NSData *data = [renderer tj_HEICDataFallingBackToPNGDataWithCompressionQuality:1.0 actions:/**/];

After falling back to JPEG

UIGraphicsImageRenderer *renderer = /**/;
NSData *data = [renderer tj_HEICDataWithCompressionQuality:1.0 fallingBackToJPEGDataWithCompressionQuality:1.0 actions:/**/];

Checking HEIC images

You can check if the image at a particular path is a HEIC image using tj_isImageAtPathHEIC on devices that support HEIC reading.

BOOL isHEICImage = tj_isImageAtPathHEIC(/*path to an image*/);

For lower level access you can also use tj_CGImageSourceUTIIsHEIC, which allows you to check using an image source made from data or a URL, and is also helpful if you want to immediately use the image source to perform a transformation in the event it is HEIC.

BOOL isHEICImageSource = tj_CGImageSourceUTIIsHEIC(/*image source*);
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].