├── .github └── workflows │ └── build.yml ├── .gitignore ├── .spi.yml ├── .swiftpm └── xcode │ └── package.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Demo └── CIFilterFactory_Demo │ ├── CIFilterFactory ObjectiveC Test │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ ├── AppIcon-512@2x.png │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ └── MainMenu.xib │ ├── CIFilterFactory_ObjectiveC_Test.entitlements │ ├── Info.plist │ └── main.m │ ├── CIFilterFactory Swift iOS Test │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── Contents.json │ │ └── grumpy-cat.imageset │ │ │ ├── Contents.json │ │ │ └── Domestic_cat_mean_face.jpg │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── CIFilterFactory Swift iOS Test.entitlements │ ├── Info.plist │ ├── SceneDelegate.swift │ └── ViewController.swift │ ├── CIFilterFactory Swift tvOS Test │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── App Icon & Top Shelf Image.brandassets │ │ │ ├── App Icon - App Store.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── App Icon.imagestack │ │ │ │ ├── Back.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ ├── Contents.json │ │ │ │ ├── Front.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ │ └── Middle.imagestacklayer │ │ │ │ │ ├── Content.imageset │ │ │ │ │ └── Contents.json │ │ │ │ │ └── Contents.json │ │ │ ├── Contents.json │ │ │ ├── Top Shelf Image Wide.imageset │ │ │ │ └── Contents.json │ │ │ └── Top Shelf Image.imageset │ │ │ │ └── Contents.json │ │ ├── AppIcon.imageset │ │ │ ├── AppIcon-512@2x.png │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── ViewController.swift │ └── CIFilterFactory Tests.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── LICENSE ├── Package.swift ├── README.md ├── Sources └── CIFilterFactory │ ├── CIFilterFactory+Types.swift │ ├── CIFilterFactory.swift │ ├── CIImage+extensions.swift │ ├── CIVector+extensions.swift │ ├── PrivacyInfo.xcprivacy │ ├── extensions │ └── QRCodeGenerator+extensions.swift │ ├── generated │ ├── AccordionFoldTransition.swift │ ├── AdditionCompositing.swift │ ├── AffineClamp.swift │ ├── AffineTile.swift │ ├── AffineTransform.swift │ ├── AreaAlphaWeightedHistogram.swift │ ├── AreaAverage.swift │ ├── AreaBoundsRed.swift │ ├── AreaHistogram.swift │ ├── AreaLogarithmicHistogram.swift │ ├── AreaMaximum.swift │ ├── AreaMaximumAlpha.swift │ ├── AreaMinMax.swift │ ├── AreaMinMaxRed.swift │ ├── AreaMinimum.swift │ ├── AreaMinimumAlpha.swift │ ├── AttributedTextImageGenerator.swift │ ├── AztecCodeGenerator.swift │ ├── BarcodeGenerator.swift │ ├── BarsSwipeTransition.swift │ ├── BicubicScaleTransform.swift │ ├── BlendWithAlphaMask.swift │ ├── BlendWithBlueMask.swift │ ├── BlendWithMask.swift │ ├── BlendWithRedMask.swift │ ├── Bloom.swift │ ├── BlurredRectangleGenerator.swift │ ├── BokehBlur.swift │ ├── BoxBlur.swift │ ├── BumpDistortion.swift │ ├── BumpDistortionLinear.swift │ ├── CMYKHalftone.swift │ ├── CameraCalibrationLensCorrection.swift │ ├── CannyEdgeDetector.swift │ ├── CheckerboardGenerator.swift │ ├── CircleSplashDistortion.swift │ ├── CircularScreen.swift │ ├── CircularWrap.swift │ ├── Clamp.swift │ ├── Code128BarcodeGenerator.swift │ ├── ColorAbsoluteDifference.swift │ ├── ColorBlendMode.swift │ ├── ColorBurnBlendMode.swift │ ├── ColorClamp.swift │ ├── ColorControls.swift │ ├── ColorCrossPolynomial.swift │ ├── ColorCube.swift │ ├── ColorCubeWithColorSpace.swift │ ├── ColorCubesMixedWithMask.swift │ ├── ColorCurves.swift │ ├── ColorDodgeBlendMode.swift │ ├── ColorInvert.swift │ ├── ColorMap.swift │ ├── ColorMatrix.swift │ ├── ColorMonochrome.swift │ ├── ColorPolynomial.swift │ ├── ColorPosterize.swift │ ├── ColorThreshold.swift │ ├── ColorThresholdOtsu.swift │ ├── ColumnAverage.swift │ ├── ComicEffect.swift │ ├── ConstantColorGenerator.swift │ ├── ConvertLabToRGB.swift │ ├── ConvertRGBtoLab.swift │ ├── Convolution3X3.swift │ ├── Convolution5X5.swift │ ├── Convolution7X7.swift │ ├── Convolution9Horizontal.swift │ ├── Convolution9Vertical.swift │ ├── ConvolutionRGB3X3.swift │ ├── ConvolutionRGB5X5.swift │ ├── ConvolutionRGB7X7.swift │ ├── ConvolutionRGB9Horizontal.swift │ ├── ConvolutionRGB9Vertical.swift │ ├── CopyMachineTransition.swift │ ├── CoreMLModelFilter.swift │ ├── Crop.swift │ ├── Crystallize.swift │ ├── DarkenBlendMode.swift │ ├── DepthBlurEffect.swift │ ├── DepthOfField.swift │ ├── DepthToDisparity.swift │ ├── DifferenceBlendMode.swift │ ├── DiscBlur.swift │ ├── DisintegrateWithMaskTransition.swift │ ├── DisparityToDepth.swift │ ├── DisplacementDistortion.swift │ ├── DissolveTransition.swift │ ├── DistanceGradientFromRedMask.swift │ ├── Dither.swift │ ├── DivideBlendMode.swift │ ├── DocumentEnhancer.swift │ ├── DotScreen.swift │ ├── Droste.swift │ ├── EdgePreserveUpsampleFilter.swift │ ├── EdgeWork.swift │ ├── Edges.swift │ ├── EightfoldReflectedTile.swift │ ├── ExclusionBlendMode.swift │ ├── ExposureAdjust.swift │ ├── FalseColor.swift │ ├── FlashTransition.swift │ ├── FourfoldReflectedTile.swift │ ├── FourfoldRotatedTile.swift │ ├── FourfoldTranslatedTile.swift │ ├── GaborGradients.swift │ ├── GammaAdjust.swift │ ├── GaussianBlur.swift │ ├── GaussianGradient.swift │ ├── GlassDistortion.swift │ ├── GlassLozenge.swift │ ├── GlideReflectedTile.swift │ ├── Gloom.swift │ ├── GuidedFilter.swift │ ├── HardLightBlendMode.swift │ ├── HatchedScreen.swift │ ├── HeightFieldFromMask.swift │ ├── HexagonalPixellate.swift │ ├── HighlightShadowAdjust.swift │ ├── HistogramDisplayFilter.swift │ ├── HoleDistortion.swift │ ├── HueAdjust.swift │ ├── HueBlendMode.swift │ ├── HueSaturationValueGradient.swift │ ├── KMeans.swift │ ├── Kaleidoscope.swift │ ├── KeystoneCorrectionCombined.swift │ ├── KeystoneCorrectionHorizontal.swift │ ├── KeystoneCorrectionVertical.swift │ ├── LabDeltaE.swift │ ├── LanczosScaleTransform.swift │ ├── LenticularHaloGenerator.swift │ ├── LightTunnel.swift │ ├── LightenBlendMode.swift │ ├── LineOverlay.swift │ ├── LineScreen.swift │ ├── LinearBurnBlendMode.swift │ ├── LinearDodgeBlendMode.swift │ ├── LinearGradient.swift │ ├── LinearLightBlendMode.swift │ ├── LinearToSRGBToneCurve.swift │ ├── LuminosityBlendMode.swift │ ├── MaskToAlpha.swift │ ├── MaskedVariableBlur.swift │ ├── MaximumComponent.swift │ ├── MaximumCompositing.swift │ ├── MaximumScaleTransform.swift │ ├── MedianFilter.swift │ ├── MeshGenerator.swift │ ├── MinimumComponent.swift │ ├── MinimumCompositing.swift │ ├── Mix.swift │ ├── ModTransition.swift │ ├── MorphologyGradient.swift │ ├── MorphologyMaximum.swift │ ├── MorphologyMinimum.swift │ ├── MorphologyRectangleMaximum.swift │ ├── MorphologyRectangleMinimum.swift │ ├── MotionBlur.swift │ ├── MultiplyBlendMode.swift │ ├── MultiplyCompositing.swift │ ├── NinePartStretched.swift │ ├── NinePartTiled.swift │ ├── NoiseReduction.swift │ ├── OpTile.swift │ ├── OverlayBlendMode.swift │ ├── PDF417BarcodeGenerator.swift │ ├── PageCurlTransition.swift │ ├── PageCurlWithShadowTransition.swift │ ├── PaletteCentroid.swift │ ├── Palettize.swift │ ├── ParallelogramTile.swift │ ├── PersonSegmentation.swift │ ├── PerspectiveCorrection.swift │ ├── PerspectiveRotate.swift │ ├── PerspectiveTile.swift │ ├── PerspectiveTransform.swift │ ├── PerspectiveTransformWithExtent.swift │ ├── PhotoEffectChrome.swift │ ├── PhotoEffectFade.swift │ ├── PhotoEffectInstant.swift │ ├── PhotoEffectMono.swift │ ├── PhotoEffectNoir.swift │ ├── PhotoEffectProcess.swift │ ├── PhotoEffectTonal.swift │ ├── PhotoEffectTransfer.swift │ ├── PinLightBlendMode.swift │ ├── PinchDistortion.swift │ ├── Pixellate.swift │ ├── Pointillize.swift │ ├── QRCodeGenerator.swift │ ├── RadialGradient.swift │ ├── RandomGenerator.swift │ ├── RippleTransition.swift │ ├── RoundedRectangleGenerator.swift │ ├── RoundedRectangleStrokeGenerator.swift │ ├── RowAverage.swift │ ├── SRGBToneCurveToLinear.swift │ ├── SaliencyMapFilter.swift │ ├── SampleNearest.swift │ ├── SaturationBlendMode.swift │ ├── ScreenBlendMode.swift │ ├── SepiaTone.swift │ ├── ShadedMaterial.swift │ ├── SharpenLuminance.swift │ ├── SixfoldReflectedTile.swift │ ├── SixfoldRotatedTile.swift │ ├── SmoothLinearGradient.swift │ ├── SobelGradients.swift │ ├── SoftLightBlendMode.swift │ ├── SourceAtopCompositing.swift │ ├── SourceInCompositing.swift │ ├── SourceOutCompositing.swift │ ├── SourceOverCompositing.swift │ ├── SpotColor.swift │ ├── SpotLight.swift │ ├── StarShineGenerator.swift │ ├── StraightenFilter.swift │ ├── StretchCrop.swift │ ├── StripesGenerator.swift │ ├── SubtractBlendMode.swift │ ├── SunbeamsGenerator.swift │ ├── SwipeTransition.swift │ ├── TemperatureAndTint.swift │ ├── TextImageGenerator.swift │ ├── Thermal.swift │ ├── ToneCurve.swift │ ├── ToneMapHeadroom.swift │ ├── TorusLensDistortion.swift │ ├── TriangleKaleidoscope.swift │ ├── TriangleTile.swift │ ├── TwelvefoldReflectedTile.swift │ ├── TwirlDistortion.swift │ ├── UnsharpMask.swift │ ├── Vibrance.swift │ ├── Vignette.swift │ ├── VignetteEffect.swift │ ├── VividLightBlendMode.swift │ ├── VortexDistortion.swift │ ├── WhitePointAdjust.swift │ ├── XRay.swift │ └── ZoomBlur.swift │ └── private │ ├── CIFF+Logger.swift │ ├── CIFilterFactory+ValueHandling.swift │ ├── Clamping.swift │ └── Dictionary+extensions.swift ├── Tests └── CIFilterFactoryTests │ ├── CIFilterFactoryTests.swift │ ├── XCTestManifests.swift │ └── resources │ ├── sydney.jpg │ └── test.jpg └── Tools ├── generator ├── ciff_generator.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── ciff_generator.xcscheme └── ciff_generator │ ├── AdditionalOutputKeyMap.swift │ ├── FileSquirter.swift │ ├── FilterGenerator.swift │ ├── InputKeyType.swift │ ├── KeyTypes.swift │ ├── String+extensions.swift │ ├── generator.swift │ └── main.swift ├── make-docs.sh └── regenerate.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Swift 2 | 3 | on: [push] 4 | 5 | jobs: 6 | macos_tests: 7 | name: Build on latest macOS 8 | runs-on: macos-latest 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Build 12 | run: swift build 13 | - name: Run tests 14 | run: swift test 15 | 16 | ios_tests: 17 | name: Build on iOS 18 | runs-on: macos-latest 19 | steps: 20 | - uses: actions/checkout@v4 21 | - name: Run tests on iOS 22 | run: xcodebuild -scheme CIFilterFactory build -destination "platform=iOS Simulator,name=iPhone SE (3rd generation),OS=latest" 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | .swiftpm/xcode/xcshareddata 7 | Demo/CIFilterFactory_Demo/CIFilterFactory Tests.xcodeproj/project.xcworkspace/xcshareddata 8 | CIFilterFactory ObjectiveC Test.xcscheme 9 | ._* 10 | CIFilterFactory.doccarchive 11 | IDEWorkspaceChecks.plist 12 | .docgeneratortemp 13 | -------------------------------------------------------------------------------- /.spi.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | builder: 3 | configs: 4 | - scheme: CIFilterFactory 5 | documentation_targets: [CIFilterFactory] 6 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // CIFilterFactory ObjectiveC Test 4 | // 5 | // Created by Darren Ford on 9/7/20. 6 | // Copyright © 2024 Darren Ford. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // CIFilterFactory ObjectiveC Test 4 | // 5 | // Created by Darren Ford on 9/7/20. 6 | // Copyright © 2024 Darren Ford. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @import CIFilterFactory; 12 | @import CoreImage; 13 | 14 | @interface AppDelegate () 15 | 16 | @property (strong) IBOutlet NSWindow *window; 17 | @property (weak) IBOutlet NSImageView *imageView; 18 | 19 | @end 20 | 21 | @implementation AppDelegate 22 | 23 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 24 | // Insert code here to initialize your application 25 | 26 | [self basicTesting]; 27 | 28 | 29 | id appimage = [NSImage imageNamed:NSImageNameApplicationIcon]; 30 | id bir = [[NSBitmapImageRep alloc] initWithData:[appimage TIFFRepresentation]]; 31 | id image = [[CIImage alloc] initWithBitmapImageRep:bir]; 32 | assert(image); 33 | 34 | // Sepia filter 35 | CIFFSepiaTone* sepiaFilter = [[CIFFSepiaTone alloc] initWithInputImage:nil 36 | intensity:1.0]; 37 | assert(sepiaFilter); 38 | 39 | CIFFCrystallize* crystalize = [[CIFFCrystallize alloc] initWithInputImage:nil 40 | radius:20 41 | center:CGPointMake(150, 200)]; 42 | assert(crystalize); 43 | 44 | // Create the output image by chaining the filters 45 | CIImage* output = [image applying:@[sepiaFilter, crystalize]]; 46 | 47 | // CIImage* output = [crystalize outputImage]; 48 | struct CGImage* out = [[CIContext context] createCGImage:output fromRect:[output extent]]; 49 | 50 | id outputImage = [[NSImage alloc] initWithCGImage:out size:[output extent].size]; 51 | [[self imageView] setImage:outputImage]; 52 | 53 | CGPoint c = [crystalize center]; 54 | assert(c.x == 150); 55 | assert(c.y == 200); 56 | } 57 | 58 | 59 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 60 | // Insert code here to tear down your application 61 | } 62 | 63 | // Some basic tests 64 | 65 | - (void)basicTesting { 66 | 67 | id appimage = [NSImage imageNamed:NSImageNameApplicationIcon]; 68 | id bir = [[NSBitmapImageRep alloc] initWithData:[appimage TIFFRepresentation]]; 69 | id image = [[CIImage alloc] initWithBitmapImageRep:bir]; 70 | assert(image); 71 | 72 | { 73 | // Simple QR Code generator example using native NSString and NSData 74 | CIFFQRCodeGenerator *filter = [[CIFFQRCodeGenerator alloc] init]; 75 | [filter setCorrectionLevel:@"H"]; 76 | [filter setMessage: [@"Hello" dataUsingEncoding:NSUTF8StringEncoding]]; 77 | CIImage* output = [filter outputImage]; 78 | struct CGImage* out = [[CIContext context] createCGImage:output fromRect:[output extent]]; 79 | NSImage *im = [[NSImage alloc] initWithCGImage:out size:NSZeroSize]; 80 | assert(im != nil); 81 | 82 | CGImageRef r = [filter outputCGImage]; 83 | assert(r != nil); 84 | } 85 | 86 | { 87 | CIFFBokehBlur* bb = [[CIFFBokehBlur alloc] init]; 88 | bb.ringAmount = 14.4; 89 | assert([bb ringAmount] == 1); // clamped 90 | 91 | bb.ringAmount = 0.5; 92 | assert([bb ringAmount] == 0.5); 93 | } 94 | 95 | { 96 | CIFFBloom* filter = [[CIFFBloom alloc] init]; 97 | [filter setInputImage:image]; 98 | [filter setRadius:10]; 99 | [filter setIntensity:4.45]; 100 | CIImage* output = [filter outputImage]; 101 | assert(output != nil); 102 | 103 | if (@available(macOS 10.15, *)) { 104 | CIFFKMeans* f = [[CIFFKMeans alloc] init]; 105 | [f setPerceptual: YES]; 106 | assert([f perceptual] == YES); 107 | [f setPerceptual: NO]; 108 | assert([f perceptual] == NO); 109 | } 110 | } 111 | 112 | if (@available(macOS 10.15, *)) { 113 | CIFFKeystoneCorrectionHorizontal *filter = [[CIFFKeystoneCorrectionHorizontal alloc] init]; 114 | 115 | filter.inputImage = image; 116 | CIImage* out = filter.outputImage; 117 | assert(out != nil); 118 | } 119 | 120 | { 121 | CIFFGloom* f = [[CIFFGloom alloc] initWithInputImage:image radius:5 intensity:1]; 122 | assert([f radius] == 5); 123 | assert([f intensity] == 1); 124 | 125 | // This should clamp to 0 126 | f.intensity = -10; 127 | assert([f intensity] == 0); 128 | } 129 | 130 | { 131 | CIFFTextImageGenerator* filter = [[CIFFTextImageGenerator alloc] init]; 132 | [filter setText:@"Noodle"]; 133 | CIImage* output = [filter outputImage]; 134 | assert(output); 135 | struct CGImage* out = [[CIContext context] createCGImage:output fromRect:[output extent]]; 136 | id outputImage = [[NSImage alloc] initWithCGImage:out size:[output extent].size]; 137 | assert(outputImage); 138 | 139 | NSString* storedValue = [filter text]; 140 | assert([storedValue isEqual:@"Noodle"]); 141 | } 142 | 143 | 144 | } 145 | 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dagronf/CIFilterFactory/0612970c16dd042afe5aaef68e1e65322f7426a3/Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x", 6 | "size" : "16x16" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "1x", 16 | "size" : "32x32" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "2x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "1x", 26 | "size" : "128x128" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "2x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "1x", 36 | "size" : "256x256" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "2x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "1x", 46 | "size" : "512x512" 47 | }, 48 | { 49 | "filename" : "AppIcon-512@2x.png", 50 | "idiom" : "mac", 51 | "scale" : "2x", 52 | "size" : "512x512" 53 | } 54 | ], 55 | "info" : { 56 | "author" : "xcode", 57 | "version" : 1 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/CIFilterFactory_ObjectiveC_Test.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2024 Darren Ford. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory ObjectiveC Test/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CIFilterFactory ObjectiveC Test 4 | // 5 | // Created by Darren Ford on 9/7/20. 6 | // Copyright © 2024 Darren Ford. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | @autoreleasepool { 13 | // Setup code that might create autoreleased objects goes here. 14 | } 15 | return NSApplicationMain(argc, argv); 16 | } 17 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CIFilterFactory Swift iOS Test 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/grumpy-cat.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "Domestic_cat_mean_face.jpg", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/grumpy-cat.imageset/Domestic_cat_mean_face.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dagronf/CIFilterFactory/0612970c16dd042afe5aaef68e1e65322f7426a3/Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Assets.xcassets/grumpy-cat.imageset/Domestic_cat_mean_face.jpg -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/CIFilterFactory Swift iOS Test.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.network.client 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // CIFilterFactory Swift iOS Test 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift iOS Test/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CIFilterFactory Swift iOS Test 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import UIKit 9 | import CIFilterFactory 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var image: UIImageView! 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | // Do any additional setup after loading the view. 17 | 18 | let image = UIImage(named: "grumpy-cat")! 19 | 20 | let filter = CIFF.CircularScreen()! 21 | filter.inputImage = CIImage(image: image) 22 | let output = filter.outputImage! 23 | 24 | self.image.image = UIImage(ciImage: output) 25 | } 26 | 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CIFilterFactory Swift tvOS Test 4 | // 5 | // Created by Darren Ford on 9/7/20. 6 | // Copyright © 2024 Darren Ford. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import CIFilterFactory 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | 18 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 19 | // Override point for customization after application launch. 20 | basicTests() 21 | return true 22 | } 23 | 24 | func applicationWillResignActive(_ application: UIApplication) { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 27 | } 28 | 29 | func applicationDidEnterBackground(_ application: UIApplication) { 30 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 31 | } 32 | 33 | func applicationWillEnterForeground(_ application: UIApplication) { 34 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | func applicationDidBecomeActive(_ application: UIApplication) { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | func basicTests() { 42 | 43 | let appimage = UIImage(named: "AppIcon")! 44 | let image = CIImage(cgImage: appimage.cgImage!) 45 | 46 | do { 47 | let filter = CIFF.QRCodeGenerator()! 48 | filter.message = "Hello".data(using: .utf8)! 49 | filter.correction = .H 50 | let output = filter.outputImage! 51 | let uiImage = UIImage(ciImage: output) 52 | Swift.print(uiImage) 53 | 54 | let cgImage = filter.outputCGImage 55 | let c = cgImage!.takeUnretainedValue() 56 | Swift.print(c) 57 | let uiImage2 = UIImage(cgImage: c) 58 | Swift.print(uiImage2) 59 | 60 | let origString = String(data: filter.message!, encoding: .utf8) 61 | assert(origString == "Hello") 62 | } 63 | 64 | do { 65 | guard let bloomFilter = CIFF.Bloom() else { fatalError() } 66 | bloomFilter.inputImage = image 67 | bloomFilter.intensity = 0.3 68 | bloomFilter.radius = 5 69 | let outputImage = bloomFilter.outputImage 70 | assert(outputImage != nil) 71 | } 72 | 73 | do { 74 | guard let textFilter = CIFF.TextImageGenerator() else { fatalError() } 75 | textFilter.text = "Noodle" 76 | assert(textFilter.text == "Noodle") 77 | 78 | let output = textFilter.outputImage! 79 | let uiImage = UIImage(ciImage: output) 80 | Swift.print(uiImage) 81 | } 82 | } 83 | 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | }, 6 | "layers" : [ 7 | { 8 | "filename" : "Front.imagestacklayer" 9 | }, 10 | { 11 | "filename" : "Middle.imagestacklayer" 12 | }, 13 | { 14 | "filename" : "Back.imagestacklayer" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - App Store.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "tv", 9 | "scale" : "2x" 10 | } 11 | ], 12 | "info" : { 13 | "author" : "xcode", 14 | "version" : 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Back.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | }, 6 | "layers" : [ 7 | { 8 | "filename" : "Front.imagestacklayer" 9 | }, 10 | { 11 | "filename" : "Middle.imagestacklayer" 12 | }, 13 | { 14 | "filename" : "Back.imagestacklayer" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "tv", 9 | "scale" : "2x" 10 | } 11 | ], 12 | "info" : { 13 | "author" : "xcode", 14 | "version" : 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Front.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "tv", 9 | "scale" : "2x" 10 | } 11 | ], 12 | "info" : { 13 | "author" : "xcode", 14 | "version" : 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon.imagestack/Middle.imagestacklayer/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "assets" : [ 3 | { 4 | "filename" : "App Icon - App Store.imagestack", 5 | "idiom" : "tv", 6 | "role" : "primary-app-icon", 7 | "size" : "1280x768" 8 | }, 9 | { 10 | "filename" : "App Icon.imagestack", 11 | "idiom" : "tv", 12 | "role" : "primary-app-icon", 13 | "size" : "400x240" 14 | }, 15 | { 16 | "filename" : "Top Shelf Image Wide.imageset", 17 | "idiom" : "tv", 18 | "role" : "top-shelf-image-wide", 19 | "size" : "2320x720" 20 | }, 21 | { 22 | "filename" : "Top Shelf Image.imageset", 23 | "idiom" : "tv", 24 | "role" : "top-shelf-image", 25 | "size" : "1920x720" 26 | } 27 | ], 28 | "info" : { 29 | "author" : "xcode", 30 | "version" : 1 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "tv", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "tv-marketing", 13 | "scale" : "1x" 14 | }, 15 | { 16 | "idiom" : "tv-marketing", 17 | "scale" : "2x" 18 | } 19 | ], 20 | "info" : { 21 | "author" : "xcode", 22 | "version" : 1 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "tv", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "tv", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "tv-marketing", 13 | "scale" : "1x" 14 | }, 15 | { 16 | "idiom" : "tv-marketing", 17 | "scale" : "2x" 18 | } 19 | ], 20 | "info" : { 21 | "author" : "xcode", 22 | "version" : 1 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/AppIcon.imageset/AppIcon-512@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dagronf/CIFilterFactory/0612970c16dd042afe5aaef68e1e65322f7426a3/Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/AppIcon.imageset/AppIcon-512@2x.png -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/AppIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "filename" : "AppIcon-512@2x.png", 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | arm64 30 | 31 | UIUserInterfaceStyle 32 | Automatic 33 | 34 | 35 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Swift tvOS Test/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CIFilterFactory Swift tvOS Test 4 | // 5 | // Created by Darren Ford on 9/7/20. 6 | // Copyright © 2024 Darren Ford. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import CIFilterFactory 12 | 13 | import CoreImage.CIFilterBuiltins 14 | 15 | class ViewController: UIViewController { 16 | 17 | @IBOutlet weak var imageView: UIImageView! 18 | override func viewDidLoad() { 19 | super.viewDidLoad() 20 | // Do any additional setup after loading the view. 21 | } 22 | 23 | override func viewDidAppear(_ animated: Bool) { 24 | super.viewDidAppear(animated) 25 | 26 | let appimage = UIImage(named: "AppIcon")! 27 | let image = CIImage(cgImage: appimage.cgImage!) 28 | 29 | // Use the chaining API to apply the filters 30 | let sepiaFilter = CIFF.SepiaTone(intensity: 0.9)! 31 | let crystalize = CIFF.Crystallize(radius: 20, center: CGPoint(x: 150, y: 200))! 32 | let output = image.applying([sepiaFilter, crystalize]) 33 | let outputImage = UIImage(ciImage: output) 34 | 35 | // Use the functional interface 36 | // let output = image 37 | // .applyingSepiaTone(intensity: 0.9) 38 | // .applyingCrystallize(radius: 20, center: CGPoint(x: 150, y: 200)) 39 | // let outputImage = UIImage(ciImage: output) 40 | 41 | self.imageView.image = outputImage 42 | 43 | /// Just a simple check 44 | assert(crystalize.radius == 20) 45 | assert(crystalize.center.x == 150) 46 | assert(crystalize.center.y == 200) 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Demo/CIFilterFactory_Demo/CIFilterFactory Tests.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Darren Ford 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.4 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "CIFilterFactory", 7 | platforms: [ 8 | .iOS(.v9), 9 | //.macCatalyst(.v13), // uncomment for swift-tools 5.5 and above 10 | .macOS(.v10_10), 11 | .tvOS(.v11), 12 | ], 13 | products: [ 14 | // Products define the executables and libraries a package produces, and make them visible to other packages. 15 | .library(name: "CIFilterFactory", targets: ["CIFilterFactory"]), 16 | .library(name: "CIFilterFactory-static", type: .static, targets: ["CIFilterFactory"]), 17 | .library(name: "CIFilterFactory-shared", type: .dynamic, targets: ["CIFilterFactory"]), 18 | ], 19 | targets: [ 20 | .target( 21 | name: "CIFilterFactory", 22 | resources: [ 23 | .copy("PrivacyInfo.xcprivacy"), 24 | ]), 25 | .testTarget( 26 | name: "CIFilterFactoryTests", 27 | dependencies: ["CIFilterFactory"], 28 | resources: [ 29 | .process("resources"), 30 | ]) 31 | ] 32 | ) 33 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/CIFilterFactory+Types.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIFilterFactory+Types.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import Foundation 25 | import CoreImage 26 | 27 | #if !os(macOS) 28 | // For access to NSValue.cgAffineTransformValue 29 | import UIKit 30 | #endif 31 | 32 | public extension CIFF { 33 | 34 | /// A wrapped AffineTransform class to abstract away affine transform differences per platform 35 | @objc(CIFFCIAffineTransform) class CIAffineTransform: NSObject { 36 | 37 | static func Create(m11: CGFloat, m12: CGFloat, m21: CGFloat, m22: CGFloat, tX: CGFloat, tY: CGFloat) -> CIAffineTransform { 38 | #if os(macOS) 39 | return CIAffineTransform( 40 | NSAffineTransform(transform: Foundation.AffineTransform(m11: m11, m12: m12, m21: m21, m22: m22, tX: tX, tY: tY))) 41 | #else 42 | return CIAffineTransform(CGAffineTransform(a: m11, b: m12, c: m21, d: m22, tx: tX, ty: tY)) 43 | #endif 44 | } 45 | 46 | #if os(macOS) 47 | @objc var transform: NSAffineTransform 48 | 49 | @objc public init(m11: CGFloat, m12: CGFloat, m21: CGFloat, m22: CGFloat, tX: CGFloat, tY: CGFloat) { 50 | self.transform = NSAffineTransform(transform: Foundation.AffineTransform(m11: m11, m12: m12, m21: m21, m22: m22, tX: tX, tY: tY)) 51 | super.init() 52 | } 53 | 54 | @objc public init(_ transform: NSAffineTransform) { 55 | self.transform = transform 56 | super.init() 57 | } 58 | 59 | @objc public convenience init?(filter: CIFilter, key: String) { 60 | guard let value = filter.value(forKey: key) as? NSAffineTransform else { 61 | return nil 62 | } 63 | self.init(value) 64 | } 65 | 66 | func embeddedValue() -> AnyObject { 67 | return self.transform 68 | } 69 | #else 70 | @objc var transform: CGAffineTransform 71 | 72 | @objc public init(m11: CGFloat, m12: CGFloat, m21: CGFloat, m22: CGFloat, tX: CGFloat, tY: CGFloat) { 73 | self.transform = CGAffineTransform(a: m11, b: m12, c: m21, d: m22, tx: tX, ty: tY) 74 | super.init() 75 | } 76 | 77 | @objc public init(_ transform: CGAffineTransform) { 78 | self.transform = transform 79 | super.init() 80 | } 81 | 82 | @objc public convenience init?(filter: CIFilter, key: String) { 83 | guard let value = filter.value(forKey: key) as? NSValue else { 84 | return nil 85 | } 86 | self.init(value.cgAffineTransformValue) 87 | } 88 | 89 | func embeddedValue() -> AnyObject { 90 | return NSValue(cgAffineTransform: self.transform) 91 | } 92 | #endif 93 | } 94 | } 95 | 96 | extension CGPoint { 97 | /// Convert this CGPoint value to a CIVector 98 | @inline(__always) internal var ciVector: CIVector { return CIVector(cgPoint: self) } 99 | } 100 | 101 | extension CGRect { 102 | /// Convert this CGRect value to a CIVector 103 | @inline(__always) internal var ciVector: CIVector { return CIVector(cgRect: self) } 104 | } 105 | 106 | public extension CIFF { 107 | /// A three-dimensional location in the working coordinate space. (A 3-element vector type.) 108 | /// 109 | /// A wrapper for a `CIAttributeTypePosition3` type. 110 | /// 111 | /// See: [CIAttributeTypePosition3](https://developer.apple.com/documentation/coreimage/kciattributetypeposition3) 112 | @objc(CIFFCIPosition3) class CIPosition3: NSObject { 113 | /// The x value 114 | @objc public let x: CGFloat 115 | /// The y value 116 | @objc public let y: CGFloat 117 | /// The z value 118 | @objc public let z: CGFloat 119 | 120 | /// A CIVector representation of this object 121 | @objc lazy public var ciVector: CIVector = { 122 | CIVector(values: [self.x, self.y, self.z], count: 3) 123 | }() 124 | 125 | /// Create a CIPosition3 value from x, y and z values 126 | @objc public init(x: CGFloat, y: CGFloat, z: CGFloat) { 127 | self.x = x 128 | self.y = y 129 | self.z = z 130 | super.init() 131 | } 132 | 133 | /// Create a CIPosition3 value from the contents of a CIVector 134 | /// 135 | /// Returns nil if :- 136 | /// * The passed vector is nil, or 137 | /// * The passed vector does not contain exactly three values 138 | @objc public init?(_ vector: CIVector?) { 139 | guard let v = vector, v.count == 3 else { return nil } 140 | self.x = v.value(at: 0) 141 | self.y = v.value(at: 1) 142 | self.z = v.value(at: 2) 143 | super.init() 144 | } 145 | } 146 | } 147 | 148 | #endif // canImport(CoreImage) 149 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/CIImage+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIImage+extensions.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 7 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 8 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 9 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all copies or substantial 12 | // portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 15 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 16 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | // 19 | 20 | #if canImport(CoreImage) 21 | 22 | import Foundation 23 | import CoreImage 24 | 25 | public extension CIImage { 26 | /// Apply the provided chain of filters to this image, returning the filtered image. 27 | /// 28 | /// See: **Chaining Filters for Complex Effects** in the [Core Image Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_tasks/ci_tasks.html). 29 | @objc func applying(_ filters: [CIFF.Core]) -> CIImage { 30 | var outputImage: CIImage = self 31 | filters.forEach { filter in 32 | let parameters = filter.inputParameters.removingValue(forKey: "inputImage") 33 | outputImage = outputImage.applyingFilter(filter.name, parameters: parameters) 34 | } 35 | return outputImage 36 | } 37 | } 38 | 39 | public extension CIImage { 40 | /// Generate a CGImage representation of this CIImage 41 | /// - Parameters: 42 | /// - context: The context to use, or nil to use a default context 43 | /// - size: The size of the resulting CGImage, or nil to use the CIImage extent 44 | /// - Returns: The image 45 | func asCGImage(context: CIContext? = nil, size: CGSize? = nil) -> CGImage? { 46 | let context = context ?? CIContext(options: nil) 47 | let rect: CGRect 48 | if let size = size { 49 | rect = CGRect(origin: .zero, size: size) 50 | } 51 | else { 52 | rect = self.extent 53 | if rect.width > 20000 || rect.height > 20000 { 54 | return nil 55 | } 56 | } 57 | return context.createCGImage(self, from: rect) 58 | } 59 | } 60 | 61 | #if os(macOS) 62 | import AppKit 63 | #else 64 | import UIKit 65 | #endif 66 | 67 | public extension CIImage { 68 | #if os(macOS) 69 | @inlinable func nsImage() -> NSImage { 70 | let rep = NSCIImageRep(ciImage: self) 71 | guard rep.size.width <= 10000, rep.size.height <= 10000 else { return NSImage() } 72 | let nsImage = NSImage(size: rep.size) 73 | nsImage.addRepresentation(rep) 74 | return nsImage 75 | } 76 | #else 77 | @inlinable func uiImage() -> UIImage { UIImage(ciImage: self) } 78 | #endif 79 | } 80 | 81 | public enum CIFFScaling: Int { 82 | case aspectFit = 0 83 | case aspectFill = 1 84 | case fill = 2 85 | } 86 | 87 | public extension CIImage { 88 | /// Save the extent and then re-crop to that extent after applying whatever is in the closure 89 | func recropping(apply: (CIImage) -> CIImage) -> CIImage { 90 | let savedExtent: CGRect = extent 91 | let newCIImage = apply(self) 92 | let cropped = newCIImage.cropped(to: savedExtent) 93 | return cropped 94 | } 95 | 96 | // func scaling(to targetSize: CGSize, _ method: CIFFScaling, isActive: Bool = true) -> CIImage { 97 | // guard isActive else { return self } 98 | // let currentSize = extent.size 99 | // 100 | // if method == .aspectFit { 101 | // let smallerRatio: CGFloat = min(targetSize.width / currentSize.width, targetSize.height / currentSize.height) 102 | // let newSize: CGSize = CGSize(width: currentSize.width * smallerRatio, height: currentSize.height * smallerRatio) 103 | // 104 | // return self.applyingLanczosScaleTransform(scale: smallerRatio) 105 | //// .clampedToExtent() 106 | // .cropped(to: CGRect(origin: .zero, size: targetSize)) 107 | //// .cropped(to: CGRect( 108 | //// x: (newSize.width - targetSize.width) / 2, 109 | //// y: (newSize.height - targetSize.height) / 2, 110 | //// width: targetSize.width.rounded(.towardZero), 111 | //// height: targetSize.height.rounded(.towardZero)) 112 | //// ) 113 | // } 114 | // else if method == .aspectFill { 115 | // let largerRatio: CGFloat = max(targetSize.width / currentSize.width, targetSize.height / currentSize.height) 116 | // let newSize: CGSize = CGSize(width: currentSize.width * largerRatio, height: currentSize.height * largerRatio) 117 | // return self.applyingLanczosScaleTransform(scale: largerRatio) 118 | // .clampedToExtent() 119 | // .cropped(to: CGRect( 120 | // x: (newSize.width - targetSize.width) / 2, 121 | // y: (newSize.height - targetSize.height) / 2, 122 | // width: targetSize.width.rounded(.towardZero), 123 | // height: targetSize.height.rounded(.towardZero)) 124 | // ) 125 | // } 126 | // else { 127 | // // Compute scale and corrective aspect ratio 128 | // let scale = targetSize.height / (currentSize.height) 129 | // let aspectRatio = targetSize.width / (currentSize.width * scale) 130 | // return self.applyingLanczosScaleTransform(scale: scale, aspectRatio: aspectRatio) 131 | // .clampedToExtent() 132 | // .cropped(to: CGRect(origin: .zero, size: targetSize)) 133 | // } 134 | // } 135 | } 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/CIVector+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIVector+extensions.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if !os(watchOS) 23 | 24 | import Foundation 25 | import CoreImage.CIVector 26 | 27 | extension CIVector { 28 | /// A convenience for creating CIVector objects 29 | @inlinable @inline(__always) public convenience init(values: CGFloat...) { 30 | self.init(values: values, count: values.count) 31 | } 32 | 33 | /// A convenience for creating CIVector objects 34 | @inlinable @inline(__always) public convenience init(values: [CGFloat]) { 35 | self.init(values: values, count: values.count) 36 | } 37 | 38 | /// Returns the vector values as an array 39 | @inlinable @inline(__always) public var allValues: [CGFloat] { 40 | (0 ..< self.count).lazy.map { self.value(at: $0) } 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/PrivacyInfo.xcprivacy: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSPrivacyAccessedAPITypes 6 | 7 | NSPrivacyCollectedDataTypes 8 | 9 | NSPrivacyTracking 10 | 11 | NSPrivacyTrackingDomains 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/extensions/QRCodeGenerator+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QRCodeGenerator+extensions.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import Foundation 25 | import CoreImage 26 | 27 | /// Extension to the QR code filter to have type-safe correction levels 28 | @available(macOS 10.10, iOS 8, tvOS 8, *) 29 | public extension CIFF.QRCodeGenerator { 30 | /// QR Code correction levels 31 | enum Level: String, CaseIterable { 32 | /// Low level correction (up to 7% error correction capability) 33 | case L 34 | /// Medium level correction (up to 15% error correction capability) 35 | case M 36 | /// Quantize level correction (up to 25% error correction capability) 37 | case Q 38 | /// High level correction (up to 30% error correction capability) 39 | case H 40 | /// The default correction level 41 | public static var `default`: Level { .M } 42 | } 43 | 44 | /// The QR Code correction level. 45 | /// 46 | /// A convenience property for the `correctionLevel` property providing type safety for the correction level types. 47 | @inlinable var correction: Level { 48 | get { 49 | guard let v = self.correctionLevel, let level = Level(rawValue: v) else { 50 | return .default 51 | } 52 | return level 53 | } 54 | set { self.correctionLevel = newValue.rawValue } 55 | } 56 | 57 | /// Create a QRCode with a specific utf8 text. Returns nil if the text cannot be converted to utf8 58 | /// - Parameters: 59 | /// - text: The UTF8 encodable message 60 | /// - correction: The correction level (default .high) 61 | @inlinable convenience init?(text: String, correction: Level = .H) { 62 | guard let data = text.data(using: .utf8) else { return nil } 63 | self.init(message: data, correctionLevel: correction.rawValue) 64 | } 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/BarcodeGenerator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BarcodeGenerator.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Barcode Generator 31 | /// 32 | /// Generate a barcode image from a CIBarcodeDescriptor. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIBarcodeGenerator 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.13, iOS 11, tvOS 11 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - Generator (*CICategoryGenerator*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CIBarcodeGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIBarcodeGenerator) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cibarcodegenerator) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CIBarcodeGenerator/) 50 | /// **Additional output keys** 51 | /// - outputCGImageForQRCodeDescriptor 52 | /// - outputCGImageForAztecCodeDescriptor 53 | /// - outputCGImageForPDF417CodeDescriptor 54 | /// - outputCGImageForDataMatrixCodeDescriptor 55 | /// - outputCGImage 56 | /// 57 | @available(macOS 10.13, iOS 11, tvOS 11, *) 58 | @objc(CIFFBarcodeGenerator) class BarcodeGenerator: Core { 59 | /// Create an instance of the filter with all default values 60 | @objc public init?() { 61 | super.init(name: "CIBarcodeGenerator") 62 | } 63 | 64 | // MARK: - barcodeDescriptor (inputBarcodeDescriptor) 65 | 66 | /// The CIBarcodeDescription object to generate an image for. 67 | /// 68 | /// CIFilter attribute information 69 | /// - Attribute key: `inputBarcodeDescriptor` 70 | /// - Internal class: `CIBarcodeDescriptor` 71 | @objc public var barcodeDescriptor: CIBarcodeDescriptor? { 72 | get { 73 | self.keyedValue("inputBarcodeDescriptor") 74 | } 75 | set { 76 | self.setKeyedValue(newValue, for: "inputBarcodeDescriptor") 77 | } 78 | } 79 | 80 | // MARK: - Additional output keys 81 | 82 | @objc public var outputCGImage: Unmanaged? { 83 | let value = self.filter.perform(#selector(getter: AdditionalOutputsFilterDescriptor.outputCGImage)) 84 | if let obj = value?.takeUnretainedValue() { 85 | return Unmanaged.passUnretained(obj as! CGImage) 86 | } 87 | return nil 88 | } 89 | 90 | // A hidden class for extracting any additional output objects 91 | private final class AdditionalOutputsFilterDescriptor: NSObject { 92 | @objc var outputCGImage: Unmanaged? 93 | } 94 | 95 | // MARK: - Convenience creators 96 | 97 | /// Filter initializer 98 | /// - Parameters: 99 | /// - barcodeDescriptor: The CIBarcodeDescription object to generate an image for. 100 | @objc public convenience init?( 101 | barcodeDescriptor: CIBarcodeDescriptor 102 | ) { 103 | self.init() 104 | self.barcodeDescriptor = barcodeDescriptor 105 | } 106 | } 107 | } 108 | 109 | @available(macOS 10.13, iOS 11, tvOS 11, *) 110 | public extension CIImage { 111 | /// Create a new CIImage using the 'Barcode Generator' filter 112 | /// 113 | /// - Parameters: 114 | /// - barcodeDescriptor: The CIBarcodeDescription object to generate an image for. 115 | /// - Returns: A new image by running the filter, or nil if the image could not be created 116 | /// 117 | /// Generate a barcode image from a CIBarcodeDescriptor. 118 | /// 119 | /// **Categories**: BuiltIn, Generator, StillImage, Video 120 | /// 121 | /// **Documentation Links** 122 | /// - [CIBarcodeGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIBarcodeGenerator) 123 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cibarcodegenerator) 124 | /// - [CIFilter.app documentation](https://cifilter.app/CIBarcodeGenerator/) 125 | @inlinable static func createUsingBarcodeGenerator( 126 | barcodeDescriptor: CIBarcodeDescriptor 127 | ) -> CIImage? { 128 | return CIFF.BarcodeGenerator( 129 | barcodeDescriptor: barcodeDescriptor 130 | )?.outputImage 131 | } 132 | } 133 | 134 | #endif // canImport(CoreImage) 135 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/ColorInvert.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorInvert.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Color Invert 31 | /// 32 | /// Inverts the colors in an image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIColorInvert 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 5, tvOS 5 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CIColorInvert Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorInvert) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolorinvert) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorInvert/) 53 | @available(macOS 10.4, iOS 5, tvOS 5, *) 54 | @objc(CIFFColorInvert) class ColorInvert: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CIColorInvert") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to use as an input for the effect. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - Convenience creators 78 | 79 | /// Filter initializer 80 | /// - Parameters: 81 | /// - inputImage: The image to use as an input for the effect. 82 | @objc public convenience init?( 83 | inputImage: CIImage? = nil 84 | ) { 85 | self.init() 86 | if let inputImage = inputImage { 87 | self.inputImage = inputImage 88 | } 89 | } 90 | } 91 | } 92 | 93 | @available(macOS 10.4, iOS 5, tvOS 5, *) 94 | public extension CIImage { 95 | /// Apply the 'Color Invert' filter to this image and return a new filtered image 96 | /// 97 | /// - Parameters: 98 | /// - isActive: If true applies the filter and returns a new image, else returns this image 99 | /// - Returns: The filtered image, or this image if the filter is not active 100 | /// 101 | /// Inverts the colors in an image. 102 | /// 103 | /// **Categories**: BuiltIn, ColorEffect, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 104 | /// 105 | /// **Documentation Links** 106 | /// - [CIColorInvert Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorInvert) 107 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolorinvert) 108 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorInvert/) 109 | @inlinable func applyingColorInvert( 110 | isActive: Bool = true 111 | ) -> CIImage { 112 | guard isActive else { return self } 113 | return CIFF.ColorInvert( 114 | inputImage: self 115 | )?.outputImage ?? CIImage.empty() 116 | } 117 | } 118 | 119 | #endif // canImport(CoreImage) 120 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/ColorMap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorMap.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Color Map 31 | /// 32 | /// Performs a nonlinear transformation of source color values using mapping values provided in a table. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIColorMap 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 6, tvOS 6 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIColorMap Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorMap) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolormap) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorMap/) 52 | @available(macOS 10.4, iOS 6, tvOS 6, *) 53 | @objc(CIFFColorMap) class ColorMap: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIColorMap") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as an input for the effect. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - gradientImage (inputGradientImage) 77 | 78 | /// The image data from this image transforms the source image values. 79 | /// 80 | /// CIFilter attribute information 81 | /// - Attribute key: `inputGradientImage` 82 | /// - Internal class: `CIImage` 83 | /// - Type: `CIAttributeTypeGradient` 84 | @objc public var gradientImage: CIImage? { 85 | get { 86 | self.keyedValue("inputGradientImage") 87 | } 88 | set { 89 | self.setKeyedValue(newValue, for: "inputGradientImage") 90 | } 91 | } 92 | 93 | // MARK: - Convenience creators 94 | 95 | /// Filter initializer 96 | /// - Parameters: 97 | /// - inputImage: The image to use as an input for the effect. 98 | /// - gradientImage: The image data from this image transforms the source image values. 99 | @objc public convenience init?( 100 | inputImage: CIImage? = nil, 101 | gradientImage: CIImage? = nil 102 | ) { 103 | self.init() 104 | if let inputImage = inputImage { 105 | self.inputImage = inputImage 106 | } 107 | if let gradientImage = gradientImage { 108 | self.gradientImage = gradientImage 109 | } 110 | } 111 | } 112 | } 113 | 114 | @available(macOS 10.4, iOS 6, tvOS 6, *) 115 | public extension CIImage { 116 | /// Apply the 'Color Map' filter to this image and return a new filtered image 117 | /// 118 | /// - Parameters: 119 | /// - gradientImage: The image data from this image transforms the source image values. 120 | /// - isActive: If true applies the filter and returns a new image, else returns this image 121 | /// - Returns: The filtered image, or this image if the filter is not active 122 | /// 123 | /// Performs a nonlinear transformation of source color values using mapping values provided in a table. 124 | /// 125 | /// **Categories**: BuiltIn, ColorEffect, Interlaced, NonSquarePixels, StillImage, Video 126 | /// 127 | /// **Documentation Links** 128 | /// - [CIColorMap Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorMap) 129 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolormap) 130 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorMap/) 131 | @inlinable func applyingColorMap( 132 | gradientImage: CIImage, 133 | isActive: Bool = true 134 | ) -> CIImage { 135 | guard isActive else { return self } 136 | return CIFF.ColorMap( 137 | inputImage: self, 138 | gradientImage: gradientImage 139 | )?.outputImage ?? CIImage.empty() 140 | } 141 | } 142 | 143 | #endif // canImport(CoreImage) 144 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/ColorThresholdOtsu.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorThresholdOtsu.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Color Threshold Otsu 31 | /// 32 | /// Produces a binarized image from an image with finite extent. The threshold is calculated from the image histogram using Otsu’s method. The red, green and blue channels of the resulting image will be one if its value is greater than the threshold and zero otherwise. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIColorThresholdOtsu 36 | /// 37 | /// **Availability** 38 | /// - macOS 11.0, iOS 14, tvOS 14 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIColorThresholdOtsu Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorThresholdOtsu) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolorthresholdotsu) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorThresholdOtsu/) 52 | @available(macOS 11.0, iOS 14, tvOS 14, *) 53 | @objc(CIFFColorThresholdOtsu) class ColorThresholdOtsu: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIColorThresholdOtsu") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as an input for the effect. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - Convenience creators 77 | 78 | /// Filter initializer 79 | /// - Parameters: 80 | /// - inputImage: The image to use as an input for the effect. 81 | @objc public convenience init?( 82 | inputImage: CIImage? = nil 83 | ) { 84 | self.init() 85 | if let inputImage = inputImage { 86 | self.inputImage = inputImage 87 | } 88 | } 89 | } 90 | } 91 | 92 | @available(macOS 11.0, iOS 14, tvOS 14, *) 93 | public extension CIImage { 94 | /// Apply the 'Color Threshold Otsu' filter to this image and return a new filtered image 95 | /// 96 | /// - Parameters: 97 | /// - isActive: If true applies the filter and returns a new image, else returns this image 98 | /// - Returns: The filtered image, or this image if the filter is not active 99 | /// 100 | /// Produces a binarized image from an image with finite extent. The threshold is calculated from the image histogram using Otsu’s method. The red, green and blue channels of the resulting image will be one if its value is greater than the threshold and zero otherwise. 101 | /// 102 | /// **Categories**: BuiltIn, ColorAdjustment, Interlaced, NonSquarePixels, StillImage, Video 103 | /// 104 | /// **Documentation Links** 105 | /// - [CIColorThresholdOtsu Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIColorThresholdOtsu) 106 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicolorthresholdotsu) 107 | /// - [CIFilter.app documentation](https://cifilter.app/CIColorThresholdOtsu/) 108 | @inlinable func applyingColorThresholdOtsu( 109 | isActive: Bool = true 110 | ) -> CIImage { 111 | guard isActive else { return self } 112 | return CIFF.ColorThresholdOtsu( 113 | inputImage: self 114 | )?.outputImage ?? CIImage.empty() 115 | } 116 | } 117 | 118 | #endif // canImport(CoreImage) 119 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/ComicEffect.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ComicEffect.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Comic Effect 31 | /// 32 | /// Simulates a comic book drawing by outlining edges and applying a color halftone effect. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIComicEffect 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.5, iOS 9, tvOS 9 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - StillImage (*CICategoryStillImage*) 43 | /// - Stylize (*CICategoryStylize*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CIComicEffect Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIComicEffect) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicomiceffect) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CIComicEffect/) 50 | @available(macOS 10.5, iOS 9, tvOS 9, *) 51 | @objc(CIFFComicEffect) class ComicEffect: Core { 52 | /// Create an instance of the filter with all default values 53 | @objc public init?() { 54 | super.init(name: "CIComicEffect") 55 | } 56 | 57 | // MARK: - inputImage (inputImage) 58 | 59 | /// The image to use as an input for the effect. 60 | /// 61 | /// CIFilter attribute information 62 | /// - Attribute key: `inputImage` 63 | /// - Internal class: `CIImage` 64 | /// - Type: `CIAttributeTypeImage` 65 | @objc public var inputImage: CIImage? { 66 | get { 67 | self.keyedValue("inputImage") 68 | } 69 | set { 70 | self.setKeyedValue(newValue, for: "inputImage") 71 | } 72 | } 73 | 74 | // MARK: - Convenience creators 75 | 76 | /// Filter initializer 77 | /// - Parameters: 78 | /// - inputImage: The image to use as an input for the effect. 79 | @objc public convenience init?( 80 | inputImage: CIImage? = nil 81 | ) { 82 | self.init() 83 | if let inputImage = inputImage { 84 | self.inputImage = inputImage 85 | } 86 | } 87 | } 88 | } 89 | 90 | @available(macOS 10.5, iOS 9, tvOS 9, *) 91 | public extension CIImage { 92 | /// Apply the 'Comic Effect' filter to this image and return a new filtered image 93 | /// 94 | /// - Parameters: 95 | /// - isActive: If true applies the filter and returns a new image, else returns this image 96 | /// - Returns: The filtered image, or this image if the filter is not active 97 | /// 98 | /// Simulates a comic book drawing by outlining edges and applying a color halftone effect. 99 | /// 100 | /// **Categories**: BuiltIn, StillImage, Stylize, Video 101 | /// 102 | /// **Documentation Links** 103 | /// - [CIComicEffect Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIComicEffect) 104 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cicomiceffect) 105 | /// - [CIFilter.app documentation](https://cifilter.app/CIComicEffect/) 106 | @inlinable func applyingComicEffect( 107 | isActive: Bool = true 108 | ) -> CIImage { 109 | guard isActive else { return self } 110 | return CIFF.ComicEffect( 111 | inputImage: self 112 | )?.outputImage ?? CIImage.empty() 113 | } 114 | } 115 | 116 | #endif // canImport(CoreImage) 117 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/ConstantColorGenerator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConstantColorGenerator.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Constant Color 31 | /// 32 | /// Generates a solid color. You typically use the output of this filter as the input to another filter. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIConstantColorGenerator 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 5, tvOS 5 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - Generator (*CICategoryGenerator*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - StillImage (*CICategoryStillImage*) 45 | /// - Video (*CICategoryVideo*) 46 | /// 47 | /// **Documentation Links** 48 | /// - [CIConstantColorGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIConstantColorGenerator) 49 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciconstantcolorgenerator) 50 | /// - [CIFilter.app documentation](https://cifilter.app/CIConstantColorGenerator/) 51 | @available(macOS 10.4, iOS 5, tvOS 5, *) 52 | @objc(CIFFConstantColorGenerator) class ConstantColorGenerator: Core { 53 | /// Create an instance of the filter with all default values 54 | @objc public init?() { 55 | super.init(name: "CIConstantColorGenerator") 56 | } 57 | 58 | // MARK: - color (inputColor) 59 | 60 | /// The color to generate. 61 | /// 62 | /// CIFilter attribute information 63 | /// - Attribute key: `inputColor` 64 | /// - Internal class: `CIColor` 65 | /// - Type: `CIAttributeTypeColor` 66 | @objc public var color: CIColor? { 67 | get { 68 | self.keyedValue("inputColor") 69 | } 70 | set { 71 | self.setKeyedValue(newValue, for: "inputColor") 72 | } 73 | } 74 | 75 | // MARK: - Convenience creators 76 | 77 | /// Filter initializer 78 | /// - Parameters: 79 | /// - color: The color to generate. 80 | @objc public convenience init?( 81 | color: CIColor 82 | ) { 83 | self.init() 84 | self.color = color 85 | } 86 | } 87 | } 88 | 89 | @available(macOS 10.4, iOS 5, tvOS 5, *) 90 | public extension CIImage { 91 | /// Create a new CIImage using the 'Constant Color' filter 92 | /// 93 | /// - Parameters: 94 | /// - color: The color to generate. 95 | /// - Returns: A new image by running the filter, or nil if the image could not be created 96 | /// 97 | /// Generates a solid color. You typically use the output of this filter as the input to another filter. 98 | /// 99 | /// **Categories**: BuiltIn, Generator, HighDynamicRange, StillImage, Video 100 | /// 101 | /// **Documentation Links** 102 | /// - [CIConstantColorGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIConstantColorGenerator) 103 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciconstantcolorgenerator) 104 | /// - [CIFilter.app documentation](https://cifilter.app/CIConstantColorGenerator/) 105 | @inlinable static func createUsingConstantColorGenerator( 106 | color: CIColor 107 | ) -> CIImage? { 108 | return CIFF.ConstantColorGenerator( 109 | color: color 110 | )?.outputImage 111 | } 112 | } 113 | 114 | #endif // canImport(CoreImage) 115 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/DepthToDisparity.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DepthToDisparity.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Depth To Disparity 31 | /// 32 | /// Convert a depth data image to disparity data. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIDepthToDisparity 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.13, iOS 11, tvOS 11 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CIDepthToDisparity Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDepthToDisparity) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidepthtodisparity) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CIDepthToDisparity/) 50 | @available(macOS 10.13, iOS 11, tvOS 11, *) 51 | @objc(CIFFDepthToDisparity) class DepthToDisparity: Core { 52 | /// Create an instance of the filter with all default values 53 | @objc public init?() { 54 | super.init(name: "CIDepthToDisparity") 55 | } 56 | 57 | // MARK: - inputImage (inputImage) 58 | 59 | /// The input depth data image to convert to disparity data. 60 | /// 61 | /// CIFilter attribute information 62 | /// - Attribute key: `inputImage` 63 | /// - Internal class: `CIImage` 64 | /// - Type: `CIAttributeTypeImage` 65 | @objc public var inputImage: CIImage? { 66 | get { 67 | self.keyedValue("inputImage") 68 | } 69 | set { 70 | self.setKeyedValue(newValue, for: "inputImage") 71 | } 72 | } 73 | 74 | // MARK: - Convenience creators 75 | 76 | /// Filter initializer 77 | /// - Parameters: 78 | /// - inputImage: The input depth data image to convert to disparity data. 79 | @objc public convenience init?( 80 | inputImage: CIImage? = nil 81 | ) { 82 | self.init() 83 | if let inputImage = inputImage { 84 | self.inputImage = inputImage 85 | } 86 | } 87 | } 88 | } 89 | 90 | @available(macOS 10.13, iOS 11, tvOS 11, *) 91 | public extension CIImage { 92 | /// Apply the 'Depth To Disparity' filter to this image and return a new filtered image 93 | /// 94 | /// - Parameters: 95 | /// - isActive: If true applies the filter and returns a new image, else returns this image 96 | /// - Returns: The filtered image, or this image if the filter is not active 97 | /// 98 | /// Convert a depth data image to disparity data. 99 | /// 100 | /// **Categories**: BuiltIn, ColorAdjustment, StillImage, Video 101 | /// 102 | /// **Documentation Links** 103 | /// - [CIDepthToDisparity Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDepthToDisparity) 104 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidepthtodisparity) 105 | /// - [CIFilter.app documentation](https://cifilter.app/CIDepthToDisparity/) 106 | @inlinable func applyingDepthToDisparity( 107 | isActive: Bool = true 108 | ) -> CIImage { 109 | guard isActive else { return self } 110 | return CIFF.DepthToDisparity( 111 | inputImage: self 112 | )?.outputImage ?? CIImage.empty() 113 | } 114 | } 115 | 116 | #endif // canImport(CoreImage) 117 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/DisparityToDepth.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisparityToDepth.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Disparity To Depth 31 | /// 32 | /// Convert a disparity data image to depth data. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIDisparityToDepth 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.13, iOS 11, tvOS 11 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CIDisparityToDepth Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDisparityToDepth) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidisparitytodepth) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CIDisparityToDepth/) 50 | @available(macOS 10.13, iOS 11, tvOS 11, *) 51 | @objc(CIFFDisparityToDepth) class DisparityToDepth: Core { 52 | /// Create an instance of the filter with all default values 53 | @objc public init?() { 54 | super.init(name: "CIDisparityToDepth") 55 | } 56 | 57 | // MARK: - inputImage (inputImage) 58 | 59 | /// The input disparity data image to convert to depth data. 60 | /// 61 | /// CIFilter attribute information 62 | /// - Attribute key: `inputImage` 63 | /// - Internal class: `CIImage` 64 | /// - Type: `CIAttributeTypeImage` 65 | @objc public var inputImage: CIImage? { 66 | get { 67 | self.keyedValue("inputImage") 68 | } 69 | set { 70 | self.setKeyedValue(newValue, for: "inputImage") 71 | } 72 | } 73 | 74 | // MARK: - Convenience creators 75 | 76 | /// Filter initializer 77 | /// - Parameters: 78 | /// - inputImage: The input disparity data image to convert to depth data. 79 | @objc public convenience init?( 80 | inputImage: CIImage? = nil 81 | ) { 82 | self.init() 83 | if let inputImage = inputImage { 84 | self.inputImage = inputImage 85 | } 86 | } 87 | } 88 | } 89 | 90 | @available(macOS 10.13, iOS 11, tvOS 11, *) 91 | public extension CIImage { 92 | /// Apply the 'Disparity To Depth' filter to this image and return a new filtered image 93 | /// 94 | /// - Parameters: 95 | /// - isActive: If true applies the filter and returns a new image, else returns this image 96 | /// - Returns: The filtered image, or this image if the filter is not active 97 | /// 98 | /// Convert a disparity data image to depth data. 99 | /// 100 | /// **Categories**: BuiltIn, ColorAdjustment, StillImage, Video 101 | /// 102 | /// **Documentation Links** 103 | /// - [CIDisparityToDepth Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDisparityToDepth) 104 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidisparitytodepth) 105 | /// - [CIFilter.app documentation](https://cifilter.app/CIDisparityToDepth/) 106 | @inlinable func applyingDisparityToDepth( 107 | isActive: Bool = true 108 | ) -> CIImage { 109 | guard isActive else { return self } 110 | return CIFF.DisparityToDepth( 111 | inputImage: self 112 | )?.outputImage ?? CIImage.empty() 113 | } 114 | } 115 | 116 | #endif // canImport(CoreImage) 117 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/DivideBlendMode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DivideBlendMode.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Divide Blend Mode 31 | /// 32 | /// Divides the background image sample color from the source image sample color. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIDivideBlendMode 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.10, iOS 8, tvOS 8 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - CompositeOperation (*CICategoryCompositeOperation*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIDivideBlendMode Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDivideBlendMode) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidivideblendmode) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIDivideBlendMode/) 52 | @available(macOS 10.10, iOS 8, tvOS 8, *) 53 | @objc(CIFFDivideBlendMode) class DivideBlendMode: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIDivideBlendMode") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as a foreground image. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - backgroundImage (inputBackgroundImage) 77 | 78 | /// The image to use as a background image. 79 | /// 80 | /// CIFilter attribute information 81 | /// - Attribute key: `inputBackgroundImage` 82 | /// - Internal class: `CIImage` 83 | /// - Type: `CIAttributeTypeImage` 84 | @objc public var backgroundImage: CIImage? { 85 | get { 86 | self.keyedValue("inputBackgroundImage") 87 | } 88 | set { 89 | self.setKeyedValue(newValue, for: "inputBackgroundImage") 90 | } 91 | } 92 | 93 | // MARK: - Convenience creators 94 | 95 | /// Filter initializer 96 | /// - Parameters: 97 | /// - inputImage: The image to use as a foreground image. 98 | /// - backgroundImage: The image to use as a background image. 99 | @objc public convenience init?( 100 | inputImage: CIImage? = nil, 101 | backgroundImage: CIImage? = nil 102 | ) { 103 | self.init() 104 | if let inputImage = inputImage { 105 | self.inputImage = inputImage 106 | } 107 | if let backgroundImage = backgroundImage { 108 | self.backgroundImage = backgroundImage 109 | } 110 | } 111 | } 112 | } 113 | 114 | @available(macOS 10.10, iOS 8, tvOS 8, *) 115 | public extension CIImage { 116 | /// Apply the 'Divide Blend Mode' filter to this image and return a new filtered image 117 | /// 118 | /// - Parameters: 119 | /// - backgroundImage: The image to use as a background image. 120 | /// - isActive: If true applies the filter and returns a new image, else returns this image 121 | /// - Returns: The filtered image, or this image if the filter is not active 122 | /// 123 | /// Divides the background image sample color from the source image sample color. 124 | /// 125 | /// **Categories**: BuiltIn, CompositeOperation, Interlaced, NonSquarePixels, StillImage, Video 126 | /// 127 | /// **Documentation Links** 128 | /// - [CIDivideBlendMode Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIDivideBlendMode) 129 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cidivideblendmode) 130 | /// - [CIFilter.app documentation](https://cifilter.app/CIDivideBlendMode/) 131 | @inlinable func applyingDivideBlendMode( 132 | backgroundImage: CIImage, 133 | isActive: Bool = true 134 | ) -> CIImage { 135 | guard isActive else { return self } 136 | return CIFF.DivideBlendMode( 137 | inputImage: self, 138 | backgroundImage: backgroundImage 139 | )?.outputImage ?? CIImage.empty() 140 | } 141 | } 142 | 143 | #endif // canImport(CoreImage) 144 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/GaborGradients.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GaborGradients.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Gabor Gradients 31 | /// 32 | /// Applies multichannel 5 by 5 Gabor gradient filter to an image. The resulting image has maximum horizontal gradient in the red channel and the maximum vertical gradient in the green channel. The gradient values can be positive or negative. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIGaborGradients 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.15, iOS 13, tvOS 13 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Stylize (*CICategoryStylize*) 45 | /// - Video (*CICategoryVideo*) 46 | /// 47 | /// **Documentation Links** 48 | /// - [CIGaborGradients Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIGaborGradients) 49 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cigaborgradients) 50 | /// - [CIFilter.app documentation](https://cifilter.app/CIGaborGradients/) 51 | @available(macOS 10.15, iOS 13, tvOS 13, *) 52 | @objc(CIFFGaborGradients) class GaborGradients: Core { 53 | /// Create an instance of the filter with all default values 54 | @objc public init?() { 55 | super.init(name: "CIGaborGradients") 56 | } 57 | 58 | // MARK: - inputImage (inputImage) 59 | 60 | /// The image to use as an input for the effect. 61 | /// 62 | /// CIFilter attribute information 63 | /// - Attribute key: `inputImage` 64 | /// - Internal class: `CIImage` 65 | /// - Type: `CIAttributeTypeImage` 66 | @objc public var inputImage: CIImage? { 67 | get { 68 | self.keyedValue("inputImage") 69 | } 70 | set { 71 | self.setKeyedValue(newValue, for: "inputImage") 72 | } 73 | } 74 | 75 | // MARK: - Convenience creators 76 | 77 | /// Filter initializer 78 | /// - Parameters: 79 | /// - inputImage: The image to use as an input for the effect. 80 | @objc public convenience init?( 81 | inputImage: CIImage? = nil 82 | ) { 83 | self.init() 84 | if let inputImage = inputImage { 85 | self.inputImage = inputImage 86 | } 87 | } 88 | } 89 | } 90 | 91 | @available(macOS 10.15, iOS 13, tvOS 13, *) 92 | public extension CIImage { 93 | /// Apply the 'Gabor Gradients' filter to this image and return a new filtered image 94 | /// 95 | /// - Parameters: 96 | /// - isActive: If true applies the filter and returns a new image, else returns this image 97 | /// - Returns: The filtered image, or this image if the filter is not active 98 | /// 99 | /// Applies multichannel 5 by 5 Gabor gradient filter to an image. The resulting image has maximum horizontal gradient in the red channel and the maximum vertical gradient in the green channel. The gradient values can be positive or negative. 100 | /// 101 | /// **Categories**: BuiltIn, HighDynamicRange, StillImage, Stylize, Video 102 | /// 103 | /// **Documentation Links** 104 | /// - [CIGaborGradients Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIGaborGradients) 105 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cigaborgradients) 106 | /// - [CIFilter.app documentation](https://cifilter.app/CIGaborGradients/) 107 | @inlinable func applyingGaborGradients( 108 | isActive: Bool = true 109 | ) -> CIImage { 110 | guard isActive else { return self } 111 | return CIFF.GaborGradients( 112 | inputImage: self 113 | )?.outputImage ?? CIImage.empty() 114 | } 115 | } 116 | 117 | #endif // canImport(CoreImage) 118 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/HueAdjust.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HueAdjust.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Hue Adjust 31 | /// 32 | /// Changes the overall hue, or tint, of the source pixels. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIHueAdjust 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 5, tvOS 5 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CIHueAdjust Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIHueAdjust) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cihueadjust) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CIHueAdjust/) 53 | @available(macOS 10.4, iOS 5, tvOS 5, *) 54 | @objc(CIFFHueAdjust) class HueAdjust: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CIHueAdjust") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to use as an input for the effect. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - angle (inputAngle) 78 | 79 | /// An angle in radians to use to correct the hue of an image. 80 | /// 81 | /// CIFilter attribute information 82 | /// - Attribute key: `inputAngle` 83 | /// - Internal class: `NSNumber` 84 | /// - Type: `CIAttributeTypeAngle` 85 | /// - Default Value: `0.0` 86 | @objc public var angle: Double { 87 | get { 88 | self.doubleValue(forKey: "inputAngle", defaultValue: Self.angleDefault) 89 | } 90 | set { 91 | self.setKeyedValue(NSNumber(value: newValue), for: "inputAngle") 92 | } 93 | } 94 | 95 | /// `angle` default value 96 | @objc public static let angleDefault: Double = 0.0 97 | 98 | // MARK: - Convenience creators 99 | 100 | /// Filter initializer 101 | /// - Parameters: 102 | /// - inputImage: The image to use as an input for the effect. 103 | /// - angle: An angle in radians to use to correct the hue of an image. 104 | @objc public convenience init?( 105 | inputImage: CIImage? = nil, 106 | angle: Double = HueAdjust.angleDefault 107 | ) { 108 | self.init() 109 | if let inputImage = inputImage { 110 | self.inputImage = inputImage 111 | } 112 | self.angle = angle 113 | } 114 | } 115 | } 116 | 117 | @available(macOS 10.4, iOS 5, tvOS 5, *) 118 | public extension CIImage { 119 | /// Apply the 'Hue Adjust' filter to this image and return a new filtered image 120 | /// 121 | /// - Parameters: 122 | /// - angle: An angle in radians to use to correct the hue of an image. 123 | /// - isActive: If true applies the filter and returns a new image, else returns this image 124 | /// - Returns: The filtered image, or this image if the filter is not active 125 | /// 126 | /// Changes the overall hue, or tint, of the source pixels. 127 | /// 128 | /// **Categories**: BuiltIn, ColorAdjustment, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 129 | /// 130 | /// **Documentation Links** 131 | /// - [CIHueAdjust Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIHueAdjust) 132 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cihueadjust) 133 | /// - [CIFilter.app documentation](https://cifilter.app/CIHueAdjust/) 134 | @inlinable func applyingHueAdjust( 135 | angle: Double = CIFF.HueAdjust.angleDefault, 136 | isActive: Bool = true 137 | ) -> CIImage { 138 | guard isActive else { return self } 139 | return CIFF.HueAdjust( 140 | inputImage: self, 141 | angle: angle 142 | )?.outputImage ?? CIImage.empty() 143 | } 144 | } 145 | 146 | #endif // canImport(CoreImage) 147 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/HueBlendMode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HueBlendMode.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Hue Blend Mode 31 | /// 32 | /// Uses the luminance and saturation values of the background with the hue of the source image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIHueBlendMode 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 5, tvOS 5 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - CompositeOperation (*CICategoryCompositeOperation*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIHueBlendMode Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIHueBlendMode) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cihueblendmode) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIHueBlendMode/) 52 | @available(macOS 10.4, iOS 5, tvOS 5, *) 53 | @objc(CIFFHueBlendMode) class HueBlendMode: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIHueBlendMode") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as a foreground image. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - backgroundImage (inputBackgroundImage) 77 | 78 | /// The image to use as a background image. 79 | /// 80 | /// CIFilter attribute information 81 | /// - Attribute key: `inputBackgroundImage` 82 | /// - Internal class: `CIImage` 83 | /// - Type: `CIAttributeTypeImage` 84 | @objc public var backgroundImage: CIImage? { 85 | get { 86 | self.keyedValue("inputBackgroundImage") 87 | } 88 | set { 89 | self.setKeyedValue(newValue, for: "inputBackgroundImage") 90 | } 91 | } 92 | 93 | // MARK: - Convenience creators 94 | 95 | /// Filter initializer 96 | /// - Parameters: 97 | /// - inputImage: The image to use as a foreground image. 98 | /// - backgroundImage: The image to use as a background image. 99 | @objc public convenience init?( 100 | inputImage: CIImage? = nil, 101 | backgroundImage: CIImage? = nil 102 | ) { 103 | self.init() 104 | if let inputImage = inputImage { 105 | self.inputImage = inputImage 106 | } 107 | if let backgroundImage = backgroundImage { 108 | self.backgroundImage = backgroundImage 109 | } 110 | } 111 | } 112 | } 113 | 114 | @available(macOS 10.4, iOS 5, tvOS 5, *) 115 | public extension CIImage { 116 | /// Apply the 'Hue Blend Mode' filter to this image and return a new filtered image 117 | /// 118 | /// - Parameters: 119 | /// - backgroundImage: The image to use as a background image. 120 | /// - isActive: If true applies the filter and returns a new image, else returns this image 121 | /// - Returns: The filtered image, or this image if the filter is not active 122 | /// 123 | /// Uses the luminance and saturation values of the background with the hue of the source image. 124 | /// 125 | /// **Categories**: BuiltIn, CompositeOperation, Interlaced, NonSquarePixels, StillImage, Video 126 | /// 127 | /// **Documentation Links** 128 | /// - [CIHueBlendMode Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIHueBlendMode) 129 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cihueblendmode) 130 | /// - [CIFilter.app documentation](https://cifilter.app/CIHueBlendMode/) 131 | @inlinable func applyingHueBlendMode( 132 | backgroundImage: CIImage, 133 | isActive: Bool = true 134 | ) -> CIImage { 135 | guard isActive else { return self } 136 | return CIFF.HueBlendMode( 137 | inputImage: self, 138 | backgroundImage: backgroundImage 139 | )?.outputImage ?? CIImage.empty() 140 | } 141 | } 142 | 143 | #endif // canImport(CoreImage) 144 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/LabDeltaE.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LabDeltaE.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Lab ∆E 31 | /// 32 | /// Produces an image with the Lab ∆E difference values between two images. The result image will contain ∆E 1994 values between 0.0 and 100.0 where 2.0 is considered a just noticeable difference. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CILabDeltaE 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.13, iOS 11, tvOS 11 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CILabDeltaE Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CILabDeltaE) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cilabdeltae) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CILabDeltaE/) 52 | @available(macOS 10.13, iOS 11, tvOS 11, *) 53 | @objc(CIFFLabDeltaE) class LabDeltaE: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CILabDeltaE") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The first input image for comparison. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - image2 (inputImage2) 77 | 78 | /// The second input image for comparison. 79 | /// 80 | /// CIFilter attribute information 81 | /// - Attribute key: `inputImage2` 82 | /// - Internal class: `CIImage` 83 | /// - Type: `CIAttributeTypeImage` 84 | @objc public var image2: CIImage? { 85 | get { 86 | self.keyedValue("inputImage2") 87 | } 88 | set { 89 | self.setKeyedValue(newValue, for: "inputImage2") 90 | } 91 | } 92 | 93 | // MARK: - Convenience creators 94 | 95 | /// Filter initializer 96 | /// - Parameters: 97 | /// - inputImage: The first input image for comparison. 98 | /// - image2: The second input image for comparison. 99 | @objc public convenience init?( 100 | inputImage: CIImage? = nil, 101 | image2: CIImage? = nil 102 | ) { 103 | self.init() 104 | if let inputImage = inputImage { 105 | self.inputImage = inputImage 106 | } 107 | if let image2 = image2 { 108 | self.image2 = image2 109 | } 110 | } 111 | } 112 | } 113 | 114 | @available(macOS 10.13, iOS 11, tvOS 11, *) 115 | public extension CIImage { 116 | /// Apply the 'Lab ∆E' filter to this image and return a new filtered image 117 | /// 118 | /// - Parameters: 119 | /// - image2: The second input image for comparison. 120 | /// - isActive: If true applies the filter and returns a new image, else returns this image 121 | /// - Returns: The filtered image, or this image if the filter is not active 122 | /// 123 | /// Produces an image with the Lab ∆E difference values between two images. The result image will contain ∆E 1994 values between 0.0 and 100.0 where 2.0 is considered a just noticeable difference. 124 | /// 125 | /// **Categories**: BuiltIn, ColorEffect, Interlaced, NonSquarePixels, StillImage, Video 126 | /// 127 | /// **Documentation Links** 128 | /// - [CILabDeltaE Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CILabDeltaE) 129 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cilabdeltae) 130 | /// - [CIFilter.app documentation](https://cifilter.app/CILabDeltaE/) 131 | @inlinable func applyingLabDeltaE( 132 | image2: CIImage, 133 | isActive: Bool = true 134 | ) -> CIImage { 135 | guard isActive else { return self } 136 | return CIFF.LabDeltaE( 137 | inputImage: self, 138 | image2: image2 139 | )?.outputImage ?? CIImage.empty() 140 | } 141 | } 142 | 143 | #endif // canImport(CoreImage) 144 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/LinearToSRGBToneCurve.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LinearToSRGBToneCurve.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Linear to sRGB Tone Curve 31 | /// 32 | /// Converts an image in linear space to sRGB space. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CILinearToSRGBToneCurve 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.10, iOS 7, tvOS 7 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CILinearToSRGBToneCurve Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CILinearToSRGBToneCurve) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cilineartosrgbtonecurve) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CILinearToSRGBToneCurve/) 53 | @available(macOS 10.10, iOS 7, tvOS 7, *) 54 | @objc(CIFFLinearToSRGBToneCurve) class LinearToSRGBToneCurve: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CILinearToSRGBToneCurve") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to use as an input for the effect. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - Convenience creators 78 | 79 | /// Filter initializer 80 | /// - Parameters: 81 | /// - inputImage: The image to use as an input for the effect. 82 | @objc public convenience init?( 83 | inputImage: CIImage? = nil 84 | ) { 85 | self.init() 86 | if let inputImage = inputImage { 87 | self.inputImage = inputImage 88 | } 89 | } 90 | } 91 | } 92 | 93 | @available(macOS 10.10, iOS 7, tvOS 7, *) 94 | public extension CIImage { 95 | /// Apply the 'Linear to sRGB Tone Curve' filter to this image and return a new filtered image 96 | /// 97 | /// - Parameters: 98 | /// - isActive: If true applies the filter and returns a new image, else returns this image 99 | /// - Returns: The filtered image, or this image if the filter is not active 100 | /// 101 | /// Converts an image in linear space to sRGB space. 102 | /// 103 | /// **Categories**: BuiltIn, ColorAdjustment, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 104 | /// 105 | /// **Documentation Links** 106 | /// - [CILinearToSRGBToneCurve Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CILinearToSRGBToneCurve) 107 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cilineartosrgbtonecurve) 108 | /// - [CIFilter.app documentation](https://cifilter.app/CILinearToSRGBToneCurve/) 109 | @inlinable func applyingLinearToSRGBToneCurve( 110 | isActive: Bool = true 111 | ) -> CIImage { 112 | guard isActive else { return self } 113 | return CIFF.LinearToSRGBToneCurve( 114 | inputImage: self 115 | )?.outputImage ?? CIImage.empty() 116 | } 117 | } 118 | 119 | #endif // canImport(CoreImage) 120 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/MaskToAlpha.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaskToAlpha.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Mask to Alpha 31 | /// 32 | /// Converts a grayscale image to a white image that is masked by alpha. The white values from the source image produce the inside of the mask; the black values become completely transparent. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIMaskToAlpha 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 6, tvOS 6 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIMaskToAlpha Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMaskToAlpha) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimasktoalpha) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIMaskToAlpha/) 52 | @available(macOS 10.4, iOS 6, tvOS 6, *) 53 | @objc(CIFFMaskToAlpha) class MaskToAlpha: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIMaskToAlpha") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as an input for the effect. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - Convenience creators 77 | 78 | /// Filter initializer 79 | /// - Parameters: 80 | /// - inputImage: The image to use as an input for the effect. 81 | @objc public convenience init?( 82 | inputImage: CIImage? = nil 83 | ) { 84 | self.init() 85 | if let inputImage = inputImage { 86 | self.inputImage = inputImage 87 | } 88 | } 89 | } 90 | } 91 | 92 | @available(macOS 10.4, iOS 6, tvOS 6, *) 93 | public extension CIImage { 94 | /// Apply the 'Mask to Alpha' filter to this image and return a new filtered image 95 | /// 96 | /// - Parameters: 97 | /// - isActive: If true applies the filter and returns a new image, else returns this image 98 | /// - Returns: The filtered image, or this image if the filter is not active 99 | /// 100 | /// Converts a grayscale image to a white image that is masked by alpha. The white values from the source image produce the inside of the mask; the black values become completely transparent. 101 | /// 102 | /// **Categories**: BuiltIn, ColorEffect, Interlaced, NonSquarePixels, StillImage, Video 103 | /// 104 | /// **Documentation Links** 105 | /// - [CIMaskToAlpha Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMaskToAlpha) 106 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimasktoalpha) 107 | /// - [CIFilter.app documentation](https://cifilter.app/CIMaskToAlpha/) 108 | @inlinable func applyingMaskToAlpha( 109 | isActive: Bool = true 110 | ) -> CIImage { 111 | guard isActive else { return self } 112 | return CIFF.MaskToAlpha( 113 | inputImage: self 114 | )?.outputImage ?? CIImage.empty() 115 | } 116 | } 117 | 118 | #endif // canImport(CoreImage) 119 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/MaximumComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MaximumComponent.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Maximum Component 31 | /// 32 | /// Converts an image to grayscale using the maximum of the three color components. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIMaximumComponent 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.5, iOS 6, tvOS 6 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CIMaximumComponent Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMaximumComponent) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimaximumcomponent) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CIMaximumComponent/) 53 | @available(macOS 10.5, iOS 6, tvOS 6, *) 54 | @objc(CIFFMaximumComponent) class MaximumComponent: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CIMaximumComponent") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to process. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - Convenience creators 78 | 79 | /// Filter initializer 80 | /// - Parameters: 81 | /// - inputImage: The image to process. 82 | @objc public convenience init?( 83 | inputImage: CIImage? = nil 84 | ) { 85 | self.init() 86 | if let inputImage = inputImage { 87 | self.inputImage = inputImage 88 | } 89 | } 90 | } 91 | } 92 | 93 | @available(macOS 10.5, iOS 6, tvOS 6, *) 94 | public extension CIImage { 95 | /// Apply the 'Maximum Component' filter to this image and return a new filtered image 96 | /// 97 | /// - Parameters: 98 | /// - isActive: If true applies the filter and returns a new image, else returns this image 99 | /// - Returns: The filtered image, or this image if the filter is not active 100 | /// 101 | /// Converts an image to grayscale using the maximum of the three color components. 102 | /// 103 | /// **Categories**: BuiltIn, ColorEffect, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 104 | /// 105 | /// **Documentation Links** 106 | /// - [CIMaximumComponent Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMaximumComponent) 107 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimaximumcomponent) 108 | /// - [CIFilter.app documentation](https://cifilter.app/CIMaximumComponent/) 109 | @inlinable func applyingMaximumComponent( 110 | isActive: Bool = true 111 | ) -> CIImage { 112 | guard isActive else { return self } 113 | return CIFF.MaximumComponent( 114 | inputImage: self 115 | )?.outputImage ?? CIImage.empty() 116 | } 117 | } 118 | 119 | #endif // canImport(CoreImage) 120 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/MedianFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MedianFilter.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Median 31 | /// 32 | /// Computes the median value for a group of neighboring pixels and replaces each pixel value with the median. The effect is to reduce noise. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIMedianFilter 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 9, tvOS 9 39 | /// 40 | /// **Categories** 41 | /// - Blur (*CICategoryBlur*) 42 | /// - BuiltIn (*CICategoryBuiltIn*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - StillImage (*CICategoryStillImage*) 45 | /// - Video (*CICategoryVideo*) 46 | /// 47 | /// **Documentation Links** 48 | /// - [CIMedianFilter Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMedianFilter) 49 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimedianfilter) 50 | /// - [CIFilter.app documentation](https://cifilter.app/CIMedianFilter/) 51 | @available(macOS 10.4, iOS 9, tvOS 9, *) 52 | @objc(CIFFMedianFilter) class MedianFilter: Core { 53 | /// Create an instance of the filter with all default values 54 | @objc public init?() { 55 | super.init(name: "CIMedianFilter") 56 | } 57 | 58 | // MARK: - inputImage (inputImage) 59 | 60 | /// The image to use as an input for the effect. 61 | /// 62 | /// CIFilter attribute information 63 | /// - Attribute key: `inputImage` 64 | /// - Internal class: `CIImage` 65 | /// - Type: `CIAttributeTypeImage` 66 | @objc public var inputImage: CIImage? { 67 | get { 68 | self.keyedValue("inputImage") 69 | } 70 | set { 71 | self.setKeyedValue(newValue, for: "inputImage") 72 | } 73 | } 74 | 75 | // MARK: - Convenience creators 76 | 77 | /// Filter initializer 78 | /// - Parameters: 79 | /// - inputImage: The image to use as an input for the effect. 80 | @objc public convenience init?( 81 | inputImage: CIImage? = nil 82 | ) { 83 | self.init() 84 | if let inputImage = inputImage { 85 | self.inputImage = inputImage 86 | } 87 | } 88 | } 89 | } 90 | 91 | @available(macOS 10.4, iOS 9, tvOS 9, *) 92 | public extension CIImage { 93 | /// Apply the 'Median' filter to this image and return a new filtered image 94 | /// 95 | /// - Parameters: 96 | /// - isActive: If true applies the filter and returns a new image, else returns this image 97 | /// - Returns: The filtered image, or this image if the filter is not active 98 | /// 99 | /// Computes the median value for a group of neighboring pixels and replaces each pixel value with the median. The effect is to reduce noise. 100 | /// 101 | /// **Categories**: Blur, BuiltIn, HighDynamicRange, StillImage, Video 102 | /// 103 | /// **Documentation Links** 104 | /// - [CIMedianFilter Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMedianFilter) 105 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cimedianfilter) 106 | /// - [CIFilter.app documentation](https://cifilter.app/CIMedianFilter/) 107 | @inlinable func applyingMedianFilter( 108 | isActive: Bool = true 109 | ) -> CIImage { 110 | guard isActive else { return self } 111 | return CIFF.MedianFilter( 112 | inputImage: self 113 | )?.outputImage ?? CIImage.empty() 114 | } 115 | } 116 | 117 | #endif // canImport(CoreImage) 118 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/MinimumComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinimumComponent.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Minimum Component 31 | /// 32 | /// Converts an image to grayscale using the minimum of the three color components. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIMinimumComponent 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.5, iOS 6, tvOS 6 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CIMinimumComponent Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMinimumComponent) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciminimumcomponent) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CIMinimumComponent/) 53 | @available(macOS 10.5, iOS 6, tvOS 6, *) 54 | @objc(CIFFMinimumComponent) class MinimumComponent: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CIMinimumComponent") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to process. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - Convenience creators 78 | 79 | /// Filter initializer 80 | /// - Parameters: 81 | /// - inputImage: The image to process. 82 | @objc public convenience init?( 83 | inputImage: CIImage? = nil 84 | ) { 85 | self.init() 86 | if let inputImage = inputImage { 87 | self.inputImage = inputImage 88 | } 89 | } 90 | } 91 | } 92 | 93 | @available(macOS 10.5, iOS 6, tvOS 6, *) 94 | public extension CIImage { 95 | /// Apply the 'Minimum Component' filter to this image and return a new filtered image 96 | /// 97 | /// - Parameters: 98 | /// - isActive: If true applies the filter and returns a new image, else returns this image 99 | /// - Returns: The filtered image, or this image if the filter is not active 100 | /// 101 | /// Converts an image to grayscale using the minimum of the three color components. 102 | /// 103 | /// **Categories**: BuiltIn, ColorEffect, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 104 | /// 105 | /// **Documentation Links** 106 | /// - [CIMinimumComponent Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIMinimumComponent) 107 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciminimumcomponent) 108 | /// - [CIFilter.app documentation](https://cifilter.app/CIMinimumComponent/) 109 | @inlinable func applyingMinimumComponent( 110 | isActive: Bool = true 111 | ) -> CIImage { 112 | guard isActive else { return self } 113 | return CIFF.MinimumComponent( 114 | inputImage: self 115 | )?.outputImage ?? CIImage.empty() 116 | } 117 | } 118 | 119 | #endif // canImport(CoreImage) 120 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/RandomGenerator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RandomGenerator.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Random Generator 31 | /// 32 | /// Generates an image of infinite extent whose pixel values are made up of four independent, uniformly-distributed random numbers in the 0 to 1 range. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIRandomGenerator 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 6, tvOS 6 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - Generator (*CICategoryGenerator*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CIRandomGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIRandomGenerator) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cirandomgenerator) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CIRandomGenerator/) 50 | @available(macOS 10.4, iOS 6, tvOS 6, *) 51 | @objc(CIFFRandomGenerator) class RandomGenerator: Core { 52 | /// Create an instance of the filter with all default values 53 | @objc public init?() { 54 | super.init(name: "CIRandomGenerator") 55 | } 56 | } 57 | } 58 | 59 | @available(macOS 10.4, iOS 6, tvOS 6, *) 60 | public extension CIImage { 61 | /// Create a new CIImage using the 'Random Generator' filter 62 | /// 63 | /// - Returns: A new image by running the filter, or nil if the image could not be created 64 | /// 65 | /// Generates an image of infinite extent whose pixel values are made up of four independent, uniformly-distributed random numbers in the 0 to 1 range. 66 | /// 67 | /// **Categories**: BuiltIn, Generator, StillImage, Video 68 | /// 69 | /// **Documentation Links** 70 | /// - [CIRandomGenerator Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIRandomGenerator) 71 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cirandomgenerator) 72 | /// - [CIFilter.app documentation](https://cifilter.app/CIRandomGenerator/) 73 | @inlinable static func createUsingRandomGenerator( 74 | ) -> CIImage? { 75 | return CIFF.RandomGenerator( 76 | )?.outputImage 77 | } 78 | } 79 | 80 | #endif // canImport(CoreImage) 81 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/SRGBToneCurveToLinear.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SRGBToneCurveToLinear.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// sRGB Tone Curve to Linear 31 | /// 32 | /// Converts an image in sRGB space to linear space. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CISRGBToneCurveToLinear 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.10, iOS 7, tvOS 7 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CISRGBToneCurveToLinear Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISRGBToneCurveToLinear) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisrgbtonecurvetolinear) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CISRGBToneCurveToLinear/) 53 | @available(macOS 10.10, iOS 7, tvOS 7, *) 54 | @objc(CIFFSRGBToneCurveToLinear) class SRGBToneCurveToLinear: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CISRGBToneCurveToLinear") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to use as an input for the effect. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - Convenience creators 78 | 79 | /// Filter initializer 80 | /// - Parameters: 81 | /// - inputImage: The image to use as an input for the effect. 82 | @objc public convenience init?( 83 | inputImage: CIImage? = nil 84 | ) { 85 | self.init() 86 | if let inputImage = inputImage { 87 | self.inputImage = inputImage 88 | } 89 | } 90 | } 91 | } 92 | 93 | @available(macOS 10.10, iOS 7, tvOS 7, *) 94 | public extension CIImage { 95 | /// Apply the 'sRGB Tone Curve to Linear' filter to this image and return a new filtered image 96 | /// 97 | /// - Parameters: 98 | /// - isActive: If true applies the filter and returns a new image, else returns this image 99 | /// - Returns: The filtered image, or this image if the filter is not active 100 | /// 101 | /// Converts an image in sRGB space to linear space. 102 | /// 103 | /// **Categories**: BuiltIn, ColorAdjustment, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 104 | /// 105 | /// **Documentation Links** 106 | /// - [CISRGBToneCurveToLinear Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISRGBToneCurveToLinear) 107 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisrgbtonecurvetolinear) 108 | /// - [CIFilter.app documentation](https://cifilter.app/CISRGBToneCurveToLinear/) 109 | @inlinable func applyingSRGBToneCurveToLinear( 110 | isActive: Bool = true 111 | ) -> CIImage { 112 | guard isActive else { return self } 113 | return CIFF.SRGBToneCurveToLinear( 114 | inputImage: self 115 | )?.outputImage ?? CIImage.empty() 116 | } 117 | } 118 | 119 | #endif // canImport(CoreImage) 120 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/SaliencyMapFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SaliencyMapFilter.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Saliency Map Filter 31 | /// 32 | /// Generates output image as a saliency map of the input image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CISaliencyMapFilter 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.14, iOS 12, tvOS 12 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - StillImage (*CICategoryStillImage*) 43 | /// - Stylize (*CICategoryStylize*) 44 | /// - Video (*CICategoryVideo*) 45 | /// 46 | /// **Documentation Links** 47 | /// - [CISaliencyMapFilter Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISaliencyMapFilter) 48 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisaliencymapfilter) 49 | /// - [CIFilter.app documentation](https://cifilter.app/CISaliencyMapFilter/) 50 | @available(macOS 10.14, iOS 12, tvOS 12, *) 51 | @objc(CIFFSaliencyMapFilter) class SaliencyMapFilter: Core { 52 | /// Create an instance of the filter with all default values 53 | @objc public init?() { 54 | super.init(name: "CISaliencyMapFilter") 55 | } 56 | 57 | // MARK: - inputImage (inputImage) 58 | 59 | /// The image to use as an input for the effect. 60 | /// 61 | /// CIFilter attribute information 62 | /// - Attribute key: `inputImage` 63 | /// - Internal class: `CIImage` 64 | /// - Type: `CIAttributeTypeImage` 65 | @objc public var inputImage: CIImage? { 66 | get { 67 | self.keyedValue("inputImage") 68 | } 69 | set { 70 | self.setKeyedValue(newValue, for: "inputImage") 71 | } 72 | } 73 | 74 | // MARK: - Convenience creators 75 | 76 | /// Filter initializer 77 | /// - Parameters: 78 | /// - inputImage: The image to use as an input for the effect. 79 | @objc public convenience init?( 80 | inputImage: CIImage? = nil 81 | ) { 82 | self.init() 83 | if let inputImage = inputImage { 84 | self.inputImage = inputImage 85 | } 86 | } 87 | } 88 | } 89 | 90 | @available(macOS 10.14, iOS 12, tvOS 12, *) 91 | public extension CIImage { 92 | /// Apply the 'Saliency Map Filter' filter to this image and return a new filtered image 93 | /// 94 | /// - Parameters: 95 | /// - isActive: If true applies the filter and returns a new image, else returns this image 96 | /// - Returns: The filtered image, or this image if the filter is not active 97 | /// 98 | /// Generates output image as a saliency map of the input image. 99 | /// 100 | /// **Categories**: BuiltIn, StillImage, Stylize, Video 101 | /// 102 | /// **Documentation Links** 103 | /// - [CISaliencyMapFilter Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISaliencyMapFilter) 104 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisaliencymapfilter) 105 | /// - [CIFilter.app documentation](https://cifilter.app/CISaliencyMapFilter/) 106 | @inlinable func applyingSaliencyMapFilter( 107 | isActive: Bool = true 108 | ) -> CIImage { 109 | guard isActive else { return self } 110 | return CIFF.SaliencyMapFilter( 111 | inputImage: self 112 | )?.outputImage ?? CIImage.empty() 113 | } 114 | } 115 | 116 | #endif // canImport(CoreImage) 117 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/SampleNearest.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SampleNearest.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Sample Nearest 31 | /// 32 | /// Produces an image that forces the image sampling to “nearest” mode instead of the default “linear” mode. This filter can be used to alter the behavior of filters that alter the geometry of an image. The output of this filter should be passed as the input to the geometry filter. For example, passing the output of this filter to CIAffineTransform can be used to produce a pixelated upsampled image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CISampleNearest 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.14, iOS 12, tvOS 12 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Stylize (*CICategoryStylize*) 45 | /// - Video (*CICategoryVideo*) 46 | /// 47 | /// **Documentation Links** 48 | /// - [CISampleNearest Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISampleNearest) 49 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisamplenearest) 50 | /// - [CIFilter.app documentation](https://cifilter.app/CISampleNearest/) 51 | @available(macOS 10.14, iOS 12, tvOS 12, *) 52 | @objc(CIFFSampleNearest) class SampleNearest: Core { 53 | /// Create an instance of the filter with all default values 54 | @objc public init?() { 55 | super.init(name: "CISampleNearest") 56 | } 57 | 58 | // MARK: - inputImage (inputImage) 59 | 60 | /// The image to use as an input for the effect. 61 | /// 62 | /// CIFilter attribute information 63 | /// - Attribute key: `inputImage` 64 | /// - Internal class: `CIImage` 65 | /// - Type: `CIAttributeTypeImage` 66 | @objc public var inputImage: CIImage? { 67 | get { 68 | self.keyedValue("inputImage") 69 | } 70 | set { 71 | self.setKeyedValue(newValue, for: "inputImage") 72 | } 73 | } 74 | 75 | // MARK: - Convenience creators 76 | 77 | /// Filter initializer 78 | /// - Parameters: 79 | /// - inputImage: The image to use as an input for the effect. 80 | @objc public convenience init?( 81 | inputImage: CIImage? = nil 82 | ) { 83 | self.init() 84 | if let inputImage = inputImage { 85 | self.inputImage = inputImage 86 | } 87 | } 88 | } 89 | } 90 | 91 | @available(macOS 10.14, iOS 12, tvOS 12, *) 92 | public extension CIImage { 93 | /// Apply the 'Sample Nearest' filter to this image and return a new filtered image 94 | /// 95 | /// - Parameters: 96 | /// - isActive: If true applies the filter and returns a new image, else returns this image 97 | /// - Returns: The filtered image, or this image if the filter is not active 98 | /// 99 | /// Produces an image that forces the image sampling to “nearest” mode instead of the default “linear” mode. This filter can be used to alter the behavior of filters that alter the geometry of an image. The output of this filter should be passed as the input to the geometry filter. For example, passing the output of this filter to CIAffineTransform can be used to produce a pixelated upsampled image. 100 | /// 101 | /// **Categories**: BuiltIn, HighDynamicRange, StillImage, Stylize, Video 102 | /// 103 | /// **Documentation Links** 104 | /// - [CISampleNearest Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISampleNearest) 105 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisamplenearest) 106 | /// - [CIFilter.app documentation](https://cifilter.app/CISampleNearest/) 107 | @inlinable func applyingSampleNearest( 108 | isActive: Bool = true 109 | ) -> CIImage { 110 | guard isActive else { return self } 111 | return CIFF.SampleNearest( 112 | inputImage: self 113 | )?.outputImage ?? CIImage.empty() 114 | } 115 | } 116 | 117 | #endif // canImport(CoreImage) 118 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/SobelGradients.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SobelGradients.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Sobel Gradients 31 | /// 32 | /// Applies multichannel 3 by 3 Sobel gradient filter to an image. The resulting image has maximum horizontal gradient in the red channel and the maximum vertical gradient in the green channel. The gradient values can be positive or negative. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CISobelGradients 36 | /// 37 | /// **Availability** 38 | /// - macOS 14.0, iOS 17, tvOS 17 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 43 | /// - StillImage (*CICategoryStillImage*) 44 | /// - Stylize (*CICategoryStylize*) 45 | /// - Video (*CICategoryVideo*) 46 | /// 47 | /// **Documentation Links** 48 | /// - [CISobelGradients Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISobelGradients) 49 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisobelgradients) 50 | /// - [CIFilter.app documentation](https://cifilter.app/CISobelGradients/) 51 | @available(macOS 14.0, iOS 17, tvOS 17, *) 52 | @objc(CIFFSobelGradients) class SobelGradients: Core { 53 | /// Create an instance of the filter with all default values 54 | @objc public init?() { 55 | super.init(name: "CISobelGradients") 56 | } 57 | 58 | // MARK: - inputImage (inputImage) 59 | 60 | /// The image to use as an input for the effect. 61 | /// 62 | /// CIFilter attribute information 63 | /// - Attribute key: `inputImage` 64 | /// - Internal class: `CIImage` 65 | /// - Type: `CIAttributeTypeImage` 66 | @objc public var inputImage: CIImage? { 67 | get { 68 | self.keyedValue("inputImage") 69 | } 70 | set { 71 | self.setKeyedValue(newValue, for: "inputImage") 72 | } 73 | } 74 | 75 | // MARK: - Convenience creators 76 | 77 | /// Filter initializer 78 | /// - Parameters: 79 | /// - inputImage: The image to use as an input for the effect. 80 | @objc public convenience init?( 81 | inputImage: CIImage? = nil 82 | ) { 83 | self.init() 84 | if let inputImage = inputImage { 85 | self.inputImage = inputImage 86 | } 87 | } 88 | } 89 | } 90 | 91 | @available(macOS 14.0, iOS 17, tvOS 17, *) 92 | public extension CIImage { 93 | /// Apply the 'Sobel Gradients' filter to this image and return a new filtered image 94 | /// 95 | /// - Parameters: 96 | /// - isActive: If true applies the filter and returns a new image, else returns this image 97 | /// - Returns: The filtered image, or this image if the filter is not active 98 | /// 99 | /// Applies multichannel 3 by 3 Sobel gradient filter to an image. The resulting image has maximum horizontal gradient in the red channel and the maximum vertical gradient in the green channel. The gradient values can be positive or negative. 100 | /// 101 | /// **Categories**: BuiltIn, HighDynamicRange, StillImage, Stylize, Video 102 | /// 103 | /// **Documentation Links** 104 | /// - [CISobelGradients Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISobelGradients) 105 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cisobelgradients) 106 | /// - [CIFilter.app documentation](https://cifilter.app/CISobelGradients/) 107 | @inlinable func applyingSobelGradients( 108 | isActive: Bool = true 109 | ) -> CIImage { 110 | guard isActive else { return self } 111 | return CIFF.SobelGradients( 112 | inputImage: self 113 | )?.outputImage ?? CIImage.empty() 114 | } 115 | } 116 | 117 | #endif // canImport(CoreImage) 118 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/Thermal.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Thermal.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// Thermal 31 | /// 32 | /// Apply a “Thermal” style effect to an image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIThermal 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.11, iOS 10, tvOS 10 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIThermal Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIThermal) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cithermal) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIThermal/) 52 | @available(macOS 10.11, iOS 10, tvOS 10, *) 53 | @objc(CIFFThermal) class Thermal: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIThermal") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as an input for the effect. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - Convenience creators 77 | 78 | /// Filter initializer 79 | /// - Parameters: 80 | /// - inputImage: The image to use as an input for the effect. 81 | @objc public convenience init?( 82 | inputImage: CIImage? = nil 83 | ) { 84 | self.init() 85 | if let inputImage = inputImage { 86 | self.inputImage = inputImage 87 | } 88 | } 89 | } 90 | } 91 | 92 | @available(macOS 10.11, iOS 10, tvOS 10, *) 93 | public extension CIImage { 94 | /// Apply the 'Thermal' filter to this image and return a new filtered image 95 | /// 96 | /// - Parameters: 97 | /// - isActive: If true applies the filter and returns a new image, else returns this image 98 | /// - Returns: The filtered image, or this image if the filter is not active 99 | /// 100 | /// Apply a “Thermal” style effect to an image. 101 | /// 102 | /// **Categories**: BuiltIn, ColorEffect, Interlaced, NonSquarePixels, StillImage, Video 103 | /// 104 | /// **Documentation Links** 105 | /// - [CIThermal Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIThermal) 106 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cithermal) 107 | /// - [CIFilter.app documentation](https://cifilter.app/CIThermal/) 108 | @inlinable func applyingThermal( 109 | isActive: Bool = true 110 | ) -> CIImage { 111 | guard isActive else { return self } 112 | return CIFF.Thermal( 113 | inputImage: self 114 | )?.outputImage ?? CIImage.empty() 115 | } 116 | } 117 | 118 | #endif // canImport(CoreImage) 119 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/WhitePointAdjust.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WhitePointAdjust.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// White Point Adjust 31 | /// 32 | /// Adjusts the reference white point for an image and maps all colors in the source using the new reference. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIWhitePointAdjust 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.4, iOS 5, tvOS 5 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorAdjustment (*CICategoryColorAdjustment*) 43 | /// - HighDynamicRange (*CICategoryHighDynamicRange*) 44 | /// - Interlaced (*CICategoryInterlaced*) 45 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 46 | /// - StillImage (*CICategoryStillImage*) 47 | /// - Video (*CICategoryVideo*) 48 | /// 49 | /// **Documentation Links** 50 | /// - [CIWhitePointAdjust Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIWhitePointAdjust) 51 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciwhitepointadjust) 52 | /// - [CIFilter.app documentation](https://cifilter.app/CIWhitePointAdjust/) 53 | @available(macOS 10.4, iOS 5, tvOS 5, *) 54 | @objc(CIFFWhitePointAdjust) class WhitePointAdjust: Core { 55 | /// Create an instance of the filter with all default values 56 | @objc public init?() { 57 | super.init(name: "CIWhitePointAdjust") 58 | } 59 | 60 | // MARK: - inputImage (inputImage) 61 | 62 | /// The image to use as an input for the effect. 63 | /// 64 | /// CIFilter attribute information 65 | /// - Attribute key: `inputImage` 66 | /// - Internal class: `CIImage` 67 | /// - Type: `CIAttributeTypeImage` 68 | @objc public var inputImage: CIImage? { 69 | get { 70 | self.keyedValue("inputImage") 71 | } 72 | set { 73 | self.setKeyedValue(newValue, for: "inputImage") 74 | } 75 | } 76 | 77 | // MARK: - color (inputColor) 78 | 79 | /// A color to use as the white point. 80 | /// 81 | /// CIFilter attribute information 82 | /// - Attribute key: `inputColor` 83 | /// - Internal class: `CIColor` 84 | /// - Type: `CIAttributeTypeColor` 85 | @objc public var color: CIColor? { 86 | get { 87 | self.keyedValue("inputColor") 88 | } 89 | set { 90 | self.setKeyedValue(newValue, for: "inputColor") 91 | } 92 | } 93 | 94 | // MARK: - Convenience creators 95 | 96 | /// Filter initializer 97 | /// - Parameters: 98 | /// - inputImage: The image to use as an input for the effect. 99 | /// - color: A color to use as the white point. 100 | @objc public convenience init?( 101 | inputImage: CIImage? = nil, 102 | color: CIColor 103 | ) { 104 | self.init() 105 | if let inputImage = inputImage { 106 | self.inputImage = inputImage 107 | } 108 | self.color = color 109 | } 110 | } 111 | } 112 | 113 | @available(macOS 10.4, iOS 5, tvOS 5, *) 114 | public extension CIImage { 115 | /// Apply the 'White Point Adjust' filter to this image and return a new filtered image 116 | /// 117 | /// - Parameters: 118 | /// - color: A color to use as the white point. 119 | /// - isActive: If true applies the filter and returns a new image, else returns this image 120 | /// - Returns: The filtered image, or this image if the filter is not active 121 | /// 122 | /// Adjusts the reference white point for an image and maps all colors in the source using the new reference. 123 | /// 124 | /// **Categories**: BuiltIn, ColorAdjustment, HighDynamicRange, Interlaced, NonSquarePixels, StillImage, Video 125 | /// 126 | /// **Documentation Links** 127 | /// - [CIWhitePointAdjust Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIWhitePointAdjust) 128 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/ciwhitepointadjust) 129 | /// - [CIFilter.app documentation](https://cifilter.app/CIWhitePointAdjust/) 130 | @inlinable func applyingWhitePointAdjust( 131 | color: CIColor, 132 | isActive: Bool = true 133 | ) -> CIImage { 134 | guard isActive else { return self } 135 | return CIFF.WhitePointAdjust( 136 | inputImage: self, 137 | color: color 138 | )?.outputImage ?? CIImage.empty() 139 | } 140 | } 141 | 142 | #endif // canImport(CoreImage) 143 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/generated/XRay.swift: -------------------------------------------------------------------------------- 1 | // 2 | // XRay.swift (AUTOMATICALLY GENERATED FILE) 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | #if canImport(CoreImage) 23 | 24 | import AVFoundation 25 | import CoreImage 26 | import CoreML 27 | import Foundation 28 | 29 | @objc public extension CIFF { 30 | /// X-Ray 31 | /// 32 | /// Apply an “XRay” style effect to an image. 33 | /// 34 | /// **CIFilter Name** 35 | /// - CIXRay 36 | /// 37 | /// **Availability** 38 | /// - macOS 10.11, iOS 10, tvOS 10 39 | /// 40 | /// **Categories** 41 | /// - BuiltIn (*CICategoryBuiltIn*) 42 | /// - ColorEffect (*CICategoryColorEffect*) 43 | /// - Interlaced (*CICategoryInterlaced*) 44 | /// - NonSquarePixels (*CICategoryNonSquarePixels*) 45 | /// - StillImage (*CICategoryStillImage*) 46 | /// - Video (*CICategoryVideo*) 47 | /// 48 | /// **Documentation Links** 49 | /// - [CIXRay Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIXRay) 50 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cixray) 51 | /// - [CIFilter.app documentation](https://cifilter.app/CIXRay/) 52 | @available(macOS 10.11, iOS 10, tvOS 10, *) 53 | @objc(CIFFXRay) class XRay: Core { 54 | /// Create an instance of the filter with all default values 55 | @objc public init?() { 56 | super.init(name: "CIXRay") 57 | } 58 | 59 | // MARK: - inputImage (inputImage) 60 | 61 | /// The image to use as an input for the effect. 62 | /// 63 | /// CIFilter attribute information 64 | /// - Attribute key: `inputImage` 65 | /// - Internal class: `CIImage` 66 | /// - Type: `CIAttributeTypeImage` 67 | @objc public var inputImage: CIImage? { 68 | get { 69 | self.keyedValue("inputImage") 70 | } 71 | set { 72 | self.setKeyedValue(newValue, for: "inputImage") 73 | } 74 | } 75 | 76 | // MARK: - Convenience creators 77 | 78 | /// Filter initializer 79 | /// - Parameters: 80 | /// - inputImage: The image to use as an input for the effect. 81 | @objc public convenience init?( 82 | inputImage: CIImage? = nil 83 | ) { 84 | self.init() 85 | if let inputImage = inputImage { 86 | self.inputImage = inputImage 87 | } 88 | } 89 | } 90 | } 91 | 92 | @available(macOS 10.11, iOS 10, tvOS 10, *) 93 | public extension CIImage { 94 | /// Apply the 'X-Ray' filter to this image and return a new filtered image 95 | /// 96 | /// - Parameters: 97 | /// - isActive: If true applies the filter and returns a new image, else returns this image 98 | /// - Returns: The filtered image, or this image if the filter is not active 99 | /// 100 | /// Apply an “XRay” style effect to an image. 101 | /// 102 | /// **Categories**: BuiltIn, ColorEffect, Interlaced, NonSquarePixels, StillImage, Video 103 | /// 104 | /// **Documentation Links** 105 | /// - [CIXRay Online Documentation](http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CIXRay) 106 | /// - [CoreImage.CIFilterBuiltins Xcode documentation](https://developer.apple.com/documentation/coreimage/cixray) 107 | /// - [CIFilter.app documentation](https://cifilter.app/CIXRay/) 108 | @inlinable func applyingXRay( 109 | isActive: Bool = true 110 | ) -> CIImage { 111 | guard isActive else { return self } 112 | return CIFF.XRay( 113 | inputImage: self 114 | )?.outputImage ?? CIImage.empty() 115 | } 116 | } 117 | 118 | #endif // canImport(CoreImage) 119 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/private/CIFF+Logger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CIFF+Logger.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | // Error logging extensions for CIFilterFactory 23 | 24 | #if canImport(OSLog) 25 | 26 | import Foundation 27 | import OSLog 28 | 29 | @available(macOS 11.0, iOS 14, tvOS 14, *) 30 | @usableFromInline internal var _logger: Logger = Logger() 31 | 32 | @available(macOS 11.0, iOS 14, tvOS 14, *) 33 | extension CIFF { 34 | /// Set the logger instance to be used when presenting error messages 35 | public static func SetLogger(_ logger: Logger) { 36 | _logger = logger 37 | } 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/private/Clamping.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Clamp.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | import Foundation 23 | 24 | extension ExpressibleByIntegerLiteral where Self: FloatingPoint { 25 | // Regular range x..) -> Self { 28 | let upper = range.upperBound.nextDown 29 | return min(max(self, range.lowerBound), upper) 30 | } 31 | 32 | // Range up to ..) -> Self { 35 | return min(self, range.upperBound.nextDown) 36 | } 37 | } 38 | 39 | extension ExpressibleByIntegerLiteral where Self: Strideable { 40 | // Regular range x..) -> Self { 43 | let upper = range.upperBound.advanced(by: -1) 44 | return min(max(self, range.lowerBound), upper) 45 | } 46 | 47 | // Range up to ..) -> Self { 50 | return min(self, range.upperBound.advanced(by: -1)) 51 | } 52 | } 53 | 54 | extension ExpressibleByIntegerLiteral where Self: Comparable { 55 | // Closed range x...y 56 | 57 | @inlinable func clamped(to range: ClosedRange) -> Self { 58 | return min(max(self, range.lowerBound), range.upperBound) 59 | } 60 | 61 | // Partial range through ...y 62 | 63 | @inlinable func clamped(to range: PartialRangeThrough) -> Self { 64 | return min(range.upperBound, self) 65 | } 66 | 67 | // Partial range from x... 68 | 69 | @inlinable func clamped(to range: PartialRangeFrom) -> Self { 70 | return max(range.lowerBound, self) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Sources/CIFilterFactory/private/Dictionary+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Dictionary+extensions.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | // MIT license 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 9 | // documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 10 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 11 | // permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all copies or substantial 14 | // portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 17 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 18 | // OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | import Foundation 23 | 24 | extension Dictionary { 25 | /// Returns a new dictionary without the specified key. 26 | func removingValue(forKey key: Key) -> Self { 27 | var result = self 28 | result.removeValue(forKey: key) 29 | return result 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Tests/CIFilterFactoryTests/XCTestManifests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | 3 | #if !canImport(ObjectiveC) 4 | public func allTests() -> [XCTestCaseEntry] { 5 | return [ 6 | testCase(CIFilterFactoryTests.allTests), 7 | ] 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /Tests/CIFilterFactoryTests/resources/sydney.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dagronf/CIFilterFactory/0612970c16dd042afe5aaef68e1e65322f7426a3/Tests/CIFilterFactoryTests/resources/sydney.jpg -------------------------------------------------------------------------------- /Tests/CIFilterFactoryTests/resources/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dagronf/CIFilterFactory/0612970c16dd042afe5aaef68e1e65322f7426a3/Tests/CIFilterFactoryTests/resources/test.jpg -------------------------------------------------------------------------------- /Tools/generator/ciff_generator.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator.xcodeproj/xcshareddata/xcschemes/ciff_generator.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 57 | 58 | 59 | 60 | 66 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/AdditionalOutputKeyMap.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // 4 | // Copyright © 2024 Darren Ford. All rights reserved. 5 | // 6 | 7 | import Foundation 8 | 9 | struct AdditionalOutputKey: Hashable { 10 | let filterName: String 11 | let outputKeyName: String 12 | internal init(_ filterName: String, _ outputKeyName: String) { 13 | self.filterName = filterName 14 | self.outputKeyName = outputKeyName 15 | } 16 | } 17 | 18 | // Map known filter output types with their return type. 19 | // Not all 'additional outputs' have a simple map 20 | // (for example LanczosScaleTransform has outputImageNewScaleX:scaleY:) 21 | // so a simple map isn't possible. 22 | // This is a basic map that I've put together myself 23 | let additionalOutputKeyTypes: Dictionary = [ 24 | AdditionalOutputKey("CIAztecCodeGenerator", "outputCGImage"): "CGImage", 25 | 26 | AdditionalOutputKey("CIBarcodeGenerator", "outputCGImage"): "CGImage", 27 | 28 | AdditionalOutputKey("CICode128BarcodeGenerator", "outputCGImage"): "CGImage", 29 | 30 | AdditionalOutputKey("CIPDF417BarcodeGenerator", "outputCGImage"): "CGImage", 31 | 32 | AdditionalOutputKey("CIQRCodeGenerator", "outputCGImage"): "CGImage", 33 | 34 | AdditionalOutputKey("CIAreaHistogram", "outputData"): "CFData", 35 | AdditionalOutputKey("CIAreaHistogram", "outputImageMPS"): "CIImage", 36 | AdditionalOutputKey("CIAreaHistogram", "outputImageNonMPS"): "CIImage", 37 | 38 | AdditionalOutputKey("CIAreaLogarithmicHistogram", "outputData"): "CFData", 39 | AdditionalOutputKey("CIAreaLogarithmicHistogram", "outputImageMPS"): "CIImage", 40 | AdditionalOutputKey("CIAreaLogarithmicHistogram", "outputImageNonMPS"): "CIImage", 41 | ] 42 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/FileSquirter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FileSquirter.swift 3 | // ciff_generator 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import Foundation 9 | 10 | class FileSquirter { 11 | let name: String 12 | var content: String = "" 13 | init(name: String) { 14 | self.name = name 15 | } 16 | 17 | func print(_ text: String) { 18 | content += text + "\n" 19 | } 20 | func blankLine() { 21 | content += "\n" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/InputKeyType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InputKeyType.swift 3 | // ciff_generator 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import CoreImage 9 | import Foundation 10 | 11 | struct InputKeyType { 12 | let attributeKey: String 13 | let name: String 14 | let keyClass: String 15 | let mappedClass: String? 16 | let description: String 17 | let subtype: String? 18 | let `default`: Any? 19 | 20 | let keyAttributes: [String: Any] 21 | 22 | var `class`: String { 23 | return self.mappedClass ?? self.keyClass 24 | } 25 | 26 | // Map between the CIFilter attribute type and the compatible Swift type 27 | var swiftType: String { 28 | if self.subtype == kCIAttributeTypePosition { 29 | return "CGPoint" 30 | } 31 | else if self.subtype == kCIAttributeTypeRectangle { 32 | return "CGRect" 33 | } 34 | else if self.subtype == kCIAttributeTypeOffset { 35 | return "CGPoint" 36 | } 37 | else if self.class == "NSAffineTransform" { 38 | return "CIAffineTransform" 39 | } 40 | else if self.class == "CGImageMetadataRef" { 41 | return "CGImageMetadata" 42 | } 43 | else if self.subtype == kCIAttributeTypeScalar { 44 | return "Double" 45 | } 46 | else if self.subtype == kCIAttributeTypeDistance { 47 | return "Double" 48 | } 49 | else if self.subtype == kCIAttributeTypeTime { 50 | return "Double" 51 | } 52 | else if self.subtype == kCIAttributeTypeAngle { 53 | return "Double" 54 | } 55 | else if self.subtype == kCIAttributeTypeInteger { 56 | return "Int" 57 | } 58 | else if self.subtype == kCIAttributeTypeBoolean { 59 | return "Bool" 60 | } 61 | else if self.subtype == kCIAttributeTypeCount { 62 | return "UInt" 63 | } 64 | else if self.subtype == kCIAttributeTypePosition3 { 65 | return "CIPosition3" 66 | } 67 | return self.class 68 | } 69 | 70 | // Returns a code generator for the specific swift attribute type 71 | func valueTypeGenerator() -> CoreType { 72 | switch self.swiftType { 73 | case "Double": return DoubleGeneratorType(inputKeyType: self) 74 | case "Int": return IntGeneratorType(inputKeyType: self) 75 | case "UInt": return UIntGeneratorType(inputKeyType: self) 76 | case "Bool": return BoolGeneratorType(inputKeyType: self) 77 | case "CGRect": return RectGeneratorType(inputKeyType: self) 78 | case "CGPoint": return PositionGeneratorType(inputKeyType: self) 79 | case "CIAffineTransform": return AffineGeneratorType(inputKeyType: self) 80 | case "CGImageMetadata": return ImageGeneratorType(inputKeyType: self) 81 | case "String": return StringGeneratorType(inputKeyType: self) 82 | case "Data": return DataGeneratorType(inputKeyType: self) 83 | case "CIPosition3": return CIPosition3Type(inputKeyType: self) 84 | case "CIVector": return CIVectorGeneratorType(inputKeyType: self) 85 | default: return CoreType(inputKeyType: self) 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/String+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+extensions.swift 3 | // ciff_generator 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import Foundation 9 | 10 | extension String { 11 | func index(at offset: Int) -> String.Index { self.index(self.startIndex, offsetBy: offset) } 12 | func substring(from startIndex: String.Index, length: Int) -> String { 13 | return String(self[startIndex ..< self.index(startIndex, offsetBy: length)]) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/generator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // generator.swift 3 | // ciff_generator 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import CoreImage 9 | import Foundation 10 | 11 | class Main { 12 | static func generateAll(outURL: URL) { 13 | Main(outURL: outURL).generate() 14 | } 15 | 16 | let outURL: URL 17 | init(outURL: URL) { 18 | self.outURL = outURL 19 | } 20 | } 21 | 22 | extension Main { 23 | func generate() { 24 | // Get a list of all the filter names 25 | for filterName in CIFilter.filterNames(inCategories: nil) { 26 | if let filter = CIFilter(name: filterName) { 27 | self.generateFilter(filter) 28 | } 29 | } 30 | 31 | // Some additional private apple filters 32 | // for filterName in CIFilter.filterNames(inCategory: "CICategoryApplePrivate") { 33 | // if let filter = CIFilter(name: filterName) { 34 | // self.generateFilter(filter) 35 | // } 36 | // } 37 | } 38 | 39 | // Generate the class definition for a specific filter 40 | func generateFilter(_ filter: CIFilter) { 41 | do { 42 | let filterGenerator = FilterGenerator(filter: filter) 43 | filterGenerator.generate() 44 | if filterGenerator.out.content.count > 0 { 45 | let outURL = outURL.appendingPathComponent("\(filterGenerator.staticName).swift") 46 | try filterGenerator.out.content.write(to: outURL, atomically: true, encoding: .utf8) 47 | } 48 | } 49 | catch { 50 | Swift.print("Cannot write file \(error)") 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Tools/generator/ciff_generator/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // ciff_generator 4 | // 5 | // Copyright © 2024 Darren Ford. All rights reserved. 6 | // 7 | 8 | import Foundation 9 | import CoreImage 10 | 11 | let currentDirectoryURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath) 12 | let outURL = URL(string: CommandLine.arguments[1], relativeTo: currentDirectoryURL)! 13 | 14 | let generatedBase = outURL.appendingPathComponent("generated") 15 | try! FileManager.default.createDirectory(at: generatedBase, withIntermediateDirectories: true, attributes: nil) 16 | 17 | print("Generating CIFilter definitions into \(generatedBase.absoluteURL)") 18 | 19 | Main.generateAll(outURL: generatedBase) 20 | 21 | print("Generating CIFilter complete!") 22 | -------------------------------------------------------------------------------- /Tools/make-docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A simple script to generate a docarchive file for cifilterfactory 4 | 5 | # Make sure we stop if any errors occur 6 | set -e 7 | 8 | # The path where this script resides (/tools folder) 9 | script_path="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 10 | 11 | # The path for the package (one level up) 12 | package_path="$( cd -- "${script_path}/../" >/dev/null 2>&1 ; pwd -P )" 13 | 14 | # The temporary 'docs' folder for generating documentation 15 | temporary_folder="${package_path}/.build/docgenerator" 16 | 17 | echo "Generating docarchive in ${package_path}" 18 | echo "Temporary build location is ${temporary_folder}" 19 | 20 | pushd . 21 | 22 | # We have to run docbuild in the root of the source package 23 | cd "${package_path}" 24 | 25 | # Generate the documentation, using 'docs_path' as the temporary generation folder 26 | echo "Compiling package..." 27 | xcodebuild docbuild -scheme CIFilterFactory -derivedDataPath "${temporary_folder}" -destination "platform=macOS" >/dev/null 28 | 29 | echo "Copying docarchive into position..." 30 | # Copy the resulting docarchive file up to the package folder 31 | cp -R "${temporary_folder}/Build/Products/Debug/CIFilterFactory.doccarchive" . 32 | 33 | #echo "Removing temporary build folder..." 34 | # And remove the temporary docs folder 35 | #rm -r "${temporary_folder}" 36 | 37 | popd 38 | -------------------------------------------------------------------------------- /Tools/regenerate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # A simple script to re-generate the CIFilterFactory.swift file 4 | 5 | # swift ./generate.swift ../Sources/CIFilterFactory 6 | 7 | pushd . 8 | cd generator 9 | xcodebuild -scheme ciff_generator build CONFIGURATION_BUILD_DIR="build" 10 | ./build/ciff_generator ../../Sources/CIFilterFactory 11 | cd .. 12 | 13 | # Comment the next line if you don't want the files formatted automatically 14 | swiftformat --indent tabs --swiftversion 5 --self insert ../Sources/CIFilterFactory/generated/*.swift 15 | 16 | # Make the docs 17 | ./make-docs.sh 18 | --------------------------------------------------------------------------------