{"id":28521072,"url":"https://github.com/cykooz/fast_image_resize","last_synced_at":"2026-01-16T08:06:35.037Z","repository":{"id":37943686,"uuid":"382588654","full_name":"Cykooz/fast_image_resize","owner":"Cykooz","description":"Rust library for fast image resizing with using of SIMD instructions.","archived":false,"fork":false,"pushed_at":"2025-05-16T13:46:48.000Z","size":69521,"stargazers_count":361,"open_issues_count":2,"forks_count":35,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-06-09T07:09:22.676Z","etag":null,"topics":["image","resize","resize-image","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/Cykooz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","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,"zenodo":null}},"created_at":"2021-07-03T10:35:39.000Z","updated_at":"2025-06-05T09:32:50.000Z","dependencies_parsed_at":"2024-05-04T14:46:45.127Z","dependency_job_id":"abb290cf-43d1-43b2-b641-ab39d8140529","html_url":"https://github.com/Cykooz/fast_image_resize","commit_stats":{"total_commits":175,"total_committers":7,"mean_commits":25.0,"dds":"0.11428571428571432","last_synced_commit":"8548ee562b16888461f1a6487e43c55ebf83dff6"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/Cykooz/fast_image_resize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cykooz%2Ffast_image_resize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cykooz%2Ffast_image_resize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cykooz%2Ffast_image_resize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cykooz%2Ffast_image_resize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cykooz","download_url":"https://codeload.github.com/Cykooz/fast_image_resize/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cykooz%2Ffast_image_resize/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263369521,"owners_count":23456314,"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":["image","resize","resize-image","rust-lang"],"created_at":"2025-06-09T07:08:37.866Z","updated_at":"2026-01-16T08:06:34.834Z","avatar_url":"https://github.com/Cykooz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast_image_resize\n\n[![github](https://img.shields.io/badge/github-Cykooz%2Ffast__image__resize-8da0cb?logo=github)](https://github.com/Cykooz/fast_image_resize)\n[![crates.io](https://img.shields.io/crates/v/fast_image_resize.svg?logo=rust)](https://crates.io/crates/fast_image_resize)\n[![docs.rs](https://img.shields.io/badge/docs.rs-fast__image__resize-66c2a5?logo=docs.rs)](https://docs.rs/fast_image_resize)\n\nRust library for fast image resizing with using of SIMD instructions.\n\n[CHANGELOG](https://github.com/Cykooz/fast_image_resize/blob/main/CHANGELOG.md)\n\nSupported pixel formats and available optimizations:\n\n| Format | Description                                                   | SSE4.1 | AVX2 | Neon | Wasm32 SIMD128 |\n|:------:|:--------------------------------------------------------------|:------:|:----:|:----:|:--------------:|\n|   U8   | One `u8` component per pixel (e.g. L)                         |   +    |  +   |  +   |       +        |\n|  U8x2  | Two `u8` components per pixel (e.g. LA)                       |   +    |  +   |  +   |       +        |\n|  U8x3  | Three `u8` components per pixel (e.g. RGB)                    |   +    |  +   |  +   |       +        |\n|  U8x4  | Four `u8` components per pixel (e.g. RGBA, RGBx, CMYK)        |   +    |  +   |  +   |       +        |\n|  U16   | One `u16` components per pixel (e.g. L16)                     |   +    |  +   |  +   |       +        |\n| U16x2  | Two `u16` components per pixel (e.g. LA16)                    |   +    |  +   |  +   |       +        |\n| U16x3  | Three `u16` components per pixel (e.g. RGB16)                 |   +    |  +   |  +   |       +        |\n| U16x4  | Four `u16` components per pixel (e.g. RGBA16, RGBx16, CMYK16) |   +    |  +   |  +   |       +        |\n|  I32   | One `i32` component per pixel (e.g. L32)                      |   -    |  -   |  -   |       -        |\n|  F32   | One `f32` component per pixel (e.g. L32F)                     |   +    |  +   |  -   |       -        |\n| F32x2  | Two `f32` components per pixel (e.g. LA32F)                   |   +    |  +   |  -   |       -        |\n| F32x3  | Three `f32` components per pixel (e.g. RGB32F)                |   +    |  +   |  -   |       -        |\n| F32x4  | Four `f32` components per pixel (e.g. RGBA32F)                |   +    |  +   |  -   |       -        |\n\n## Colorspace\n\nResizer from this crate does not convert image into linear colorspace\nduring a resize process. If it is important for you to resize images with a\nnon-linear color space (e.g. sRGB) correctly, then you have to convert\nit to a linear color space before resizing and convert back to the color space of\nresult image. [Read more](http://www.ericbrasseur.org/gamma.html)\nabout resizing with respect to color space.\n\nThis crate provides the\n[PixelComponentMapper](https://docs.rs/fast_image_resize/latest/fast_image_resize/struct.PixelComponentMapper.html)\nstructure that allows you to create colorspace converters for images\nwhose pixels based on `u8` and `u16` components.\n\nIn addition, the crate contains functions `create_gamma_22_mapper()`\nand `create_srgb_mapper()` to create instance of `PixelComponentMapper`\nthat converts images from sRGB or gamma 2.2 into linear colorspace and back.\n\n## Multi-threading\n\nYou should enable `\"rayon\"` feature to turn on image processing in\n[rayon](https://docs.rs/rayon/latest/rayon/) thread pool.\n\n## Use in a `no_std` environment\n\nTo use the crate in a `no_std` environment you must disable\ndefault features and enabled the `no_std` feature:\n\n```toml\n[dependencies]\nfast_image_resize = { version = \"6.0\", default-features = false, features = [\"no_std\"] }\n```\n\n## Some benchmarks in single-threaded mode for x86_64\n\n_All benchmarks:_\n[_x86_64_](https://github.com/Cykooz/fast_image_resize/blob/main/benchmarks-x86_64.md),\n[_ARM64_](https://github.com/Cykooz/fast_image_resize/blob/main/benchmarks-arm64.md),\n[_WASM32_](https://github.com/Cykooz/fast_image_resize/blob/main/benchmarks-wasm32.md).\n\nOther libraries used to compare of resizing speed:\n\n- image (\u003chttps://crates.io/crates/image\u003e)\n- resize (\u003chttps://crates.io/crates/resize\u003e, single-threaded mode)\n- libvips (single-threaded mode)\n\n\u003c!-- bench_compare_rgb start --\u003e\n\n### Resize RGB8 image (U8x3) 4928x3279 =\u003e 852x567\n\nPipeline:\n\n`src_image =\u003e resize =\u003e dst_image`\n\n- Source image [nasa-4928x3279.png](https://github.com/Cykooz/fast_image_resize/blob/main/data/nasa-4928x3279.png)\n- Numbers in the table mean a duration of image resizing in milliseconds.\n\n|            | Nearest |  Box  | Bilinear | Bicubic | Lanczos3 |\n|------------|:-------:|:-----:|:--------:|:-------:|:--------:|\n| image      |  29.28  |   -   |  83.28   | 136.97  |  189.93  |\n| resize     |  7.42   | 26.82 |  49.29   |  93.22  |  140.26  |\n| libvips    |  2.42   | 61.73 |   5.66   |  9.81   |  15.78   |\n| fir rust   |  0.28   | 10.87 |  16.12   |  26.63  |  38.08   |\n| fir sse4.1 |  0.28   | 3.37  |   5.34   |  9.89   |  15.30   |\n| fir avx2   |  0.28   | 2.52  |   3.67   |  6.80   |  13.21   |\n\n\u003c!-- bench_compare_rgb end --\u003e\n\n\u003c!-- bench_compare_rgba start --\u003e\n\n### Resize RGBA8 image (U8x4) 4928x3279 =\u003e 852x567\n\nPipeline:\n\n`src_image =\u003e multiply by alpha =\u003e resize =\u003e divide by alpha =\u003e dst_image`\n\n- Source image\n  [nasa-4928x3279-rgba.png](https://github.com/Cykooz/fast_image_resize/blob/main/data/nasa-4928x3279-rgba.png)\n- Numbers in the table mean a duration of image resizing in milliseconds.\n- The `image` crate does not support multiplying and dividing by alpha channel.\n\n|            | Nearest |  Box   | Bilinear | Bicubic | Lanczos3 |\n|------------|:-------:|:------:|:--------:|:-------:|:--------:|\n| resize     |  9.59   | 34.02  |  64.61   | 126.43  |  187.18  |\n| libvips    |  4.19   | 169.02 |  142.22  | 228.64  |  330.24  |\n| fir rust   |  0.19   | 20.30  |  25.25   |  36.57  |  49.69   |\n| fir sse4.1 |  0.19   |  9.51  |  11.90   |  17.78  |  24.49   |\n| fir avx2   |  0.19   |  7.11  |   8.39   |  13.68  |  21.72   |\n\n\u003c!-- bench_compare_rgba end --\u003e\n\n\u003c!-- bench_compare_l start --\u003e\n\n### Resize L8 image (U8) 4928x3279 =\u003e 852x567\n\nPipeline:\n\n`src_image =\u003e resize =\u003e dst_image`\n\n- Source image [nasa-4928x3279.png](https://github.com/Cykooz/fast_image_resize/blob/main/data/nasa-4928x3279.png)\n  has converted into grayscale image with one byte per pixel.\n- Numbers in the table mean a duration of image resizing in milliseconds.\n\n|            | Nearest |  Box  | Bilinear | Bicubic | Lanczos3 |\n|------------|:-------:|:-----:|:--------:|:-------:|:--------:|\n| image      |  26.90  |   -   |  56.49   |  85.11  |  112.72  |\n| resize     |  6.57   | 11.06 |  18.83   |  38.44  |  63.98   |\n| libvips    |  2.62   | 24.92 |   6.81   |  9.84   |  12.73   |\n| fir rust   |  0.16   | 4.42  |   5.45   |  8.69   |  12.04   |\n| fir sse4.1 |  0.16   | 1.45  |   2.02   |  3.37   |   5.44   |\n| fir avx2   |  0.16   | 1.51  |   1.73   |  2.74   |   4.11   |\n\n\u003c!-- bench_compare_l end --\u003e\n\n## Examples\n\n### Resize RGBA8 image\n\nNote: You must enable `\"image\"` feature to support of\n[image::DynamicImage](https://docs.rs/image/latest/image/enum.DynamicImage.html).\nOtherwise, you have to convert such images into supported by the crate image type.\n\n```rust\nuse std::io::BufWriter;\n\nuse image::codecs::png::PngEncoder;\nuse image::{ExtendedColorType, ImageEncoder, ImageReader};\n\nuse fast_image_resize::{IntoImageView, Resizer};\nuse fast_image_resize::images::Image;\n\nfn main() {\n    // Read source image from file\n    let src_image = ImageReader::open(\"./data/nasa-4928x3279.png\")\n        .unwrap()\n        .decode()\n        .unwrap();\n\n    // Create container for data of destination image\n    let dst_width = 1024;\n    let dst_height = 768;\n    let mut dst_image = Image::new(\n        dst_width,\n        dst_height,\n        src_image.pixel_type().unwrap(),\n    );\n\n    // Create Resizer instance and resize source image\n    // into buffer of destination image\n    let mut resizer = Resizer::new();\n    resizer.resize(\u0026src_image, \u0026mut dst_image, None).unwrap();\n\n    // Write destination image as PNG-file\n    let mut result_buf = BufWriter::new(Vec::new());\n    PngEncoder::new(\u0026mut result_buf)\n        .write_image(\n            dst_image.buffer(),\n            dst_width,\n            dst_height,\n            src_image.color().into(),\n        )\n        .unwrap();\n}\n```\n\n### Resize with cropping\n\n```rust\nuse image::codecs::png::PngEncoder;\nuse image::{ColorType, ImageReader, GenericImageView};\n\nuse fast_image_resize::{IntoImageView, Resizer, ResizeOptions};\nuse fast_image_resize::images::Image;\n\nfn main() {\n    let img = ImageReader::open(\"./data/nasa-4928x3279.png\")\n        .unwrap()\n        .decode()\n        .unwrap();\n\n    // Create container for data of destination image\n    let mut dst_image = Image::new(\n        1024,\n        768,\n        img.pixel_type().unwrap(),\n    );\n\n    // Create Resizer instance and resize cropped source image\n    // into buffer of destination image\n    let mut resizer = Resizer::new();\n    resizer.resize(\n        \u0026img,\n        \u0026mut dst_image,\n        \u0026ResizeOptions::new().crop(\n            10.0,   // left \n            10.0,   // top\n            2000.0, // width\n            2000.0, // height\n        ),\n    ).unwrap();\n}\n```\n\n### Change CPU extensions used by resizer\n\n```rust, no_run\nuse fast_image_resize as fr;\n\nfn main() {\n    let mut resizer = fr::Resizer::new();\n    #[cfg(target_arch = \"x86_64\")]\n    unsafe {\n        resizer.set_cpu_extensions(fr::CpuExtensions::Sse4_1);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcykooz%2Ffast_image_resize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcykooz%2Ffast_image_resize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcykooz%2Ffast_image_resize/lists"}