Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sendable support & Add init function #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Sources/.DS_Store
Binary file not shown.
Binary file added Sources/SwiftyImageIO/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum ColorSpace: Int, Codable, Hashable {
enum ColorSpace: Int, Codable, Hashable, Sendable {
case sRGB = 0x1
case adobeRGB = 0x2
case wideGamutRGB = 0xfffd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum CompositeImageType: Int, Codable, Hashable {
enum CompositeImageType: Int, Codable, Hashable, Sendable {
case unknown = 0
case notCompositeImage = 1
case generalCompositeImage = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum ContrastDirection: Int, Codable, Hashable {
enum ContrastDirection: Int, Codable, Hashable, Sendable {
case normal = 0
case soft = 1
case hard = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum CustomRenderedType: Int, Codable, Hashable {
enum CustomRenderedType: Int, Codable, Hashable, Sendable {
// MARK: - standard Exif
case normal = 0
case custom = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum ExposureMode: Int, Codable, Hashable {
enum ExposureMode: Int, Codable, Hashable, Sendable {
case autoExposure = 0
case manualExposure = 1
case autoBracket = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum ExposureProgram: Int, Codable, Hashable {
enum ExposureProgram: Int, Codable, Hashable, Sendable {
case notDefined = 0
case manual = 1
case normalProgram = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum FileSourceType: Int, Codable, Hashable {
enum FileSourceType: Int, Codable, Hashable, Sendable {
case filmScanner = 1
case reflectionPrintScanner = 2
case digitalCamera = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum FlashMode: Int, Codable, Hashable {
enum FlashMode: Int, Codable, Hashable, Sendable {
case noFlash = 0x0
case fired = 0x1
case firedReturnNotDetected = 0x5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum GainControl: Int, Codable, Hashable {
enum GainControl: Int, Codable, Hashable, Sendable {
case none = 0
case lowGainUp = 1
case highGainUp = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum LightSourceType: Int, Codable, Hashable {
enum LightSourceType: Int, Codable, Hashable, Sendable {
case unknown = 0
case daylight = 1
case fluorescent = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum MeteringMode: Int, Codable, Hashable {
enum MeteringMode: Int, Codable, Hashable, Sendable {
case unknown = 0
case average = 1
case centerWeightedAverage = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum PixelFormatType: Int, Codable {
enum PixelFormatType: Int, Codable, Sendable {
case blackWhite = 0x5

case _8BitGray = 0x8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum ResolutionUnit: Int, Codable, Hashable {
enum ResolutionUnit: Int, Codable, Hashable, Sendable {
case none = 1
case inches = 2
case cm = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SaturationDirection: Int, Codable, Hashable {
enum SaturationDirection: Int, Codable, Hashable, Sendable {
case normal = 0
case lowSaturation = 1
case highSaturation = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SceneCaptureType: Int, Codable, Hashable {
enum SceneCaptureType: Int, Codable, Hashable, Sendable {
case standard = 0
case landscape = 1
case portrait = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SensingMethod: Int, Codable, Hashable {
enum SensingMethod: Int, Codable, Hashable, Sendable {
case notDefined = 1
case oneChipColorAreaSensor = 2
case twoChipColorAreaSensor = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SensitivityType: Int, Codable, Hashable {
enum SensitivityType: Int, Codable, Hashable, Sendable {
case unknown = 0
case standardOutputSensitivity = 1
case recommendedExposureIndex = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SharpnessDirection: Int, Codable, Hashable {
enum SharpnessDirection: Int, Codable, Hashable, Sendable {
case normal = 0
case soft = 1
case hard = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum SubjectDistanceRangeType: Int, Codable, Hashable {
enum SubjectDistanceRangeType: Int, Codable, Hashable, Sendable {
case unknown = 0
case macro = 1
case closeView = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension ExifProperty {
enum WhiteBalanceMode: Int, Codable, Hashable {
enum WhiteBalanceMode: Int, Codable, Hashable, Sendable {
case autoWhiteBalance = 0
case manualWhiteBalance = 1
}
Expand Down
85 changes: 82 additions & 3 deletions Sources/SwiftyImageIO/CodableEntities/Exif/ExifProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
//
//

import AnyCodable
@preconcurrency import AnyCodable
import Foundation
import ImageIO

/// Exchangeable Image File Format (EXIF) data.
public struct ExifProperty: Codable, Equatable, Hashable {
public struct ExifProperty: Codable, Equatable, Hashable, Sendable {
// MARK: - Camera Settings

/// For a particular camera mode, indicates the conditions for taking the picture.
Expand All @@ -36,7 +36,7 @@ public struct ExifProperty: Codable, Equatable, Hashable {
public var spectralSensitivity: Double?

/// The ISO speed ratings.
public var isoSpeedRatings: [AnyCodable]?
public var isoSpeedRatings: [Int]?

/// The distance to the subject, in meters.
public var subjectDistance: Double?
Expand Down Expand Up @@ -253,4 +253,83 @@ public struct ExifProperty: Codable, Equatable, Hashable {

/// The EXIF version.
public var exifVersion: [Int]?

init?(dictionary: Any?) {
guard let dictionary = dictionary as? [String : Any] else { return nil }
self.deviceSettingDescription = dictionary[""] as? AnyCodable
self.fNumber = dictionary[kCGImagePropertyExifFNumber as String] as? Double
self.shutterSpeedValue = dictionary[kCGImagePropertyExifShutterSpeedValue as String] as? Double
self.apertureValue = dictionary[kCGImagePropertyExifApertureValue as String] as? Double
self.maxApertureValue = dictionary[kCGImagePropertyExifMaxApertureValue as String] as? Double
self.focalLength = dictionary[kCGImagePropertyExifFocalLength as String] as? Double
self.spectralSensitivity = dictionary[kCGImagePropertyExifSpectralSensitivity as String] as? Double
self.isoSpeedRatings = dictionary[kCGImagePropertyExifISOSpeedRatings as String] as? [Int]
self.subjectDistance = dictionary[kCGImagePropertyExifSubjectDistance as String] as? Double
self.meteringMode = dictionary[kCGImagePropertyExifMeteringMode as String] as? MeteringMode
self.subjectArea = dictionary[kCGImagePropertyExifSubjectArea as String] as? AnyCodable
self.subjectLocation = dictionary[kCGImagePropertyExifSubjectLocation as String] as? AnyCodable
self.sensingMethod = dictionary[kCGImagePropertyExifSensingMethod as String] as? SensingMethod
self.sceneType = dictionary[kCGImagePropertyExifSceneType as String] as? Int
self.digitalZoomRatio = dictionary[kCGImagePropertyExifDigitalZoomRatio as String] as? Double
self.focalLengthIn35mmFilm = dictionary[kCGImagePropertyExifFocalLenIn35mmFilm as String] as? Double
self.sceneCaptureType = dictionary[kCGImagePropertyExifSceneCaptureType as String] as? SceneCaptureType
self.subjectDistanceRange = dictionary[kCGImagePropertyExifSubjectDistRange as String] as? SubjectDistanceRangeType
self.exposureTime = dictionary[kCGImagePropertyExifExposureTime as String] as? TimeInterval
self.exposureProgram = dictionary[kCGImagePropertyExifExposureProgram as String] as? ExposureProgram
self.exposureIndex = dictionary[kCGImagePropertyExifExposureIndex as String] as? Int
self.exposureMode = dictionary[kCGImagePropertyExifExposureMode as String] as? ExposureMode
self.isoSpeed = dictionary[kCGImagePropertyExifISOSpeed as String] as? AnyCodable
self.isoSpeedLatitudeYYY = dictionary[kCGImagePropertyExifISOSpeedLatitudeyyy as String] as? AnyCodable
self.isoSpeedLatitudeZZZ = dictionary[kCGImagePropertyExifISOSpeedLatitudezzz as String] as? AnyCodable
self.recommendedExposureIndex = dictionary[kCGImagePropertyExifRecommendedExposureIndex as String] as? Int
self.exposureBiasValue = dictionary[kCGImagePropertyExifExposureBiasValue as String] as? Double
self.sensitivityType = dictionary[kCGImagePropertyExifSensitivityType as String] as? SensitivityType
self.standardOutputSensitivity = dictionary[kCGImagePropertyExifStandardOutputSensitivity as String] as? UInt
self.sourceExposureTimesOfCompositeImage = dictionary[kCGImagePropertyExifSourceExposureTimesOfCompositeImage as String] as? AnyCodable
self.cfaPattern = dictionary[kCGImagePropertyExifCFAPattern as String] as? AnyCodable
self.brightnessValue = dictionary[kCGImagePropertyExifBrightnessValue as String] as? Double
self.lightSource = dictionary[kCGImagePropertyExifLightSource as String] as? LightSourceType
self.flash = dictionary[kCGImagePropertyExifFlash as String] as? FlashMode
self.spatialFrequencyResponse = dictionary[kCGImagePropertyExifSpatialFrequencyResponse as String] as? String
self.contrast = dictionary[kCGImagePropertyExifContrast as String] as? ContrastDirection
self.saturation = dictionary[kCGImagePropertyExifSaturation as String] as? SaturationDirection
self.sharpness = dictionary[kCGImagePropertyExifSharpness as String] as? SharpnessDirection
self.gamma = dictionary[kCGImagePropertyExifGamma as String] as? GammaCoefficient
self.whiteBalance = dictionary[kCGImagePropertyExifWhiteBalance as String] as? WhiteBalanceMode
self.gainControl = dictionary[kCGImagePropertyExifGainControl as String] as? GainControl
self.imageUniqueId = dictionary[kCGImagePropertyExifImageUniqueID as String] as? String
self.compressedBitsPerPixel = dictionary[kCGImagePropertyExifCompressedBitsPerPixel as String] as? Double
self.colorSpace = dictionary[kCGImagePropertyExifColorSpace as String] as? ColorSpace
self.pixelXDimension = dictionary[kCGImagePropertyExifPixelXDimension as String] as? UInt
self.pixelYDimension = dictionary[kCGImagePropertyExifPixelYDimension as String] as? UInt
self.relatedSoundFile = dictionary[kCGImagePropertyExifRelatedSoundFile as String] as? String
self.focalPlaneXResolution = dictionary[kCGImagePropertyExifFocalPlaneXResolution as String] as? Double
self.focalPlaneYResolution = dictionary[kCGImagePropertyExifFocalPlaneYResolution as String] as? Double
self.focalPlaneResolutionUnit = dictionary[kCGImagePropertyExifFocalPlaneResolutionUnit as String] as? ResolutionUnit
self.customRendered = dictionary[kCGImagePropertyExifCustomRendered as String] as? CustomRenderedType
self.compositeImage = dictionary[kCGImagePropertyExifCompositeImage as String] as? CompositeImageType
self.oecf = dictionary[kCGImagePropertyExifOECF as String] as? AnyCodable
self.componentsConfiguration = dictionary[kCGImagePropertyExifComponentsConfiguration as String] as? [Int]
self.sourceImageNumberOfCompositeImage = dictionary[kCGImagePropertyExifSourceImageNumberOfCompositeImage as String] as? [Int]
self.fileSource = dictionary[kCGImagePropertyExifFileSource as String] as? FileSourceType
self.dateTimeOriginal = dictionary[kCGImagePropertyExifDateTimeOriginal as String] as? Date
self.dateTimeDigitized = dictionary[kCGImagePropertyExifDateTimeDigitized as String] as? Date
self.subsecTime = dictionary[kCGImagePropertyExifSubsecTime as String] as? String
self.subsecTimeOriginal = dictionary[kCGImagePropertyExifSubsecTimeOriginal as String] as? String
self.subsecTimeDigitized = dictionary[kCGImagePropertyExifSubsecTimeDigitized as String] as? String
self.offsetTime = dictionary[kCGImagePropertyExifOffsetTime as String] as? String
self.offsetTimeOriginal = dictionary[kCGImagePropertyExifOffsetTimeOriginal as String] as? String
self.offsetTimeDigitized = dictionary[kCGImagePropertyExifOffsetTimeDigitized as String] as? String
self.lensSpecification = dictionary[kCGImagePropertyExifLensSpecification as String] as? [Double]
self.lensMake = dictionary[kCGImagePropertyExifLensMake as String] as? String
self.lensModel = dictionary[kCGImagePropertyExifLensModel as String] as? String
self.lensSerialNumber = dictionary[kCGImagePropertyExifLensSerialNumber as String] as? String
self.makerNote = dictionary[kCGImagePropertyExifMakerNote as String] as? AnyCodable
self.userComment = dictionary[kCGImagePropertyExifUserComment as String] as? String
self.cameraOwnerName = dictionary[kCGImagePropertyExifCameraOwnerName as String] as? String
self.bodySerialNumber = dictionary[kCGImagePropertyExifBodySerialNumber as String] as? String
self.flashpixVersion = dictionary[kCGImagePropertyExifFlashPixVersion as String] as? [Int]
self.flashEnergy = dictionary[kCGImagePropertyExifFlashEnergy as String] as? Int
self.exifVersion = dictionary[kCGImagePropertyExifVersion as String] as? [Int]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum AltitudeRef: UInt8, Codable {
enum AltitudeRef: UInt8, Codable, Sendable {
case aboveSeaLevel = 0
case belowSeaLevel = 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum BearingRef: String, Codable {
enum BearingRef: String, Codable, Sendable {
case magneticNorth = "M"
case trueNorth = "T"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum Differential: UInt16, Codable {
enum Differential: UInt16, Codable, Sendable {
case noCorrection = 0
case corrected = 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum DirectionRef: String, Codable {
enum DirectionRef: String, Codable, Sendable {
case magneticNorth = "M"
case trueNorth = "T"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum DistanceLengthUnit: String, Codable {
enum DistanceLengthUnit: String, Codable, Sendable {
case kilometers = "K"
case miles = "M"
case nauticalMiles = "N"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum LatitudeRef: String, Codable {
enum LatitudeRef: String, Codable, Sendable{
case north = "N"
case south = "S"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum LongitudeRef: String, Codable {
enum LongitudeRef: String, Codable, Sendable {
case east = "E"
case west = "W"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum MeasureMode: Int, Codable {
enum MeasureMode: Int, Codable, Sendable {
case twoDimensionalMeasurement = 2
case threeDimensionalMeasurement = 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum SpeedUnit: String, Codable {
enum SpeedUnit: String, Codable, Sendable {
case kilometerPerHour = "K"
case milePerHour = "M"
case knots = "N"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum Status: String, Codable {
enum Status: String, Codable, Sendable {
case measurementActive = "A"
case measurementVoid = "V"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

public extension GPSProperty {
enum TrackRef: String, Codable {
enum TrackRef: String, Codable, Sendable {
case magneticNorth = "M"
case trueNorth = "T"
}
Expand Down
Loading