{"id":39470,"date":"2023-05-22T16:35:56","date_gmt":"2023-05-22T20:35:56","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=39470"},"modified":"2023-05-22T16:35:56","modified_gmt":"2023-05-22T20:35:56","slug":"swiftuicoreimage","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2023\/05\/22\/swiftuicoreimage\/","title":{"rendered":"SwiftUICoreImage"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/danwood\/SwiftUICoreImage\">Dan Wood<\/a>:<\/p>\n<blockquote cite=\"https:\/\/github.com\/danwood\/SwiftUICoreImage\"><p>Core Image is a wonderful image-processsing toolkit in macOS and iOS, but it&rsquo;s a bit clunky to use. Even after Apple added Swift APIs to many of the filters (<a href=\"https:\/\/developer.apple.com\/documentation\/coreimage\/methods_and_protocols_for_filter_creation\">CoreImage.CIFilterBuiltins<\/a>), it&rsquo;s still pretty tedious to chain filters to images.<\/p><p>The purpose of this package is to provide an easier way to chain multiple filters to CIImage instances and then render them into SwiftUI (or any other context &mdash; SwiftUI is not needed).<\/p><p>[&#8230;]<\/p><p>Similarly to how SwiftUI view modifiers each return a modified <code>View<\/code> instance, these modifiers on <code>CIImage<\/code> take care of the core image chaining by creating a corresponding <code>CIFilter<\/code>, hooking up the <code>inputImage<\/code> for you, and returning the resulting <code>outputImage<\/code>.<\/p><p>[&#8230;]<\/p><p>The contents of CIImage-Filters.swift are generated source code, using code that I&rsquo;ve included in this repository (<code>CIImage-Generation.swift<\/code>, not included in the package import). This loops through the core image metadata that Apple provides (<code>CIFilter.filterNames(inCategories: nil)<\/code>). Unfortunately this list is somewhat out of date and contains a number of inconsistencies that I&rsquo;ve done my best to overcome.<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Dan Wood: Core Image is a wonderful image-processsing toolkit in macOS and iOS, but it&rsquo;s a bit clunky to use. Even after Apple added Swift APIs to many of the filters (CoreImage.CIFilterBuiltins), it&rsquo;s still pretty tedious to chain filters to images.The purpose of this package is to provide an easier way to chain multiple filters [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2023-05-22T20:35:58Z","apple_news_api_id":"ada3bd74-bfbd-4f9f-a99b-c85140c80b41","apple_news_api_modified_at":"2023-05-22T20:35:58Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AraO9dL-9T5-pm8hRQMgLQQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[69,888,220,31,2185,30,2223,74,71,901,1812],"class_list":["post-39470","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-cocoa","tag-code-generation","tag-coreimage","tag-ios","tag-ios-16","tag-mac","tag-macos-13-ventura","tag-opensource","tag-programming","tag-swift-programming-language","tag-swiftui"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39470","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=39470"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39470\/revisions"}],"predecessor-version":[{"id":39471,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/39470\/revisions\/39471"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=39470"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=39470"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=39470"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}