{"id":18031728,"url":"https://github.com/dagronf/ppmkit","last_synced_at":"2025-04-04T21:43:41.895Z","repository":{"id":65000472,"uuid":"579910598","full_name":"dagronf/PPMKit","owner":"dagronf","description":"Simple read/write PPM files (P3/P6) in Swift (macOS, iOS, tvOS, watchOS, macCatalyst, Linux)","archived":false,"fork":false,"pushed_at":"2023-10-22T01:01:05.000Z","size":726,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T20:17:32.424Z","etag":null,"topics":["ppm","ppm-image"],"latest_commit_sha":null,"homepage":"","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/dagronf.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":"2022-12-19T08:47:15.000Z","updated_at":"2024-08-25T19:12:49.000Z","dependencies_parsed_at":"2023-01-01T00:29:55.576Z","dependency_job_id":"39335eb6-bde6-47ff-af7a-7cb9e5cc2f78","html_url":"https://github.com/dagronf/PPMKit","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"245a61d08c99ca2c8a0e3d2f4aba7dac41e11393"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FPPMKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FPPMKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FPPMKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dagronf%2FPPMKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dagronf","download_url":"https://codeload.github.com/dagronf/PPMKit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256072,"owners_count":20909240,"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":["ppm","ppm-image"],"created_at":"2024-10-30T10:10:35.822Z","updated_at":"2025-04-04T21:43:41.877Z","avatar_url":"https://github.com/dagronf.png","language":"Swift","readme":"# PPMKit\n\nSimple read/write PPM files (P3/P6) in Swift (macOS, iOS, tvOS, watchOS, macCatalyst, Linux).\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/tag/dagronf/PPMKit\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-lightgrey\" /\u003e\n    \u003ca href=\"https://swift.org/package-manager\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat\" alt=\"Swift Package Manager\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Read a PPM file\n\n### Load a PPM file as a CGImage\n\n```swift\nlet ppmData = Data(...)\nlet cgImage = try PPM.readImage(data: ppmData)\n```\n\n### Load raw PPM image data from a file\n\n```swift\nlet image: PPM.Image = try PPM.read(fileURL: ppm1URL)\n// width = image.width\n// height = image.height\n// rawRGBBytes = image.data \n```\n\n## Write a PPM file\n\n### Write a CGImage to a PPM file\n\nNOTE: PPM doesn't support transparency, so any transparency information is lost.\n\n```swift\nlet cgImage = CGImage(...)\nlet data = try PPM.writeImage(cgImage, format: .P3)\n```\n\n### Write raw RGB data to a PPM file\n\n```swift\nlet image = PPM.Image(...)\ntry image.write(format: .P3, fileURL: \u003csome_url\u003e)\n```\n\n### Create PPM data from raw pixels\n\n```swift\npublic static func image(rgbData: [PPM.RGB], width: Int, height: Int) throws -\u003e PPM.Image\n```\n\nNote: The number of pixels in the rgbData array *must* be equal to `width` * `height`\n\n```swift\nlet pixels: [PPM.RGB] = [ ... ]\nlet image = PPM.image(rgbData: pixels, width: 100, height: 100)\n```\n\n## Linux support\n\n* Linux only supports very naive color conversions between RGB-CMYK-Gray.\n\n### To build/test linux support using a mac\n\nSee: [Testing Swift packages on Linux using Docker](https://oleb.net/2020/swift-docker-linux/)\n\n1. Install [Docker Desktop for Mac](https://www.docker.com/products/docker-desktop) on your mac\n2. Make sure that docker is running (or else the next command will fail with a weird or no error message)\n3. Run the following command in the directory you want to mirror in your linux \n\t\n```bash\ndocker run --rm --privileged --interactive --tty --volume \"$(pwd):/src\" --workdir \"/src\" swift:latest\n```\n\nNow, from within the docker container, run \n\n```bash\nswift build\nswift test\n```\n\nNote that the /src directory in the Linux container is a direct mirror of the current directory on the host OS, not a copy. If you delete a file in /src in the Linux container, that file will be gone on the host OS, too.\n\n# License\n\n```\nMIT License\n\nCopyright (c) 2022 Darren Ford\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fppmkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdagronf%2Fppmkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdagronf%2Fppmkit/lists"}