• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Objective-C
  • Created about 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A category to simplify common PHAsset functions.

PHAsset+Utility

A category to simplify common PHAsset functions.


Photos Permission

Note: This class assumes that you've already obtained permission from the user like so:
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
    // copacetic...
}];

Looking for a solution for user permission prompting? Check out this framework:

#####VWWPermissionKit


About this category

/*!
 @method        saveToAlbum:completionBlock
 @description   Save a copy of a PHAsset to a photo album. Will create the album if it doesn't exist.
 @param         title                  The title of the album.
 @param         completionBlock        This block is passed a BOOL for success.  This parameter may be nil.
 */
-(void)saveToAlbum:(NSString*)title completionBlock:(PHAssetBoolBlock)completionBlock;

/*!
 @method        updateLocation:creationDate:completionBlock
 @description   Update the location and date of an existing asset
 @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations.
 @param         creationDate           An NSDate to be written to the PHAsset.
 @param         completionBlock        This block is passed the PHAsset updated with location/date (if applied) and BOOL for success. This parameter may be nil.
 */
-(void)updateLocation:(CLLocation*)location creationDate:(NSDate*)creationDate completionBlock:(PHAssetBoolBlock)completionBlock;

/*!
 @method        saveImageToCameraRoll:location:completionBlock
 @description   Save an image to camera roll with optional completion (returns PHAsset in completion block)
 @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
 @param         creationDate           An NSDate to be written to the PHAsset.
 @param         completionBlock        Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
 */
+(void)saveImageToCameraRoll:(UIImage*)image location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;

/*!
 @method        saveVideoAtURL:location:completionBlock
 @description   Save a video to camera roll with optional completion (returns PHAsset in completion block)
 @param         location               A CLLocation object to be written to the PHAsset. See CoreLocation framework for obtaining locations. This parameter may be nil.
 @param         creationDate           An NSDate to be written to the PHAsset.
 @param         completionBlock        Returns the PHAsset which was written and BOOL for success. This parameter may be nil.
 */
+(void)saveVideoAtURL:(NSURL*)url location:(CLLocation*)location completionBlock:(PHAssetAssetBoolBlock)completionBlock;

/*!
 @method        requestMetadataWithCompletionBlock
 @description   Get metadata dictionary of an asset (the kind with {Exif}, {GPS}, etc...
 @param         completionBlock        This block is passed a dictionary of metadata properties. See ImageIO framework for parsing/reading these. This parameter may be nil.
 */
-(void)requestMetadataWithCompletionBlock:(PHAssetMetadataBlock)completionBlock;

Metadata

The metatdata dictionary returned from requestMetadataWithCompletionBlock will have subdictionaries broken into logical categories. Use Apple's ImageIO framework for parsing.

{
    ColorModel = RGB;
    DPIHeight = 72;
    DPIWidth = 72;
    Depth = 8;
    Orientation = 1;
    PixelHeight = 2448;
    PixelWidth = 3264;
    ProfileName = "sRGB IEC61966-2.1";
    "{Exif}" =     {
        ApertureValue = "2.52606882168926";
        BrightnessValue = "1.660732196589769";
        ColorSpace = 1;
        ComponentsConfiguration =         (
                                           1,
                                           2,
                                           3,
                                           0
                                           );
        CustomRendered = 2;
        DateTimeDigitized = "2012:10:26 19:34:05";
        DateTimeOriginal = "2012:10:26 19:34:05";
        ExifVersion =         (
                               2,
                               2,
                               1
                               );
        ExposureMode = 0;
        ExposureProgram = 2;
        ExposureTime = "0.05";
        FNumber = "2.4";
        Flash = 0;
        FlashPixVersion =         (
                                   1,
                                   0
                                   );
        FocalLenIn35mmFilm = 33;
        FocalLength = "4.13";
        ISOSpeedRatings =         (
                                   160
                                   );
        MeteringMode = 5;
        PixelXDimension = 3264;
        PixelYDimension = 2448;
        SceneCaptureType = 0;
        SensingMethod = 2;
        ShutterSpeedValue = "4.321956769055745";
        WhiteBalance = 0;
    };
    "{GPS}" =     {
        Altitude = "28.28625472887768";
        AltitudeRef = 0;
        DateStamp = "2012:10:26";
        ImgDirection = "142.1425389755011";
        ImgDirectionRef = T;
        Latitude = "37.79883333333333";
        LatitudeRef = N;
        Longitude = "122.4598333333333";
        LongitudeRef = W;
        TimeStamp = "02:34:05";
    };
    "{TIFF}" =     {
        DateTime = "2012:10:26 19:34:05";
        Make = Apple;
        Model = "iPhone 5";
        Orientation = 1;
        ResolutionUnit = 2;
        Software = "6.0";
        XResolution = 72;
        YResolution = 72;
    };
}

More Repositories

1

VWWPermissionKit

A visual permission manager for iOS
Objective-C
143
star
2

CURLLog

Print a curl version of your NSURLSession or NSURLRequest to the console for easy copy/paste debugging
Objective-C
19
star
3

ColorPicKit

A collection of UIControls for picking colors on iPhone, iPad, and other iOS devices. Gradient slider, Hue slider, RGB sliders, HSB sliders, CMYK sliders, ImagePixelPicker, HSB Wheel, HSB Spectrum. Color related class extensions
Swift
16
star
4

AVAssetWriter

A sample app that will take images and create a movie using AVAssetWriter.
Objective-C
14
star
5

MetadataOSX

A basic exif / metadata editor for OSX Yosemite
Objective-C
13
star
6

Theremin_v1

iOS app that renders sine, square, traingle, and sawtooth waves. Change pitch and volume with motion controls.
Objective-C
9
star
7

Synthesizer

An objective-c framework to easily produce audio tones (square, sine, etc) with varying frequency, amplitude, mute, autotune, etc...
Objective-C
8
star
8

Quadrilateral

C++
5
star
9

PhotoKit

A metadata editor for your iOS photos.
5
star
10

FFT

Perform FFT on an audio file sample. Print the output.
Objective-C
4
star
11

TreeTest

OSX outline view example
Objective-C
3
star
12

StopDrinking

Swift
3
star
13

CandySorter

An iOS app that uses BLE to drive an Arduino powered candy sorting machine.
Objective-C
3
star
14

LocationLogger

Messing around with using significant location changes and launching the app
Objective-C
2
star
15

SwiftyCurl

Generate curl commands from URLRequest or curl reports from URLSessionTask
Swift
2
star
16

Apophis

An augmented reality image capture app
Objective-C
2
star
17

XcodeSnippets

A bash script which configures xcode to use iCloud Drive to store CodeSnippets
2
star
18

RCVideo

An iOS app for recording video on radio control vehicles. It will render GPS location, motion sensor information, and more.
Objective-C
2
star
19

SpriteKit_Custom_Shaders

Swift
2
star
20

EventBrite

Objective-C
2
star
21

Rubix

Rubix cube implementation on iOS using OpenGLES 2.0 and GLKit
Objective-C
2
star
22

KeyCodes

A list of key codes for NSEvent.keyCode. Think of this as the phantom "NSKeyCodes"
Swift
2
star
23

ColorBlind

iOS app that demos many different iOS programming topics
Objective-C
2
star
24

FunctionGenerator

A few swift function to generate sine, square, triangle, and sawtooth waves
Swift
2
star
25

ZHUtilities

Objective-C
1
star
26

PhotoGeoTagger

A cocoa app for OSX which helps you add geolocation data to folders full of photos
Objective-C
1
star
27

Flare

Generate flare.json from objective-c source on using OSX
Objective-C
1
star
28

CoreAnimatorDriver

An app to display core animator projects
Swift
1
star
29

RCToolsVideo

Record video while rendering HUD, location, distance from home, top speed, etc...
Objective-C
1
star
30

GameOfLife

Conway's game of life
Objective-C
1
star
31

BusSnooze

Objective-C
1
star
32

VWWLED

Open an image and send pixels to LED matrix
Objective-C
1
star
33

LoadingImages

A seres of images for iOS loading screens
1
star
34

Superpowers

Objective-C
1
star
35

Uploader

Asset scanner and uploader
Objective-C
1
star
36

VWWMapLegendView

An interactive legend intended for use over an MKMapView
Objective-C
1
star
37

FilterTest

A GPUImage filter showcase derivative. Added precision sliders, parameter names, and a camera type function
Objective-C
1
star
38

TVOSGame

Cursor based views for UIKit and SpriteKit
Objective-C
1
star
39

BLETennis

An iOS app that powers a tennis ball pitching machine via bluetooth / arduino.
Objective-C
1
star
40

SimpleGLKit

Messing around with GLKit
Objective-C
1
star
41

TabbedAnimations

Objective-C
1
star
42

Armstrong

Swift
1
star