FLTImagePickerMetaDataUtil.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2013 The Flutter Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #import <Foundation/Foundation.h>
  5. #import <UIKit/UIKit.h>
  6. NS_ASSUME_NONNULL_BEGIN
  7. typedef enum : NSUInteger {
  8. FLTImagePickerMIMETypePNG,
  9. FLTImagePickerMIMETypeJPEG,
  10. FLTImagePickerMIMETypeGIF,
  11. FLTImagePickerMIMETypeOther,
  12. } FLTImagePickerMIMEType;
  13. extern NSString *const kFLTImagePickerDefaultSuffix;
  14. extern const FLTImagePickerMIMEType kFLTImagePickerMIMETypeDefault;
  15. @interface FLTImagePickerMetaDataUtil : NSObject
  16. // Retrieve MIME type by reading the image data. We currently only support some popular types.
  17. + (FLTImagePickerMIMEType)getImageMIMETypeFromImageData:(NSData *)imageData;
  18. // Get corresponding surfix from type.
  19. + (nullable NSString *)imageTypeSuffixFromType:(FLTImagePickerMIMEType)type;
  20. + (NSDictionary *)getMetaDataFromImageData:(NSData *)imageData;
  21. + (NSData *)updateMetaData:(NSDictionary *)metaData toImage:(NSData *)imageData;
  22. // Converting UIImage to a NSData with the type proveide.
  23. //
  24. // The quality is for JPEG type only, it defaults to 1. It throws exception if setting a non-nil
  25. // quality with type other than FLTImagePickerMIMETypeJPEG. Converting UIImage to
  26. // FLTImagePickerMIMETypeGIF or FLTImagePickerMIMETypeTIFF is not supported in iOS. This
  27. // method throws exception if trying to do so.
  28. + (nonnull NSData *)convertImage:(nonnull UIImage *)image
  29. usingType:(FLTImagePickerMIMEType)type
  30. quality:(nullable NSNumber *)quality;
  31. @end
  32. NS_ASSUME_NONNULL_END