All Projects → kelvin13 → jpeg

kelvin13 / jpeg

Licence: MPL-2.0 License
decode, inspect, edit, and encode jpeg images in pure swift

Programming Languages

swift
15916 projects
shell
77523 projects

Projects that are alternatives of or similar to jpeg

codecinfo
Detailed listing of multimedia codecs on an Android device
Stars: ✭ 33 (-72.27%)
Mutual labels:  codec, multimedia-codecs
neural-imaging
[CVPR'19, ICLR'20] A Python toolbox for modeling and optimization of photo acquisition & distribution pipelines (camera ISP, compression, forensics, manipulation detection)
Stars: ✭ 109 (-8.4%)
Mutual labels:  jpeg, codec
octodex
GitHub's Octocats.
Stars: ✭ 64 (-46.22%)
Mutual labels:  jpeg
wasm-jpeg-ijg
Demo from Chrome Dev Summit of using Web Assembly to optimize images in a browser
Stars: ✭ 54 (-54.62%)
Mutual labels:  jpeg
downscale
Better image downscale with canvas.
Stars: ✭ 80 (-32.77%)
Mutual labels:  jpeg
hsexif
Exif parser in pure haskell
Stars: ✭ 18 (-84.87%)
Mutual labels:  jpeg
STM32 TFT 8bit
STM32F103 8bit parallel TFT Library for Arduino_STM32
Stars: ✭ 45 (-62.18%)
Mutual labels:  jpeg
mozjpeg-sys
Rust bindings for mozjpeg
Stars: ✭ 26 (-78.15%)
Mutual labels:  jpeg
dartexif
Dart package to decode Exif data from tiff, jpeg and heic files
Stars: ✭ 16 (-86.55%)
Mutual labels:  jpeg
inumon
A high-level image I/O and manipulation library for Nim
Stars: ✭ 30 (-74.79%)
Mutual labels:  jpeg
yoga-image-optimizer
A graphical tool to convert and optimize JPEG, PNG and WebP images (based on YOGA)
Stars: ✭ 85 (-28.57%)
Mutual labels:  jpeg
TinyJPG
images jpg or jpeg compressed and watcher fsnotify
Stars: ✭ 73 (-38.66%)
Mutual labels:  jpeg
HEIF-converter
Converter for High Efficiency Image Format(HEIF)
Stars: ✭ 24 (-79.83%)
Mutual labels:  jpeg
m3u8
Parse and generate m3u8 playlists for Apple HTTP Live Streaming (HLS) in Ruby.
Stars: ✭ 96 (-19.33%)
Mutual labels:  codec
librfxcodec
JPEG2000 codec for RDP
Stars: ✭ 18 (-84.87%)
Mutual labels:  codec
wrender
Image compression and transformation reverse-proxy for Express apps
Stars: ✭ 14 (-88.24%)
Mutual labels:  jpeg
record-encode-audio-from-browser
Record/Encode Audio on Browser using the WebAudio API and "ported" libraries.
Stars: ✭ 55 (-53.78%)
Mutual labels:  codec
android-opus-codec
Implementation of Opus encoder and decoder in C++ for android with JNI
Stars: ✭ 44 (-63.03%)
Mutual labels:  codec
alawmulaw
A-Law and mu-Law codecs in JavaScript.
Stars: ✭ 22 (-81.51%)
Mutual labels:  codec
schifra
C++ Reed Solomon Error Correcting Library https://www.schifra.com
Stars: ✭ 28 (-76.47%)
Mutual labels:  codec

jpeg

platforms releases build build documentation issues language license

Swift 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.

Swift JPEG is available under the Mozilla Public License 2.0. The example programs are public domain and can be adapted freely.

tutorials and example programs

api reference

getting started

To Swift JPEG in a project, add this descriptor to the dependencies list in your Package.swift:

.package(url: "https://github.com/kelvin13/jpeg", .exact("1.0.0")) 

basic usage

Decode an image:

import JPEG
func decode(jpeg path:String) throws
{
    guard let image:JPEG.Data.Rectangular<JPEG.Common> = try .decompress(path: path)
    else 
    {
        // failed to access file from file system
    }

    let rgb:[JPEG.RGB]      = image.unpack(as: JPEG.RGB.self), 
        size:(x:Int, y:Int) = image.size
    // ...
}

Encode an image:

import JPEG
func encode(jpeg path:String, size:(x:Int, y:Int), pixels:[JPEG.RGB], 
    compression:Double) // 0.0 = highest quality
    throws 
{
    let layout:JPEG.Layout<JPEG.Common> = .init(
        format:     .ycc8,
        process:    .baseline, 
        components: 
        [
            1: (factor: (2, 2), qi: 0), // Y
            2: (factor: (1, 1), qi: 1), // Cb
            3: (factor: (1, 1), qi: 1), // Cr 
        ], 
        scans: 
        [
            .sequential((1, \.0, \.0), (2, \.1, \.1), (3, \.1, \.1)),
        ])
    let jfif:JPEG.JFIF = .init(version: .v1_2, density: (72, 72, .inches))
    let image:JPEG.Data.Rectangular<JPEG.Common> = 
        .pack(size: size, layout: layout, metadata: [.jfif(jfif)], pixels: rgb)

    try image.compress(path: path, quanta: 
    [
        0: JPEG.CompressionLevel.luminance(  compression).quanta,
        1: JPEG.CompressionLevel.chrominance(compression).quanta
    ])
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].