libjpeg-turbo VS stb

Compare libjpeg-turbo vs stb and see what are their differences.

stb

stb single-file public domain libraries for C/C++ (by nothings)
Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
libjpeg-turbo stb
15 164
3,582 25,071
1.3% -
8.4 6.7
14 days ago 10 days ago
C C
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

libjpeg-turbo

Posts with mentions or reviews of libjpeg-turbo. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-04-03.
  • Jpegli: A New JPEG Coding Library
    9 projects | news.ycombinator.com | 3 Apr 2024
    > all decoders will render the same pixels

    Not true. Even just within libjpeg, there are three different IDCT implementations (jidctflt.c, jidctfst.c, jidctint.c) and they produce different pixels (it's a classic speed vs quality trade-off). It's spec-compliant to choose any of those.

    A few years ago, in libjpeg-turbo, they changed the smoothing kernel used for decoding (incomplete) progressive JPEGs, from a 3x3 window to 5x5. This meant the decoder produced different pixels, but again, that's still valid:

    https://github.com/libjpeg-turbo/libjpeg-turbo/commit/6d91e9...

  • My personal C coding style as of late 2023
    1 project | news.ycombinator.com | 8 Oct 2023
    Last vestiges of this fact AFAIK were libjpeg, which had a macro NEED_SHORT_EXTERNAL_NAMES that shortens all public identifiers to have unique 6-letter-long prefixes. Libjpeg-turbo nowadays has removed them though [1].

    [1] https://github.com/libjpeg-turbo/libjpeg-turbo/commit/52ded8...

  • Libjpeg-Turbo 3.0.0
    1 project | news.ycombinator.com | 4 Jul 2023
  • Why there may never be a libjpeg-turbo 3.1
    4 projects | news.ycombinator.com | 4 Jul 2023
    While I think the move to safer code through Rust and other alternatives is a nice breath of fresh air, I doubt you can get these kinds of optimization without using unsafe code in Rust. These optimized implementations often require some kind of safety-bypassing memory modifications to work as efficiently ad they do.

    There's a reason https://github.com/libjpeg-turbo/libjpeg-turbo/tree/main/sim... is filled with assembly files with conditional loading.

  • Learn x86-64 assembly by writing a GUI from scratch
    11 projects | news.ycombinator.com | 1 Jun 2023
    Sure. You'll see it very often in codec implementations. From rav1e, a fast AV1 encoder mostly written in Rust: https://github.com/xiph/rav1e/tree/master/src/x86

    Large portions of the algorithm have been translated into assembly for ARM and x86. Shaving even a couple percent off something like motion compensation search will add up to meaningful gains.

    Or the current reference implementation of JPEG: https://github.com/libjpeg-turbo/libjpeg-turbo/tree/main/sim...

  • Announcing zune-jpeg: Rust's fastest JPEG decoder
    7 projects | /r/rust | 1 Mar 2023
    zune-jpeg is 1.5x to 2x faster than jpeg-decoder and is on par with libjpeg-turbo.
  • JDK 21 - Image Performance Improvements
    3 projects | /r/java | 13 Feb 2023
    This is interesting from the standpoint of how new JVM features can be used to improve performance (what I presume the article's main purpose to have been), but the image processing improvement itself isn't head-turning. Also, we've found that libjpeg-turbo (https://libjpeg-turbo.org/) is ~5x (IIRC, can re-run my JMH benchmark if anyone wants me to) as fast for decoding JPEGs as ImageIO, so we wouldn't even benefit from this change in 21 much.
  • Convenient CPU feature detection and dispatch in the Magnum Engine
    9 projects | /r/cpp | 2 Aug 2022
    libjpeg-turbo: https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/simd/x86_64/jsimdcpu.asm
  • Implementing SVE2 for Open Source Project
    1 project | dev.to | 28 Mar 2022
    libjpeg-turbo
  • How to go about implementing file encoding [Question]
    1 project | /r/cpp | 3 Oct 2021
    For all but the simplest formats (basically BMP), the difficulty of implementing encoding/decoding from scratch is significant - well beyond a beginner's ability, and challenging/time-consuming even for senior developers. So, libraries are used in practice - e.g. libpng and libjpeg-turbo.

stb

Posts with mentions or reviews of stb. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-01-09.
  • Lessons learned about how to make a header-file library (2013)
    1 project | news.ycombinator.com | 28 Feb 2024
  • Nebula is an open-source and free-to-use modern C++ game engine
    6 projects | news.ycombinator.com | 9 Jan 2024
    Have you considered not using an engine at all, in favor of libraries? There are many amazing libraries I've used for game development - all in C/C++ - that you can piece together:

    * General: [stb](https://github.com/nothings/stb)

  • STB: Single-file public domain libraries for C/C++
    4 projects | news.ycombinator.com | 6 Jan 2024
  • Writing a TrueType font renderer
    9 projects | news.ycombinator.com | 1 Jan 2024
    Great to see more accessible references on font internals. I have dabbled on this a bit last year and managed to have a parser and render the points of a glyph's contour (I stopped before Bezier and shape filling stuff). I still have not considered hinting, so it's nice that it's covered. What helped me was an article from the Handmade Network [1] and the source of stb_truetype [2] (also used in Dear ImGUI).

    [1] https://handmade.network/forums/articles/t/7330-implementing....

    [2] https://github.com/nothings/stb/blob/master/stb_truetype.h

  • Capturing the WebGPU Ecosystem
    9 projects | news.ycombinator.com | 11 Nov 2023
    So I read through the materials on mesh shaders and work graphs and looked at sample code. These won't really work (see below). As I implied previously, it's best to research/discuss these sort of matters with professional graphics programmers who have experience actually using the technologies under consideration.

    So for the sake of future web searchers who discover this thread: there are only two proven ways to efficiently draw thousands of unique textures of different sizes with a single draw call that are actually used by experienced graphics programmers in production code as of 2023.

    Proven method #1: Pack these thousands of textures into a texture atlas.

    Proven method #2: Use bindless resources, which is still fairly bleeding edge, and will require fallback to atlases if targeting the PC instead of only high end console (Xbox Series S|X...).

    Mesh shaders by themselves won't work: These have similar texture access limitations to the old geometry/tessellation stage they improve upon. A limited, fixed number of textures still must be bound before each draw call (say, 16 or 32 textures, not 1000s), unless bindless resources are used. So mesh shaders must be used with an atlas or with bindless resources.

    Work graphs by themselves won't work: This feature is bleeding edge shader model 6.8 whereas bindless resources are SM 6.6. (Xbox Series X|S might top out at SM 6.7, I can't find an authoritative answer.) It looks like work graphs might only work well on nVidia GPUs and won't work well on Intel GPUs anytime soon (but, again, I'm not knowledgeable enough to say this authoritatively). Furthermore, this feature may have a hard dependency on using bindless to begin with. That is, I can't tell if one is allowed to execute a work graph that binds and unbinds individual texture resources. And if one could do such a thing, it would certainly be slower than using bindless. The cost of bindless is paid "up front" when the textures are uploaded.

    Some programmers use Texture2DArray/GL_TEXTURE_2D_ARRAY as an alternative to atlases but two limitations are (1) the max array length (e.g. GL_MAX_ARRAY_TEXTURE_LAYERS) might only be 256 (e.g. for OpenGL 3.0), (2) all textures must be the same size.

    Finally, for the sake of any web searcher who lands on this thread in the years to come, to pack an atlas well a good packing algorithm is needed. It's harder to pack triangles than rectangles but triangles use atlas memory more efficiently and a good triangle packing will outperform the fancy new bindless rendering. Some open source starting points for packing:

    https://github.com/nothings/stb/blob/master/stb_rect_pack.h

    https://github.com/ands/trianglepacker

  • Www Which WASM Works
    2 projects | news.ycombinator.com | 24 Sep 2023
    The STB headers are mostly built like that: https://github.com/nothings/stb

    You could also add an optional 'convenience API' over the lower-level flexible-but-inconvenient core API, as long as core library can be compiled on its own.

    In essence it's just a way to decouple the actually important library code from runtime environment details which might be better implemented outside the C/C++ stdlib.

    It's already as simple as the stdlib IO functions not being asynchrononous while many operating systems provide more modern alternatives. For a specific type of library (such an image decoder) it's often better to delegate such details to the library user instead of circumventing the stdlib and talking directly to OS APIs.

  • File for Divorce from LLVM
    9 projects | news.ycombinator.com | 29 Jun 2023
    My stuff for instance:

    https://github.com/floooh/sokol

    ...inspired by:

    https://github.com/nothings/stb

    But it's not so much about the build system, but requiring a separate C/C++ compiler toolchain (Rust needs this, Zig currently does not - unless the proposal is implemented).

  • What C libraries do you use the most?
    4 projects | /r/C_Programming | 29 Jun 2023
    STB Libraries: https://github.com/nothings/stb
  • [Noob Question] How do C programmers get around not having hash maps?
    3 projects | /r/C_Programming | 22 Jun 2023
    stb_ds is also very popular.
  • Is there an existing multidimensional hash table implementation in C?
    4 projects | /r/C_Programming | 20 Jun 2023

What are some alternatives?

When comparing libjpeg-turbo and stb you can also consider the following projects:

ImageMagick - 🧙‍♂️ ImageMagick 7

Vcpkg - C++ Library Manager for Windows, Linux, and MacOS

libwebp - Mirror only. Please do not send pull requests. See https://chromium.googlesource.com/webm/libwebp/+/HEAD/CONTRIBUTING.md.

imgui-node-editor - Node Editor built using Dear ImGui

orion - Usable, easy and safe pure-Rust crypto

ZXing - ZXing ("Zebra Crossing") barcode scanning library for Java, Android

bloom - The simplest way to de-Google your life and business: Inbox, Calendar, Files, Contacts & much more

freetype-gl - OpenGL text using one vertex buffer, one texture and FreeType

virtualgl - Main VirtualGL repository

Rustup - The Rust toolchain installer

Cppcheck - static analysis of C/C++ code