{"id":20882466,"url":"https://github.com/tayloraswift/swift-jpeg","last_synced_at":"2025-12-11T22:54:26.671Z","repository":{"id":49170079,"uuid":"109662631","full_name":"tayloraswift/swift-jpeg","owner":"tayloraswift","description":"decode, inspect, edit, and encode jpeg images in pure swift","archived":false,"fork":false,"pushed_at":"2024-11-21T16:02:46.000Z","size":64546,"stargazers_count":150,"open_issues_count":6,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-11-29T21:28:32.805Z","etag":null,"topics":["codec","jpeg","multimedia-codecs","pure-swift","swift"],"latest_commit_sha":null,"homepage":"https://swiftinit.org/docs/swift-jpeg/jpeg","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tayloraswift.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-06T07:38:33.000Z","updated_at":"2024-11-27T11:08:17.000Z","dependencies_parsed_at":"2024-11-29T21:40:24.730Z","dependency_job_id":null,"html_url":"https://github.com/tayloraswift/swift-jpeg","commit_stats":null,"previous_names":["kelvin13/jpeg","tayloraswift/swift-jpeg","tayloraswift/jpeg"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tayloraswift%2Fswift-jpeg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tayloraswift%2Fswift-jpeg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tayloraswift%2Fswift-jpeg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tayloraswift%2Fswift-jpeg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tayloraswift","download_url":"https://codeload.github.com/tayloraswift/swift-jpeg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276164,"owners_count":20912288,"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":["codec","jpeg","multimedia-codecs","pure-swift","swift"],"created_at":"2024-11-18T07:31:52.583Z","updated_at":"2025-12-11T22:54:21.617Z","avatar_url":"https://github.com/tayloraswift.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n***`jpeg`***\n\n[![Tests](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml)\n[![Documentation](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Documentation.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Documentation.yml)\n\n\u003c/div\u003e\n\n\nSwift *JPEG* is a cross-platform pure Swift framework for decoding, inspecting, editing, and encoding JPEG images. The core framework has no external dependencies, including *Foundation*, and should compile and provide consistent behavior on *all* Swift platforms. The framework supports additional features, such as file system support, on Linux and MacOS.\n\nSwift *JPEG* is available under the [Apache 2.0 License](LICENSE). The [example programs](Snippets/) are public domain and can be adapted freely.\n\n\u003cdiv align=\"center\"\u003e\n\n[documentation](https://swiftinit.org/docs/swift-jpeg/jpeg) ·\n[license](LICENSE)\n\n\u003c/div\u003e\n\n\n## Requirements\n\nThe swift-jpeg library requires Swift 5.10 or later.\n\n\n| Platform | Status |\n| -------- | ------ |\n| 🐧 Linux | [![Tests](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml) |\n| 🍏 Darwin | [![Tests](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/Tests.yml) |\n| 🍏 Darwin (iOS) | [![iOS](https://github.com/tayloraswift/swift-jpeg/actions/workflows/iOS.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/iOS.yml) |\n| 🍏 Darwin (tvOS) | [![tvOS](https://github.com/tayloraswift/swift-jpeg/actions/workflows/tvOS.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/tvOS.yml) |\n| 🍏 Darwin (visionOS) | [![visionOS](https://github.com/tayloraswift/swift-jpeg/actions/workflows/visionOS.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/visionOS.yml) |\n| 🍏 Darwin (watchOS) | [![watchOS](https://github.com/tayloraswift/swift-jpeg/actions/workflows/watchOS.yml/badge.svg)](https://github.com/tayloraswift/swift-jpeg/actions/workflows/watchOS.yml) |\n\n\n[Check deployment minimums](https://swiftinit.org/docs/swift-jpeg#ss:platform-requirements)\n\n\n## [tutorials and example programs](examples/)\n\n* [basic decoding](examples#basic-decoding)\n* [basic encoding](examples#basic-encoding)\n* [advanced decoding](examples#advanced-decoding)\n* [advanced encoding](examples#advanced-encoding)\n* [using in-memory images](examples#using-in-memory-images)\n* [online decoding](examples#online-decoding)\n* [requantizing images](examples#requantizing-images)\n* [lossless rotations](examples#lossless-rotations)\n* [custom color formats](examples#custom-color-formats)\n\n## [api reference](https://swiftinit.org/docs/swift-jpeg/jpeg/)\n\n* [`JPEG.JPEG`](https://swiftinit.org/docs/swift-jpeg/jpeg/jpeg)\n* [`JPEG.General`](https://swiftinit.org/docs/swift-jpeg/jpeg/general)\n* [`JPEG.System`](https://swiftinit.org/docs/swift-jpeg/jpegsystem/system)\n\n## getting started\n\nTo Swift *JPEG* in a project, add this descriptor to the `dependencies` list in your `Package.swift`:\n\n```swift\n.package(url: \"https://github.com/tayloraswift/swift-jpeg\", from: \"2.0.0\")\n```\n\n## basic usage\n\nDecode an image:\n\n```swift\nimport JPEG\nfunc decode(jpeg path:String) throws\n{\n    guard let image:JPEG.Data.Rectangular\u003cJPEG.Common\u003e = try .decompress(path: path)\n    else\n    {\n        // failed to access file from file system\n    }\n\n    let rgb:[JPEG.RGB]      = image.unpack(as: JPEG.RGB.self),\n        size:(x:Int, y:Int) = image.size\n    // ...\n}\n```\n\nEncode an image:\n\n```swift\nimport JPEG\nfunc encode(jpeg path:String, size:(x:Int, y:Int), pixels:[JPEG.RGB],\n    compression:Double) // 0.0 = highest quality\n    throws\n{\n    let layout:JPEG.Layout\u003cJPEG.Common\u003e = .init(\n        format:     .ycc8,\n        process:    .baseline,\n        components:\n        [\n            1: (factor: (2, 2), qi: 0), // Y\n            2: (factor: (1, 1), qi: 1), // Cb\n            3: (factor: (1, 1), qi: 1), // Cr\n        ],\n        scans:\n        [\n            .sequential((1, \\.0, \\.0), (2, \\.1, \\.1), (3, \\.1, \\.1)),\n        ])\n    let jfif:JPEG.JFIF = .init(version: .v1_2, density: (72, 72, .inches))\n    let image:JPEG.Data.Rectangular\u003cJPEG.Common\u003e =\n        .pack(size: size, layout: layout, metadata: [.jfif(jfif)], pixels: rgb)\n\n    try image.compress(path: path, quanta:\n    [\n        0: JPEG.CompressionLevel.luminance(  compression).quanta,\n        1: JPEG.CompressionLevel.chrominance(compression).quanta\n    ])\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftayloraswift%2Fswift-jpeg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftayloraswift%2Fswift-jpeg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftayloraswift%2Fswift-jpeg/lists"}