{"id":26088826,"url":"https://github.com/fuzzyideas/clopsdk","last_synced_at":"2025-04-12T04:23:27.450Z","repository":{"id":200541096,"uuid":"705754727","full_name":"FuzzyIdeas/ClopSDK","owner":"FuzzyIdeas","description":"ClopSDK is a Swift Package that optimizes images, videos, and PDFs by sending them to the Clop macOS app.","archived":false,"fork":false,"pushed_at":"2025-03-14T19:08:08.000Z","size":2927,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T23:51:24.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FuzzyIdeas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-16T16:20:14.000Z","updated_at":"2025-03-22T10:16:23.000Z","dependencies_parsed_at":"2023-12-07T15:49:45.400Z","dependency_job_id":null,"html_url":"https://github.com/FuzzyIdeas/ClopSDK","commit_stats":null,"previous_names":["fuzzyideas/clopsdk"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuzzyIdeas%2FClopSDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuzzyIdeas%2FClopSDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuzzyIdeas%2FClopSDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuzzyIdeas%2FClopSDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FuzzyIdeas","download_url":"https://codeload.github.com/FuzzyIdeas/ClopSDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248514729,"owners_count":21117016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-09T08:19:49.319Z","updated_at":"2025-04-12T04:23:27.424Z","avatar_url":"https://github.com/FuzzyIdeas.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://lowtechguys.com/clop\"\u003e\u003cimg width=\"128\" height=\"128\" src=\"https://lowtechguys.com/static/img/clop-icon.webp\" style=\"filter: drop-shadow(0px 2px 4px rgba(80, 50, 6, 0.2));\"\u003e\u003c/a\u003e\n    \u003ch1 align=\"center\"\u003e\u003ccode style=\"text-shadow: 0px 3px 10px rgba(8, 0, 6, 0.35); font-size: 3rem; font-family: ui-monospace, Menlo, monospace; font-weight: 800; background: transparent; color: #4d3e56; padding: 0.2rem 0.2rem; border-radius: 6px\"\u003eClop SDK\u003c/code\u003e\u003c/h1\u003e\n    \u003ch5 align=\"center\" style=\"padding: 0; margin: 0; font-family: ui-monospace, monospace; font-weight: 400\"\u003eImage, video, PDF and clipboard optimiser\u003c/h4\u003e\n    \u003ch4 align=\"center\" style=\"padding: 0; margin: 0; font-family: ui-monospace, monospace; font-weight: 700;\"\u003eSoftware Development Kit\u003c/h6\u003e\n\u003c/p\u003e\n\n\nClopSDK is a Swift Package that optimizes images, videos, and PDFs by sending them to the [Clop](https://lowtechguys.com/clop) macOS app.\n\n## Installation\nYou can install ClopSDK using the Swift Package Manager. To add it to your Xcode project, go to File \u003e Swift Packages \u003e Add Package Dependency and enter the URL of this repository.\n\nYou can also add it to a standalone Swift package by adding it to your `Package.swift` file:\n\n```swift\nlet package = Package(\n    name: \"MyPackage\",\n    dependencies: [\n        .package(url: \"https://github.com/FuzzyIdeas/ClopSDK.git\", from: \"1.0.0\")\n    ],\n    targets: [\n        .target(\n            name: \"MyPackage\",\n            dependencies: [\"ClopSDK\"])\n    ]\n)\n```\n\n## Usage\nTo use ClopSDK, simply import it into your Swift file:\n\n```swift\nimport ClopSDK\n```\n\nThen, you can use the `ClopSDK` class to send file paths to the Clop app:\n\n```swift\n// Optimise a single file\ntry ClopSDK.shared.optimise(path: \"/path/to/image.jpg\")\n\n// Optimise multiple files\ntry ClopSDK.shared.optimise(paths: [\"/path/to/image.jpg\", \"/path/to/video.mp4\", \"/path/to/document.pdf\"])\n\n// Send a file to be optimised in background by Clop (don't wait for a response, return immediately)\ntry ClopSDK.shared.optimise(path: \"/path/to/image.jpg\", inTheBackground: true)\n```\n\nThe `optimise` method will connect to a local mach port ([CFMessagePort](https://developer.apple.com/documentation/corefoundation/cfmessageport-rs2#)) that Clop is listening to, and send the file paths to the app through it.\n\nTo make sure the app is running before sending the file paths, you can use the `waitForClopToBeAvailable` method:\n\n```swift\n// Wait for Clop to be available for 5 seconds\nlet clopIsAvailable = ClopSDK.shared.waitForClopToBeAvailable(for: 5)\n```\n\n### Stop running optimisations\n\nYou can stop currently running optimisations by calling the `stopOptimisations` method:\n\n```swift\nClopSDK.shared.stopOptimisations()\n```\n\n### Options\n\nYou can also pass options to the `optimise` method to change the way Clop optimises the files, or to add additional functionality like cropping, downscaling, changing playback speed etc.\n\n```swift\nfunc optimise(\n    urls                   : [URL],\n    aggressive             : Bool       = false,\n    downscaleTo            : Double?    = nil,\n    cropTo                 : CropSize?  = nil,\n    changePlaybackSpeedBy  : Double?    = nil,\n    hideGUI                : Bool       = false,\n    copyToClipboard        : Bool       = false,\n    inTheBackground        : Bool       = false\n) throws -\u003e [OptimisationResponse]\n\n// There are various overloads of the method for convenience in path passing\n\noptimise(path  : FilePath, ...)\noptimise(path  : String, ...)\noptimise(url   : URL, ...)\n\noptimise(paths : [FilePath], ...)\noptimise(paths : [String], ...)\noptimise(urls  : [URL], ...)\n```\n\nThe response will contain the optimised file path, which can be different if the file had to be converted to a more compatible format *(depending on how the app is configured by the user)*.\n\n```swift\nstruct OptimisationResponse {\n    let path: String // The optimised file path\n    let forURL: URL // The original file URL\n    var convertedFrom: String? = nil // File that started the conversion\n\n    var oldBytes = 0 // File size before optimisation\n    var newBytes = 0 // File size after optimisation\n\n    var oldWidthHeight: CGSize? = nil // Dimensions before optimisation\n    var newWidthHeight: CGSize? = nil // Dimensions after optimisation\n}\n```\n\nFor more examples on how to use the SDK, check out the [tests](Tests/ClopSDKTests/ClopSDKTests.swift).\n\n### Objective-C\n\nClopSDK is also available in Objective-C:\n\n```objc\nbool clopIsAvailable = [ClopSDKObjC.shared waitForClopToBeAvailableFor:5];\nif (!clopIsAvailable) {\n    NSLog(@\"Clop is not available\");\n    return;\n}\n\nOptimisationResponseObjC* response = [ClopSDKObjC.shared optimiseWithPath:@\"/path/to/image.png\" error:nil];\nif (response) {\n    NSLog(@\"File optimised at %@\", response.path);\n}\n```\n\n## License\nClopSDK is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzzyideas%2Fclopsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuzzyideas%2Fclopsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzzyideas%2Fclopsdk/lists"}