stb_image_resize/0.96.0

[brief]

resize images larger/smaller with good quality

stb

single-file public domain (or MIT licensed) libraries for C/C++

Noteworthy:

Most libraries by stb, except: stb_dxt by Fabian "ryg" Giesen, stb_image_resize by Jorge L. "VinoBS" Rodriguez, and stb_sprintf by Jeff Roberts.

library lastest version category LoC description
stb_vorbis.c 1.20 audio 5563 decode ogg vorbis files from file/memory to float/16-bit signed output
stb_image.h 2.26 graphics 7762 image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
stb_truetype.h 1.24 graphics 5011 parse, decode, and rasterize characters from truetype fonts
stb_image_write.h 1.15 graphics 1690 image writing to disk: PNG, TGA, BMP
stb_image_resize.h 0.96 graphics 2631 resize images larger/smaller with good quality
stb_rect_pack.h 1.00 graphics 628 simple 2D rectangle packer with decent quality
stb_ds.h 0.65 utility 1880 typesafe dynamic array and hash tables for C, will compile in C++
stb_sprintf.h 1.09 utility 1879 fast sprintf, snprintf for C/C++
stretchy_buffer.h 1.04 utility 263 typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++
stb_textedit.h 1.13 user interface 1404 guts of a text editor for games etc implementing them from scratch
stb_voxel_render.h 0.89 3D graphics 3807 Minecraft-esque voxel rendering "engine" with many more features
stb_dxt.h 1.10 3D graphics 753 Fabian "ryg" Giesen's real-time DXT compressor
stb_perlin.h 0.5 3D graphics 428 revised Perlin noise (3D input, 1D output)
stb_easy_font.h 1.1 3D graphics 305 quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
stb_tilemap_editor.h 0.41 game dev 4161 embeddable tilemap editor
stb_herringbone_wa... 0.7 game dev 1221 herringbone Wang tile map generator
stb_c_lexer.h 0.11 parsing 966 simplify writing parsers for C-like languages
stb_divide.h 0.93 math 430 more useful 32-bit modulus e.g. "euclidean divide"
stb_connected_comp... 0.96 misc 1049 incrementally compute reachability on grids
stb.h 2.37 misc 14454 helper functions for C, mostly redundant in C++; basically author's personal stuff
stb_leakcheck.h 0.6 misc 194 quick-and-dirty malloc/free leak-checking
stb_include.h 0.02 misc 295 implement recursive #include support, particularly for GLSL

Total libraries: 22 Total lines of C code: 56774

FAQ

What's the license?

These libraries are in the public domain. You can do anything you want with them. You have no legal obligation to do anything else, although I appreciate attribution.

They are also licensed under the MIT open source license, if you have lawyers who are unhappy with public domain. Every source file includes an explicit dual-license for you to choose from.

Are there other single-file public-domain/open source libraries with minimal dependencies out there?

Yes.

If I wrap an stb library in a new library, does the new library have to be public domain/MIT?

No, because it's public domain you can freely relicense it to whatever license your new library wants to be.

What's the deal with SSE support in GCC-based compilers?

stb_image will either use SSE2 (if you compile with -msse2) or will not use any SIMD at all, rather than trying to detect the processor at runtime and handle it correctly. As I understand it, the approved path in GCC for runtime-detection require you to use multiple source files, one for each CPU configuration. Because stb_image is a header-file library that compiles in only one source file, there's no approved way to build both an SSE-enabled and a non-SSE-enabled variation.

While we've tried to work around it, we've had multiple issues over the years due to specific versions of gcc breaking what we're doing, so we've given up on it. See https://github.com/nothings/stb/issues/280 and https://github.com/nothings/stb/issues/410 for examples.

Some of these libraries seem redundant to existing open source libraries. Are they better somehow?

Generally they're only better in that they're easier to integrate, easier to use, and easier to release (single file; good API; no attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch.

Can I link directly to the table of stb libraries?

You can use this URL to link directly to that list.

Why do you list "lines of code"? It's a terrible metric.

Just to give you some idea of the internal complexity of the library, to help you manage your expectations, or to let you know what you're getting into. While not all the libraries are written in the same style, they're certainly similar styles, and so comparisons between the libraries are probably still meaningful.

Note though that the lines do include both the implementation, the part that corresponds to a header file, and the documentation.

Why single-file headers?

Windows doesn't have standard directories where libraries live. That makes deploying libraries in Windows a lot more painful than open source developers on Unix-derivates generally realize. (It also makes library dependencies a lot worse in Windows.)

There's also a common problem in Windows where a library was built against a different version of the runtime library, which causes link conflicts and confusion. Shipping the libs as headers means you normally just compile them straight into your project without making libraries, thus sidestepping that problem.

Making them a single file makes it very easy to just drop them into a project that needs them. (Of course you can still put them in a proper shared library tree if you want.)

Why not two files, one a header and one an implementation? The difference between 10 files and 9 files is not a big deal, but the difference between 2 files and 1 file is a big deal. You don't need to zip or tar the files up, you don't have to remember to attach two files, etc.

Why "stb"? Is this something to do with Set-Top Boxes?

No, they are just the initials for my name, Sean T. Barrett. This was not chosen out of egomania, but as a moderately sane way of namespacing the filenames and source function names.

Will you add more image types to stb_image.h?

No. As stb_image use has grown, it has become more important for us to focus on security of the codebase. Adding new image formats increases the amount of code we need to secure, so it is no longer worth adding new formats.

Do you have any advice on how to create my own single-file library?

Yes. https://github.com/nothings/stb/blob/master/docs/stb_howto.txt

Why public domain?

I prefer it over GPL, LGPL, BSD, zlib, etc. for many reasons. Some of them are listed here: https://github.com/nothings/stb/blob/master/docs/why_public_domain.md

Why C?

Primarily, because I use C, not C++. But it does also make it easier for other people to use them from other languages.

Why not C99? stdint.h, declare-anywhere, etc.

I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC.

version 0.96.0
license MITMIT License
repository https://pkg.cppget.org/1/alpha
download stb_image_resize-0.96.0.tar.gz
sha256 9d72bed6dd234b5d93f3acb97bf9b3caa5560ef7ebc8759547f36193f561d904
project stb
url github.com/nothings/stb
package-url github.com/build2-packaging/stb
package-email wmbat@protonmail.com
topics image resize

Builds

toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_fedora_38-gcc_13-bindist
timestamp 2024-03-28 09:41:49 UTC (01:56:46 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-static_O3
timestamp 2024-03-28 06:18:41 UTC (05:19:54 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-ndebug_O3
timestamp 2024-03-28 06:11:27 UTC (05:27:09 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13-O3
timestamp 2024-03-28 06:08:04 UTC (05:30:31 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-gcc_13
timestamp 2024-03-28 06:04:57 UTC (05:33:38 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_fedora_37-gcc_12.2-bindist
timestamp 2024-03-28 03:36:37 UTC (08:01:59 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_12-bindist
timestamp 2024-03-28 03:05:28 UTC (08:33:07 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++-static_O3
timestamp 2024-03-28 03:04:30 UTC (08:34:05 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++
timestamp 2024-03-28 03:03:57 UTC (08:34:39 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0-static_O3
timestamp 2024-03-28 03:02:07 UTC (08:36:28 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6-static_O2
timestamp 2024-03-28 03:01:38 UTC (08:36:58 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6-O2
timestamp 2024-03-28 03:00:32 UTC (08:38:04 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6-static_O2
timestamp 2024-03-28 03:00:26 UTC (08:38:10 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64-static_O2
timestamp 2024-03-28 02:59:50 UTC (08:38:45 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_16.0_llvm_msvc_17.6
timestamp 2024-03-28 02:59:29 UTC (08:39:06 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6-O2
timestamp 2024-03-28 02:58:47 UTC (08:39:49 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.6
timestamp 2024-03-28 02:58:45 UTC (08:39:51 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64-O2
timestamp 2024-03-28 02:58:42 UTC (08:39:54 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-msvc_17.5
timestamp 2024-03-28 02:58:08 UTC (08:40:27 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-microsoft-win32-msvc14.3
tgt config windows_10-clang_15.0_msvc_msvc_17.6
timestamp 2024-03-28 02:58:06 UTC (08:40:30 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-w64-mingw32
tgt config windows_10-gcc_12.2_mingw_w64
timestamp 2024-03-28 02:57:44 UTC (08:40:52 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0_libc++-O3
timestamp 2024-03-28 02:56:23 UTC (08:42:12 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0-O3
timestamp 2024-03-28 02:56:22 UTC (08:42:13 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0-O3
timestamp 2024-03-28 02:55:59 UTC (08:42:37 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-static_O3
timestamp 2024-03-28 02:55:47 UTC (08:42:49 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_16.0
timestamp 2024-03-28 02:55:37 UTC (08:42:59 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-ndebug_O3
timestamp 2024-03-28 02:55:11 UTC (08:43:25 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0-static_O3
timestamp 2024-03-28 02:55:06 UTC (08:43:30 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd12.4
tgt config freebsd_12-clang_13.0
timestamp 2024-03-28 02:54:49 UTC (08:43:47 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-freebsd13.2
tgt config freebsd_13-clang_14.0
timestamp 2024-03-28 02:54:44 UTC (08:43:52 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1-O3
timestamp 2024-03-28 02:53:43 UTC (08:44:52 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-gcc_13.1
timestamp 2024-03-28 02:53:37 UTC (08:44:59 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_11-gcc_12.1
timestamp 2024-03-28 02:52:59 UTC (08:45:37 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++-static_O3
timestamp 2024-03-27 23:53:01 UTC (11:45:35 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++-O3
timestamp 2024-03-27 23:48:12 UTC (11:50:24 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16_libc++
timestamp 2024-03-27 23:16:30 UTC (12:22:05 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16-O3
timestamp 2024-03-27 22:59:32 UTC (12:39:03 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16-static_O3
timestamp 2024-03-27 22:57:05 UTC (12:41:30 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_16
timestamp 2024-03-27 22:54:45 UTC (12:43:51 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0-static_O3
timestamp 2024-03-27 21:18:01 UTC (14:20:35 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0-O3
timestamp 2024-03-27 21:17:15 UTC (14:21:21 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_14.0
timestamp 2024-03-27 21:13:11 UTC (14:25:25 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_15_libc++
timestamp 2024-03-27 12:40:37 UTC (22:57:59 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_11-gcc_12
timestamp 2024-03-27 12:40:14 UTC (22:58:22 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target aarch64-linux-gnu
tgt config linux_debian_12-clang_15
timestamp 2024-03-27 12:39:28 UTC (22:59:07 hours ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew-static_O3
timestamp 2024-03-26 14:53:30 UTC (01 20:45:06 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew-O3
timestamp 2024-03-26 14:52:30 UTC (01 20:46:05 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-gcc_13_homebrew
timestamp 2024-03-26 14:51:43 UTC (01 20:46:53 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_15.0_libc++
timestamp 2024-03-26 13:42:48 UTC (01 21:55:47 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-linux-gnu
tgt config linux_debian_12-clang_15.0
timestamp 2024-03-26 13:38:13 UTC (01 22:00:23 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0-static_O3
timestamp 2024-03-26 03:43:25 UTC (02 07:55:11 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0-O3
timestamp 2024-03-26 03:42:42 UTC (02 07:55:53 days ago)
result success | log | rebuild
toolchain public-0.16.0
target x86_64-apple-darwin22.5.0
tgt config macos_13-clang_15.0
timestamp 2024-03-26 03:41:55 UTC (02 07:56:41 days ago)
result success | log | rebuild