libstb 0.6.0__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libstb-0.6.0 → libstb-0.7.0}/.github/workflows/cmake.yml +9 -9
- {libstb-0.6.0 → libstb-0.7.0}/CHANGELOG.md +48 -2
- {libstb-0.6.0 → libstb-0.7.0}/CMakeLists.txt +13 -13
- libstb-0.7.0/PKG-INFO +170 -0
- libstb-0.7.0/README.md +139 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/CMakeLists.txt +4 -4
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/README.md +12 -12
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/CMakeLists.txt +16 -16
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/report/CMakeLists.txt +3 -3
- {libstb-0.6.0 → libstb-0.7.0}/docs/CMakeLists.txt +10 -10
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/index-docs.json +1 -1
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/index-install.txt +1 -1
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/mainpage.md +1 -1
- libstb-0.6.0/README.md → libstb-0.7.0/docs/guide.md +9 -22
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/font.rst +10 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/index.rst +3 -2
- libstb-0.7.0/docs/python/source/zlib.rst +30 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/font.hpp +26 -1
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/image.hpp +1 -1
- libstb-0.7.0/include/stb/zlib.hpp +59 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb.h +2 -1
- {libstb-0.6.0 → libstb-0.7.0}/pyproject.toml +2 -2
- {libstb-0.6.0 → libstb-0.7.0}/requirements-dev.txt +2 -2
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/CMakeLists.txt +1 -1
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/bind_font.cpp +21 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/bind_image.cpp +1 -11
- libstb-0.7.0/src/bindings/python/bind_zlib.cpp +34 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/binding.cpp +1 -0
- libstb-0.7.0/src/bindings/python/binding.hpp +33 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/libstb/__init__.py +6 -2
- libstb-0.7.0/src/bindings/python/libstb/compress.py +50 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/libstb/font.py +22 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/font.cpp +150 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/image.cpp +53 -0
- libstb-0.7.0/src/core/zlib.cpp +137 -0
- libstb-0.7.0/src/core/zlib_bridge.hpp +23 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/CMakeLists.txt +11 -11
- {libstb-0.6.0 → libstb-0.7.0}/tests/cmake/CMakeLists.txt +4 -4
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/CMakeLists.txt +20 -20
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_font.cpp +45 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_image.cpp +25 -0
- libstb-0.7.0/tests/cpp/test_zlib.cpp +141 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/CMakeLists.txt +9 -9
- libstb-0.7.0/tests/python/pngbomb.py +46 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_font.py +52 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_memory.py +27 -0
- libstb-0.7.0/tests/python/test_png_bomb.py +72 -0
- libstb-0.7.0/tests/python/test_zlib.py +162 -0
- libstb-0.7.0/tools/gen_font_metrics.py +76 -0
- libstb-0.6.0/PKG-INFO +0 -391
- libstb-0.6.0/src/bindings/python/binding.hpp +0 -13
- {libstb-0.6.0 → libstb-0.7.0}/.github/workflows/orchestrator.yml +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/.github/workflows/release_template.md +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/.github/workflows/wheels.yml +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/LICENSE.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/cmake/Download.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/cmake/FetchRealCorpus.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/corpus/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/benchmark.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/index.html +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/fonts.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/scaling.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/sizes.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/system_info.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/throughput.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/throughput_memory.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/outputs/results/verify.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_fonts.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_op_memory_driver.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_op_memory_one.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_scaling.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_sizes.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/bench_throughput.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/corpus.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/real_corpus_manifest.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/requirements.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/runners.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/system_info.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/python/verify.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/report/gather.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/report/generate_report.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/benchmarks/report/template.html.jinja2 +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/DynamicVersion.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/FixLCovPaths.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/GenerateIframe.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/Optimize.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/Startup.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/coverage_iframe.html.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/cmake/libstbConfig.cmake.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/CreateDocs.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/InjectComment.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/assets/bench-teaser.js +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/assets/libstb-docs.css +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/CreateDocs.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/Doxyfile.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/footer.html.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/index-example.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/libstb-doxygen.css +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/cpp/topbar.html.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/generate_index.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/images/libstb-logo.png +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/images/libstb-sq.png +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/images/libstb-sq.svg +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/images/libstb-sq.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/images/libstb-theme.svg +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/index.html.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/initial_comment.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/make_showcase.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/CreateDocs.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/index-docs.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/index-example.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/index-install.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/layout.html +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/libstb-nav.html +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/page.html +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/static/libstb-docs.css +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/static/libstb-sphinx.css +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/_themes/libstb/theme.toml +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/conf.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/errors.rst +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/image.rst +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/resizer.rst +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/python/source/simd.rst +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/docs/supported_langs.json +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/cpp/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/01_getting_started.ipynb +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/02_resize_filters.ipynb +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/03_font_rendering.ipynb +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/04_edit_and_orient.ipynb +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/notebooks/requirements.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/.gitignore +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/01_open_and_inspect.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/02_encode_formats.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/03_resize_filters.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/04_numpy_interop.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/05_font_render.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/06_imread_imwrite.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/07_dlpack.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/08_geometry.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/09_channels_and_alpha.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/10_exif_orientation.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/11_pillow.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/examples/python/requirements.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/env.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/error.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/resizer.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/include/stb/utf8.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/bind_resizer.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/bindings/python/libstb/image.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/exif.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/file.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/image_kernels.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/image_kernels_scalar.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/image_kernels_sse2.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/image_ops.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/resizer.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/simd.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/simd.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/core/utf8.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/README.md +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/stb/stb_image.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/stb/stb_image_resize2.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/stb/stb_image_write.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/stb/stb_rect_pack.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/src/third_party/stb/stb_truetype.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cmake/consumer_project/CMakeLists.txt +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cmake/consumer_project/main.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cmake/run_consumer_test.cmake +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/coverage_dashboard.html.in +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_common.hpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_edit.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_encode.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_env.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_exif.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_resizer.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/cpp/test_utf8.cpp +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/data/libstb-test.ttf +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/data/make_test_font.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/genhtml.css +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/conftest.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_array_interface.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_channels.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_dlpack.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_encode.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_errors.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_exif.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_functional.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_gc.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_geometry.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_image.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_lossless_exact.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_lossy_tolerance.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_no_numpy.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_oop.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_pillow_convert.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_pillow_parity.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_resizer.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_simd.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/test_torch.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/python/tolerances.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/tools/jpeg_vs_upstream.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/tools/zlib_fuzz.py +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/utest/utest.h +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/tests/utest/utest_main.cxx +0 -0
- {libstb-0.6.0 → libstb-0.7.0}/version.py +0 -0
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
run: pip install -r requirements-dev.txt
|
|
29
29
|
|
|
30
30
|
- name: Configure Project
|
|
31
|
-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -
|
|
31
|
+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSTB_BUILD_TESTS=ON -DSTB_BUILD_PYTHON=ON
|
|
32
32
|
|
|
33
33
|
- name: Build
|
|
34
34
|
run: cmake --build build -j4 --config Release
|
|
@@ -66,12 +66,12 @@ jobs:
|
|
|
66
66
|
run: |
|
|
67
67
|
cmake -S . -B build \
|
|
68
68
|
-DCMAKE_BUILD_TYPE=Release \
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
69
|
+
-DSTB_BUILD_TESTS=OFF \
|
|
70
|
+
-DSTB_BUILD_PYTHON=ON \
|
|
71
|
+
-DSTB_BUILD_DOCS=ON
|
|
72
72
|
|
|
73
73
|
- name: Build documentation
|
|
74
|
-
run: cmake --build build --target
|
|
74
|
+
run: cmake --build build --target stb_docs
|
|
75
75
|
|
|
76
76
|
- name: List docs directory
|
|
77
77
|
run: tree --du -shaC build/docs/out
|
|
@@ -113,13 +113,13 @@ jobs:
|
|
|
113
113
|
- name: Configure CMake
|
|
114
114
|
run: |
|
|
115
115
|
cmake -S . -B build \
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
116
|
+
-DSTB_BUILD_TESTS=ON \
|
|
117
|
+
-DSTB_BUILD_PYTHON=ON \
|
|
118
|
+
-DSTB_BUILD_DOCS=OFF
|
|
119
119
|
|
|
120
120
|
# C++ (lcov), Python (coverage.py) and the merged total.
|
|
121
121
|
- name: Generate coverage report
|
|
122
|
-
run: cmake --build build --target
|
|
122
|
+
run: cmake --build build --target stb_coverage
|
|
123
123
|
|
|
124
124
|
- name: Upload coverage to Codecov
|
|
125
125
|
uses: codecov/codecov-action@v5
|
|
@@ -3,9 +3,55 @@
|
|
|
3
3
|
All notable changes to libstb are listed here, newest first. The format follows
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Dates are commit dates.
|
|
5
5
|
|
|
6
|
-
This file was generated from the git history (
|
|
6
|
+
This file was generated from the git history (61 commits, tags `v0.3.0`, `v0.4.0`, `v0.5.0`, `v0.6.0`, `v0.7.0`).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [0.7.0] - 2026-10-17
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
- CMake names changed (`016551c`, `c76d406`, `3b02769`). Targets `libstb_*` are now `stb_*`:
|
|
12
|
+
`stb_core` (the library; still exported as `libstb::core`), `stb_test`, `stb_test_cpp`,
|
|
13
|
+
`stb_test_python`, `stb_test_cmake`, `stb_docs` (`_cpp`, `_python`, `_index`), `stb_coverage`
|
|
14
|
+
(`_cpp`, `_python`, `_total`), `stb_benchmark` and `stb_bench_*`; the C++ test executable
|
|
15
|
+
`test_libstb_cpp` is now `test_stb_cpp`. The options `LIBSTB_BUILD_TESTS`, `LIBSTB_BUILD_PYTHON`
|
|
16
|
+
and `LIBSTB_BUILD_DOCS` are now `STB_BUILD_TESTS`, `STB_BUILD_PYTHON` and `STB_BUILD_DOCS`.
|
|
17
|
+
Scripts and CI that call the old names must be updated. Not renamed: the package and project
|
|
18
|
+
name `libstb`, `find_package(libstb CONFIG)`, `libstb::core`, `import libstb`, the extension
|
|
19
|
+
module `libstb_py`, and environment variables such as `LIBSTB_SIMD`.
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- `stb::zlib_compress` / `stb::zlib_decompress` (`<stb/zlib.hpp>`; Python: `libstb.zlib_compress`,
|
|
23
|
+
`libstb.zlib_decompress`, `DEFAULT_ZLIB_LEVEL`, `DEFAULT_ZLIB_MAX_BYTES`) (`0088cb8`): zlib streams
|
|
24
|
+
with the PNG compressor and stb_image's inflate. `level` uses zlib's numbering (0 stores, 1 to 9,
|
|
25
|
+
-1 default 6). The output of `zlib_decompress` is bounded by `max_bytes` (a zip bomb is a
|
|
26
|
+
`limit_error` / `LimitError`, never an out-of-memory), the Adler-32 is verified, and both
|
|
27
|
+
directions interoperate with zlib. Compression was 1.2x to 1.9x faster than zlib level 6 with
|
|
28
|
+
0.4% to 3.3% larger output on our samples; decompression is **not** faster than zlib (about
|
|
29
|
+
2.5x slower on very compressible text). Any bytes-like object is accepted in Python and the GIL
|
|
30
|
+
is released.
|
|
31
|
+
- `stb::estimate_text` / `stb::estimate_metrics` (Python: `libstb.estimate_text`,
|
|
32
|
+
`libstb.estimate_metrics`): rough text size without a font file, from fixed width tables for
|
|
33
|
+
`sans`, `serif` and `mono` (Liberation metrics, generated by `tools/gen_font_metrics.py`, no font
|
|
34
|
+
bundled). No kerning; CJK and emoji count as 1 em and other non-Latin text is approximated.
|
|
35
|
+
- Tests: a real PNG decompression bomb (a valid 0.5 MB file that declares 576 MB), generated on
|
|
36
|
+
demand by `tests/python/pngbomb.py`, checked from Python (`test_png_bomb.py`, with a memray bound)
|
|
37
|
+
and C++ (`test_a_real_png_bomb_is_refused_from_its_header`) (`83226ea`); zlib tests against
|
|
38
|
+
python's `zlib` in both directions, zip bombs and exact `max_bytes` bounds; font estimator
|
|
39
|
+
tests, including agreement with the real Liberation fonts when they are installed.
|
|
40
|
+
- `docs/guide.md`: the complete reference that used to be the README (`ec879bb`).
|
|
41
|
+
- Documentation pages for the zlib and estimator APIs (Sphinx and Doxygen).
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- README rewritten as a short landing page: Python first, then C++ with CMake, then which stb
|
|
45
|
+
modules are used and how libstb differs from plain stb in API and performance (`ec879bb`).
|
|
46
|
+
- Internal: stb's headers are still compiled in one translation unit (`src/core/image.cpp`); the
|
|
47
|
+
zlib API reaches them through `src/core/zlib_bridge.hpp`, so the compressor and inflater exist
|
|
48
|
+
once. The Python bindings share one `py_buffer` helper (`binding.hpp`).
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
- The C++ install snippets (`docs/cpp/index-install.txt`, `docs/cpp/mainpage.md`) used
|
|
52
|
+
`GIT_TAG main`, but the default branch is `master`.
|
|
53
|
+
|
|
54
|
+
## [0.6.0] - 2026-10-16
|
|
9
55
|
|
|
10
56
|
### Breaking
|
|
11
57
|
- `Image.rotate90(turns=1)` (C++: `stb::image::rotate90`) now turns **counter-clockwise**, like
|
|
@@ -19,9 +19,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
19
19
|
|
|
20
20
|
include(Optimize)
|
|
21
21
|
|
|
22
|
-
option(
|
|
23
|
-
option(
|
|
24
|
-
option(
|
|
22
|
+
option(STB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
|
|
23
|
+
option(STB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
|
|
24
|
+
option(STB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
|
|
25
25
|
|
|
26
26
|
# --- libstb C++ core ---
|
|
27
27
|
# stb headers are vendored (committed) under src/third_party/stb and are only
|
|
@@ -31,10 +31,10 @@ option(LIBSTB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
|
|
|
31
31
|
# stbi_* symbol leaks out to consumers.
|
|
32
32
|
file(GLOB LIBSTB_CORE_SOURCES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/core/*.cpp)
|
|
33
33
|
|
|
34
|
-
add_library(
|
|
35
|
-
add_library(libstb::core ALIAS
|
|
34
|
+
add_library(stb_core STATIC ${LIBSTB_CORE_SOURCES})
|
|
35
|
+
add_library(libstb::core ALIAS stb_core)
|
|
36
36
|
|
|
37
|
-
set_target_properties(
|
|
37
|
+
set_target_properties(stb_core PROPERTIES
|
|
38
38
|
POSITION_INDEPENDENT_CODE ON # linked into the Python extension
|
|
39
39
|
CXX_VISIBILITY_PRESET hidden
|
|
40
40
|
VISIBILITY_INLINES_HIDDEN ON
|
|
@@ -55,14 +55,14 @@ else()
|
|
|
55
55
|
set(_libstb_cmake_dest lib/cmake/libstb)
|
|
56
56
|
endif()
|
|
57
57
|
|
|
58
|
-
target_include_directories(
|
|
58
|
+
target_include_directories(stb_core
|
|
59
59
|
PUBLIC
|
|
60
60
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
|
61
61
|
$<INSTALL_INTERFACE:${_libstb_inc_dest}>
|
|
62
62
|
)
|
|
63
63
|
# Everything that decides how the core sources are compiled lives in this function, so a target
|
|
64
64
|
# that compiles them itself (tests/cpp does, to attach coverage flags) gets exactly the same
|
|
65
|
-
# settings as
|
|
65
|
+
# settings as stb_core.
|
|
66
66
|
function(libstb_apply_core_build_settings target)
|
|
67
67
|
# SYSTEM: vendored headers we don't control - their internal warnings are not
|
|
68
68
|
# ours to fix under our own -Wall/-Wextra/-W4.
|
|
@@ -94,11 +94,11 @@ function(libstb_apply_core_build_settings target)
|
|
|
94
94
|
endif()
|
|
95
95
|
endfunction()
|
|
96
96
|
|
|
97
|
-
libstb_apply_core_build_settings(
|
|
97
|
+
libstb_apply_core_build_settings(stb_core)
|
|
98
98
|
|
|
99
99
|
# --- install (find_package(libstb) -> libstb::core) ---
|
|
100
100
|
include(CMakePackageConfigHelpers)
|
|
101
|
-
install(TARGETS
|
|
101
|
+
install(TARGETS stb_core EXPORT libstbTargets ARCHIVE DESTINATION ${_libstb_lib_dest})
|
|
102
102
|
install(DIRECTORY include/ DESTINATION ${_libstb_inc_dest})
|
|
103
103
|
install(EXPORT libstbTargets FILE libstbTargets.cmake NAMESPACE libstb:: DESTINATION ${_libstb_cmake_dest})
|
|
104
104
|
configure_package_config_file(
|
|
@@ -117,7 +117,7 @@ install(FILES
|
|
|
117
117
|
DESTINATION ${_libstb_cmake_dest}
|
|
118
118
|
)
|
|
119
119
|
|
|
120
|
-
if(
|
|
120
|
+
if(STB_BUILD_PYTHON OR DEFINED SKBUILD)
|
|
121
121
|
set(PYTHON_INSTALL_DIR ${CMAKE_BINARY_DIR}/python/install)
|
|
122
122
|
add_subdirectory(${PROJECT_SOURCE_DIR}/src/bindings/python)
|
|
123
123
|
if(DEFINED SKBUILD)
|
|
@@ -125,13 +125,13 @@ if(LIBSTB_BUILD_PYTHON OR DEFINED SKBUILD)
|
|
|
125
125
|
endif()
|
|
126
126
|
endif()
|
|
127
127
|
|
|
128
|
-
if(
|
|
128
|
+
if(STB_BUILD_TESTS)
|
|
129
129
|
enable_testing()
|
|
130
130
|
set(CMAKE_CTEST_ARGUMENTS "--output-on-failure" "-V")
|
|
131
131
|
add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
|
|
132
132
|
endif()
|
|
133
133
|
|
|
134
134
|
# Documentation (Doxygen + Sphinx). Needs the Python extension: the Sphinx build imports it.
|
|
135
|
-
if(
|
|
135
|
+
if(STB_BUILD_DOCS)
|
|
136
136
|
add_subdirectory(${PROJECT_SOURCE_DIR}/docs)
|
|
137
137
|
endif()
|
libstb-0.7.0/PKG-INFO
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: libstb
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Python bindings for the stb single-header libraries (image io, resize, fonts). Zero system dependencies.
|
|
5
|
+
Author-Email: Mohammad Raziei <mohammadraziei1375@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: C++
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Project-URL: Homepage, https://github.com/MohammadRaziei/libstb
|
|
19
|
+
Project-URL: Bug Tracker, https://github.com/MohammadRaziei/libstb/issues
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Provides-Extra: numpy
|
|
22
|
+
Requires-Dist: numpy; extra == "numpy"
|
|
23
|
+
Provides-Extra: pillow
|
|
24
|
+
Requires-Dist: pillow; extra == "pillow"
|
|
25
|
+
Provides-Extra: test
|
|
26
|
+
Requires-Dist: pytest; extra == "test"
|
|
27
|
+
Requires-Dist: numpy; (sys_platform != "win32" or platform_machine != "ARM64" or python_version >= "3.11") and extra == "test"
|
|
28
|
+
Requires-Dist: pillow; extra == "test"
|
|
29
|
+
Requires-Dist: pytest-memray; sys_platform != "win32" and (platform_machine == "x86_64" or platform_machine == "arm64") and extra == "test"
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# libstb
|
|
33
|
+
|
|
34
|
+
Fast image and font processing for **Python and C++**, with no system dependencies and no
|
|
35
|
+
Python dependencies: decode, encode, resize, edit and draw text with one small library.
|
|
36
|
+
|
|
37
|
+
libstb is highly powered by [stb](https://github.com/nothings/stb), and that is where the name
|
|
38
|
+
comes from. It is not a thin wrapper, though. The API is our own (typed, with explicit
|
|
39
|
+
ownership and errors), and several parts are rewritten or patched for speed, so both the API
|
|
40
|
+
and the performance differ from plain stb. See [what is from stb](#what-is-from-stb-and-what-is-not).
|
|
41
|
+
|
|
42
|
+
## Python
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
pip install libstb # numpy and Pillow are optional: "libstb[numpy]", "libstb[pillow]"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
import libstb as stb
|
|
50
|
+
|
|
51
|
+
img = stb.Image.open("photo.jpg") # PNG, JPEG, BMP, TGA, GIF, ... (or bytes)
|
|
52
|
+
img.width, img.height, img.channels # 640, 480, 3
|
|
53
|
+
|
|
54
|
+
small = img.resize(320, 240, "cubic") # filter by name: nearest, linear, cubic, mitchell, box...
|
|
55
|
+
small.write("small.png") # format from the extension (png, jpg, bmp, tga)
|
|
56
|
+
small.write_jpg("small.jpg", quality=80) # or choose the format and its settings
|
|
57
|
+
data = small.to_png(compression=9) # -> bytes
|
|
58
|
+
|
|
59
|
+
thumb = img.thumbnail(256, 256) # fits the box, never enlarges
|
|
60
|
+
img.crop(10, 10, 200, 100).rotate90().convert(1) # every edit returns a new Image
|
|
61
|
+
|
|
62
|
+
pixels = img.numpy() # zero-copy view (needs numpy); DLPack works too
|
|
63
|
+
photo = stb.Image.open("IMG_0001.jpg", orient=True) # apply the EXIF rotation while decoding
|
|
64
|
+
|
|
65
|
+
font = stb.Font.open("font.ttf") # trusted fonts only
|
|
66
|
+
font.render("Hello", 32).bitmap.write("hello.png")
|
|
67
|
+
stb.estimate_text("Hello", 16) # text size with no font file at all
|
|
68
|
+
|
|
69
|
+
packed = stb.zlib_compress(data) # zlib streams: the compressor that writes PNG
|
|
70
|
+
data = stb.zlib_decompress(packed, max_bytes=64 << 20) # output is bounded: a zip bomb is a LimitError
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## C++ with CMake
|
|
74
|
+
|
|
75
|
+
```cmake
|
|
76
|
+
include(FetchContent)
|
|
77
|
+
FetchContent_Declare(libstb GIT_REPOSITORY https://github.com/MohammadRaziei/libstb.git GIT_TAG master)
|
|
78
|
+
FetchContent_MakeAvailable(libstb)
|
|
79
|
+
|
|
80
|
+
target_link_libraries(my_app PRIVATE libstb::core) # CMake 3.21+, C++17
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`find_package(libstb CONFIG)` works too, after `cmake --install` or after `pip install libstb`
|
|
84
|
+
(`stb.get_cmake_dir()` gives the config directory).
|
|
85
|
+
|
|
86
|
+
```cpp
|
|
87
|
+
#include <stb.h>
|
|
88
|
+
|
|
89
|
+
stb::image img = stb::image::open("photo.jpg"); // throws stb::error subclasses
|
|
90
|
+
stb::image small = img.resize(320, 240, "cubic"); // or stb::resize_filter::mitchell
|
|
91
|
+
small.write("small.png"); // format from the extension
|
|
92
|
+
small.write_jpg("small.jpg", 80);
|
|
93
|
+
std::vector<std::uint8_t> bytes = small.to_png(9);
|
|
94
|
+
|
|
95
|
+
stb::font f = stb::font::open("font.ttf"); // cheap to copy, thread-safe
|
|
96
|
+
stb::text_bitmap t = f.render("Hello", 32);
|
|
97
|
+
stb::text_size est = stb::estimate_text("Hello", 16); // no font file needed
|
|
98
|
+
|
|
99
|
+
std::vector<std::uint8_t> z = stb::zlib_compress(bytes); // <stb/zlib.hpp>, level 0..9 like zlib
|
|
100
|
+
std::vector<std::uint8_t> back = stb::zlib_decompress(z, 64u << 20); // throws limit_error past max_bytes
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The namespace and headers are `stb` (`<stb.h>`, `<stb/*.hpp>`); the CMake target
|
|
104
|
+
(`libstb::core`) and the Python package (`libstb`) keep the project name. No stb header is
|
|
105
|
+
ever included from a public header, and stb symbols do not leak from the library, so it links
|
|
106
|
+
next to your own copy of stb.
|
|
107
|
+
|
|
108
|
+
## What is from stb, and what is not
|
|
109
|
+
|
|
110
|
+
libstb uses these stb modules, vendored in `src/third_party/` (no submodules):
|
|
111
|
+
|
|
112
|
+
| stb module | used for |
|
|
113
|
+
| :--- | :--- |
|
|
114
|
+
| `stb_image` | decoding (PNG, JPEG, BMP, TGA, GIF, ...) |
|
|
115
|
+
| `stb_image_write` | encoding PNG, JPEG, BMP, TGA |
|
|
116
|
+
| `stb_image_resize2` | resizing, all filters |
|
|
117
|
+
| `stb_truetype` | font metrics, glyphs, text rendering, atlases |
|
|
118
|
+
| `stb_rect_pack` | packing glyphs into an atlas |
|
|
119
|
+
|
|
120
|
+
What we changed on top, for speed and for a safer, more convenient API:
|
|
121
|
+
|
|
122
|
+
- **Faster encoders.** `stb_image_write.h` carries two local patches: a new PNG deflate (4-byte
|
|
123
|
+
hash chains, lazy matching, dynamic Huffman blocks: within about 1% of zlib level 6 in size at
|
|
124
|
+
roughly twice its speed) and a faster JPEG encoder (buffered bit writer, vectorisable DCT, SSE2 colour
|
|
125
|
+
conversion). The other stb headers are byte-for-byte upstream.
|
|
126
|
+
- **SIMD where it pays.** `convert`, `composite` and `flatten` have AVX2, baseline SIMD and
|
|
127
|
+
scalar builds that give identical results; the best one is picked at run time.
|
|
128
|
+
- **No hidden copies.** Decoded buffers are adopted, not copied; arrays and DLPack tensors are
|
|
129
|
+
shared when they can be; Python calls release the GIL.
|
|
130
|
+
- **zlib as an API.** The PNG compressor and stb's inflate are exposed as
|
|
131
|
+
`zlib_compress` and `zlib_decompress` (any bytes-like object in, bytes out), with a bounded
|
|
132
|
+
output so a zip bomb is a `LimitError`. They interoperate with python's `zlib`. Compression
|
|
133
|
+
was 1.2x to 1.9x faster than zlib level 6 at 0.4% to 3.3% larger output on our samples;
|
|
134
|
+
decompression is stb_image's and is **not** faster than zlib (about 2.5x slower on very
|
|
135
|
+
compressible text), so use zlib if inflate speed is what you need.
|
|
136
|
+
- **Editing stb does not have.** Crop, pad, flips, rotation, thumbnail, channel conversion,
|
|
137
|
+
alpha compositing, EXIF orientation, resize filters by name, and a font-free text size
|
|
138
|
+
estimate.
|
|
139
|
+
- **Safety.** Size limits are checked from the header before any pixel memory is allocated,
|
|
140
|
+
errors are typed (`stb.Error` with `DecodeError`, `EncodeError`, `LimitError`), and EXIF
|
|
141
|
+
parsing checks every offset. stb_truetype is still not safe on untrusted fonts: load only
|
|
142
|
+
fonts you trust.
|
|
143
|
+
|
|
144
|
+
Performance numbers against Pillow and OpenCV, including where libstb is slower (JPEG
|
|
145
|
+
encoding is one), are in [`benchmarks/`](benchmarks/README.md). They depend on the machine, so
|
|
146
|
+
run them on yours.
|
|
147
|
+
|
|
148
|
+
## More
|
|
149
|
+
|
|
150
|
+
- [`docs/guide.md`](docs/guide.md): the full reference (every call, SIMD, EXIF, DLPack, Pillow,
|
|
151
|
+
errors, design and source layout).
|
|
152
|
+
- `docs/`: the Sphinx (Python) and Doxygen (C++) sources of the documentation site.
|
|
153
|
+
- [`CHANGELOG.md`](CHANGELOG.md).
|
|
154
|
+
|
|
155
|
+
## Build and test
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
pip install -r requirements-dev.txt
|
|
159
|
+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
160
|
+
cmake --build build
|
|
161
|
+
ctest --test-dir build --output-on-failure
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Options: `STB_BUILD_TESTS`, `STB_BUILD_PYTHON`, `STB_BUILD_DOCS`. Targets: `stb_core`,
|
|
165
|
+
`stb_test`, `stb_docs`, `stb_benchmark`.
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT for libstb. The vendored stb headers are MIT / public domain (see
|
|
170
|
+
`src/third_party/README.md`).
|
libstb-0.7.0/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# libstb
|
|
2
|
+
|
|
3
|
+
Fast image and font processing for **Python and C++**, with no system dependencies and no
|
|
4
|
+
Python dependencies: decode, encode, resize, edit and draw text with one small library.
|
|
5
|
+
|
|
6
|
+
libstb is highly powered by [stb](https://github.com/nothings/stb), and that is where the name
|
|
7
|
+
comes from. It is not a thin wrapper, though. The API is our own (typed, with explicit
|
|
8
|
+
ownership and errors), and several parts are rewritten or patched for speed, so both the API
|
|
9
|
+
and the performance differ from plain stb. See [what is from stb](#what-is-from-stb-and-what-is-not).
|
|
10
|
+
|
|
11
|
+
## Python
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pip install libstb # numpy and Pillow are optional: "libstb[numpy]", "libstb[pillow]"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import libstb as stb
|
|
19
|
+
|
|
20
|
+
img = stb.Image.open("photo.jpg") # PNG, JPEG, BMP, TGA, GIF, ... (or bytes)
|
|
21
|
+
img.width, img.height, img.channels # 640, 480, 3
|
|
22
|
+
|
|
23
|
+
small = img.resize(320, 240, "cubic") # filter by name: nearest, linear, cubic, mitchell, box...
|
|
24
|
+
small.write("small.png") # format from the extension (png, jpg, bmp, tga)
|
|
25
|
+
small.write_jpg("small.jpg", quality=80) # or choose the format and its settings
|
|
26
|
+
data = small.to_png(compression=9) # -> bytes
|
|
27
|
+
|
|
28
|
+
thumb = img.thumbnail(256, 256) # fits the box, never enlarges
|
|
29
|
+
img.crop(10, 10, 200, 100).rotate90().convert(1) # every edit returns a new Image
|
|
30
|
+
|
|
31
|
+
pixels = img.numpy() # zero-copy view (needs numpy); DLPack works too
|
|
32
|
+
photo = stb.Image.open("IMG_0001.jpg", orient=True) # apply the EXIF rotation while decoding
|
|
33
|
+
|
|
34
|
+
font = stb.Font.open("font.ttf") # trusted fonts only
|
|
35
|
+
font.render("Hello", 32).bitmap.write("hello.png")
|
|
36
|
+
stb.estimate_text("Hello", 16) # text size with no font file at all
|
|
37
|
+
|
|
38
|
+
packed = stb.zlib_compress(data) # zlib streams: the compressor that writes PNG
|
|
39
|
+
data = stb.zlib_decompress(packed, max_bytes=64 << 20) # output is bounded: a zip bomb is a LimitError
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## C++ with CMake
|
|
43
|
+
|
|
44
|
+
```cmake
|
|
45
|
+
include(FetchContent)
|
|
46
|
+
FetchContent_Declare(libstb GIT_REPOSITORY https://github.com/MohammadRaziei/libstb.git GIT_TAG master)
|
|
47
|
+
FetchContent_MakeAvailable(libstb)
|
|
48
|
+
|
|
49
|
+
target_link_libraries(my_app PRIVATE libstb::core) # CMake 3.21+, C++17
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`find_package(libstb CONFIG)` works too, after `cmake --install` or after `pip install libstb`
|
|
53
|
+
(`stb.get_cmake_dir()` gives the config directory).
|
|
54
|
+
|
|
55
|
+
```cpp
|
|
56
|
+
#include <stb.h>
|
|
57
|
+
|
|
58
|
+
stb::image img = stb::image::open("photo.jpg"); // throws stb::error subclasses
|
|
59
|
+
stb::image small = img.resize(320, 240, "cubic"); // or stb::resize_filter::mitchell
|
|
60
|
+
small.write("small.png"); // format from the extension
|
|
61
|
+
small.write_jpg("small.jpg", 80);
|
|
62
|
+
std::vector<std::uint8_t> bytes = small.to_png(9);
|
|
63
|
+
|
|
64
|
+
stb::font f = stb::font::open("font.ttf"); // cheap to copy, thread-safe
|
|
65
|
+
stb::text_bitmap t = f.render("Hello", 32);
|
|
66
|
+
stb::text_size est = stb::estimate_text("Hello", 16); // no font file needed
|
|
67
|
+
|
|
68
|
+
std::vector<std::uint8_t> z = stb::zlib_compress(bytes); // <stb/zlib.hpp>, level 0..9 like zlib
|
|
69
|
+
std::vector<std::uint8_t> back = stb::zlib_decompress(z, 64u << 20); // throws limit_error past max_bytes
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The namespace and headers are `stb` (`<stb.h>`, `<stb/*.hpp>`); the CMake target
|
|
73
|
+
(`libstb::core`) and the Python package (`libstb`) keep the project name. No stb header is
|
|
74
|
+
ever included from a public header, and stb symbols do not leak from the library, so it links
|
|
75
|
+
next to your own copy of stb.
|
|
76
|
+
|
|
77
|
+
## What is from stb, and what is not
|
|
78
|
+
|
|
79
|
+
libstb uses these stb modules, vendored in `src/third_party/` (no submodules):
|
|
80
|
+
|
|
81
|
+
| stb module | used for |
|
|
82
|
+
| :--- | :--- |
|
|
83
|
+
| `stb_image` | decoding (PNG, JPEG, BMP, TGA, GIF, ...) |
|
|
84
|
+
| `stb_image_write` | encoding PNG, JPEG, BMP, TGA |
|
|
85
|
+
| `stb_image_resize2` | resizing, all filters |
|
|
86
|
+
| `stb_truetype` | font metrics, glyphs, text rendering, atlases |
|
|
87
|
+
| `stb_rect_pack` | packing glyphs into an atlas |
|
|
88
|
+
|
|
89
|
+
What we changed on top, for speed and for a safer, more convenient API:
|
|
90
|
+
|
|
91
|
+
- **Faster encoders.** `stb_image_write.h` carries two local patches: a new PNG deflate (4-byte
|
|
92
|
+
hash chains, lazy matching, dynamic Huffman blocks: within about 1% of zlib level 6 in size at
|
|
93
|
+
roughly twice its speed) and a faster JPEG encoder (buffered bit writer, vectorisable DCT, SSE2 colour
|
|
94
|
+
conversion). The other stb headers are byte-for-byte upstream.
|
|
95
|
+
- **SIMD where it pays.** `convert`, `composite` and `flatten` have AVX2, baseline SIMD and
|
|
96
|
+
scalar builds that give identical results; the best one is picked at run time.
|
|
97
|
+
- **No hidden copies.** Decoded buffers are adopted, not copied; arrays and DLPack tensors are
|
|
98
|
+
shared when they can be; Python calls release the GIL.
|
|
99
|
+
- **zlib as an API.** The PNG compressor and stb's inflate are exposed as
|
|
100
|
+
`zlib_compress` and `zlib_decompress` (any bytes-like object in, bytes out), with a bounded
|
|
101
|
+
output so a zip bomb is a `LimitError`. They interoperate with python's `zlib`. Compression
|
|
102
|
+
was 1.2x to 1.9x faster than zlib level 6 at 0.4% to 3.3% larger output on our samples;
|
|
103
|
+
decompression is stb_image's and is **not** faster than zlib (about 2.5x slower on very
|
|
104
|
+
compressible text), so use zlib if inflate speed is what you need.
|
|
105
|
+
- **Editing stb does not have.** Crop, pad, flips, rotation, thumbnail, channel conversion,
|
|
106
|
+
alpha compositing, EXIF orientation, resize filters by name, and a font-free text size
|
|
107
|
+
estimate.
|
|
108
|
+
- **Safety.** Size limits are checked from the header before any pixel memory is allocated,
|
|
109
|
+
errors are typed (`stb.Error` with `DecodeError`, `EncodeError`, `LimitError`), and EXIF
|
|
110
|
+
parsing checks every offset. stb_truetype is still not safe on untrusted fonts: load only
|
|
111
|
+
fonts you trust.
|
|
112
|
+
|
|
113
|
+
Performance numbers against Pillow and OpenCV, including where libstb is slower (JPEG
|
|
114
|
+
encoding is one), are in [`benchmarks/`](benchmarks/README.md). They depend on the machine, so
|
|
115
|
+
run them on yours.
|
|
116
|
+
|
|
117
|
+
## More
|
|
118
|
+
|
|
119
|
+
- [`docs/guide.md`](docs/guide.md): the full reference (every call, SIMD, EXIF, DLPack, Pillow,
|
|
120
|
+
errors, design and source layout).
|
|
121
|
+
- `docs/`: the Sphinx (Python) and Doxygen (C++) sources of the documentation site.
|
|
122
|
+
- [`CHANGELOG.md`](CHANGELOG.md).
|
|
123
|
+
|
|
124
|
+
## Build and test
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
pip install -r requirements-dev.txt
|
|
128
|
+
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
|
|
129
|
+
cmake --build build
|
|
130
|
+
ctest --test-dir build --output-on-failure
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Options: `STB_BUILD_TESTS`, `STB_BUILD_PYTHON`, `STB_BUILD_DOCS`. Targets: `stb_core`,
|
|
134
|
+
`stb_test`, `stb_docs`, `stb_benchmark`.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT for libstb. The vendored stb headers are MIT / public domain (see
|
|
139
|
+
`src/third_party/README.md`).
|
|
@@ -9,7 +9,7 @@ project(LibstbBenchmarks LANGUAGES NONE)
|
|
|
9
9
|
# https://github.com/MohammadRaziei/novasvg/tree/master/benchmarks.
|
|
10
10
|
#
|
|
11
11
|
# cmake -S . -B build
|
|
12
|
-
# cmake --build build --target
|
|
12
|
+
# cmake --build build --target stb_benchmark
|
|
13
13
|
#
|
|
14
14
|
# Two folders, nothing else is ever written:
|
|
15
15
|
#
|
|
@@ -41,7 +41,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchRealCorpus.cmake")
|
|
|
41
41
|
add_subdirectory(python)
|
|
42
42
|
add_subdirectory(report)
|
|
43
43
|
|
|
44
|
-
add_custom_target(
|
|
45
|
-
COMMENT "
|
|
44
|
+
add_custom_target(stb_benchmark
|
|
45
|
+
COMMENT "stb_benchmark: running the full benchmark suite and building the report"
|
|
46
46
|
)
|
|
47
|
-
add_dependencies(
|
|
47
|
+
add_dependencies(stb_benchmark stb_bench_report)
|
|
@@ -15,7 +15,7 @@ by the same author, which this one is modeled on.
|
|
|
15
15
|
```bash
|
|
16
16
|
cd benchmarks
|
|
17
17
|
cmake -S . -B build
|
|
18
|
-
cmake --build build --target
|
|
18
|
+
cmake --build build --target stb_benchmark
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
That's the one target you need: it pulls in every benchmark, in the
|
|
@@ -47,17 +47,17 @@ Every operation is its own target, independently runnable
|
|
|
47
47
|
|
|
48
48
|
| Target | What it does |
|
|
49
49
|
|---|---|
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
50
|
+
| `stb_bench_venv` | Create the venv; install numpy/Pillow/OpenCV/imageio/scikit-image/pip-size/jinja2 + libstb itself (from git) |
|
|
51
|
+
| `stb_bench_corpus` | Generate the synthetic multi-genre corpus |
|
|
52
|
+
| `stb_bench_real_corpus` | Convert the real-world photographs (downloaded at configure time) into every format, same manifest shape |
|
|
53
|
+
| `stb_bench_verify` | Check that every (operation, library) pair produces correct output, before anything is timed |
|
|
54
|
+
| `stb_bench_sizes` | Real install footprint via `pip-size` |
|
|
55
|
+
| `stb_bench_throughput` | Speed: decode / encode / resize, every library, every corpus entry |
|
|
56
|
+
| `stb_bench_throughput_memory` | Peak memory for the same operations, libraries and entries |
|
|
57
|
+
| `stb_bench_scaling` | Throughput vs. image size, 0.016 to 16.8 megapixels |
|
|
58
|
+
| `stb_bench_fonts` | `Font` (stb_truetype) vs. Pillow's FreeType binding |
|
|
59
|
+
| `stb_bench_system_info` | Record CPU / RAM / OS / Python |
|
|
60
|
+
| `stb_bench_report` | Render `outputs/index.html` from `outputs/results/*.json`, and write `outputs/benchmark.json` |
|
|
61
61
|
|
|
62
62
|
The scripts also run by hand, from `python/`, on any machine that has
|
|
63
63
|
the requirements installed:
|
|
@@ -29,7 +29,7 @@ file(MAKE_DIRECTORY "${SCRATCH_DIR}")
|
|
|
29
29
|
# This runs at CONFIGURE time (execute_process, right here while
|
|
30
30
|
# CMakeLists.txt is being processed), not at build time, so
|
|
31
31
|
# `cmake -S . -B build` alone leaves you with a ready venv, and
|
|
32
|
-
# `cmake --build build --target
|
|
32
|
+
# `cmake --build build --target stb_benchmark` only has to run the
|
|
33
33
|
# actual benchmarks. The venv itself still lives under the build
|
|
34
34
|
# directory (${CMAKE_CURRENT_BINARY_DIR}/venv).
|
|
35
35
|
#
|
|
@@ -83,7 +83,7 @@ else()
|
|
|
83
83
|
"(delete ${VENV_STAMP} to force recreation)")
|
|
84
84
|
endif()
|
|
85
85
|
|
|
86
|
-
add_custom_target(
|
|
86
|
+
add_custom_target(stb_bench_venv)
|
|
87
87
|
|
|
88
88
|
# -------------------------------------------------------------- corpus --
|
|
89
89
|
|
|
@@ -97,7 +97,7 @@ add_custom_command(
|
|
|
97
97
|
COMMENT "libstb benchmarks: generating the synthetic corpus"
|
|
98
98
|
USES_TERMINAL
|
|
99
99
|
)
|
|
100
|
-
add_custom_target(
|
|
100
|
+
add_custom_target(stb_bench_corpus DEPENDS "${CORPUS_MANIFEST}")
|
|
101
101
|
|
|
102
102
|
# --------------------------------------------------------- real corpus --
|
|
103
103
|
# LIBSTB_REAL_CORPUS_DIR comes from FetchRealCorpus.cmake (included by
|
|
@@ -118,10 +118,10 @@ if(LIBSTB_REAL_CORPUS_DIR)
|
|
|
118
118
|
COMMENT "libstb benchmarks: converting the real-world photographs to every format"
|
|
119
119
|
USES_TERMINAL
|
|
120
120
|
)
|
|
121
|
-
add_custom_target(
|
|
121
|
+
add_custom_target(stb_bench_real_corpus DEPENDS "${REAL_CORPUS_MANIFEST}")
|
|
122
122
|
list(APPEND BENCH_MANIFESTS "${REAL_CORPUS_MANIFEST}")
|
|
123
123
|
else()
|
|
124
|
-
add_custom_target(
|
|
124
|
+
add_custom_target(stb_bench_real_corpus
|
|
125
125
|
COMMENT "libstb benchmarks: real corpus unavailable (download failed), skipping"
|
|
126
126
|
)
|
|
127
127
|
endif()
|
|
@@ -141,7 +141,7 @@ add_custom_command(
|
|
|
141
141
|
COMMENT "libstb benchmarks: verifying every operation produces correct output"
|
|
142
142
|
USES_TERMINAL
|
|
143
143
|
)
|
|
144
|
-
add_custom_target(
|
|
144
|
+
add_custom_target(stb_bench_verify DEPENDS "${VERIFY_JSON}")
|
|
145
145
|
|
|
146
146
|
# ---------------------------------------------------------------- sizes --
|
|
147
147
|
|
|
@@ -154,7 +154,7 @@ add_custom_command(
|
|
|
154
154
|
COMMENT "libstb benchmarks: comparing install footprint (pip-size)"
|
|
155
155
|
USES_TERMINAL
|
|
156
156
|
)
|
|
157
|
-
add_custom_target(
|
|
157
|
+
add_custom_target(stb_bench_sizes DEPENDS "${SIZES_JSON}")
|
|
158
158
|
|
|
159
159
|
# ----------------------------------------------------------- throughput --
|
|
160
160
|
# Repeats per (library, corpus entry, operation) cell; the best (min)
|
|
@@ -176,8 +176,8 @@ add_custom_command(
|
|
|
176
176
|
COMMENT "libstb benchmarks: decode / encode / resize speed, all libraries (${LIBSTB_BENCH_REPEATS} repeats/cell)"
|
|
177
177
|
USES_TERMINAL
|
|
178
178
|
)
|
|
179
|
-
add_custom_target(
|
|
180
|
-
add_dependencies(
|
|
179
|
+
add_custom_target(stb_bench_throughput DEPENDS "${THROUGHPUT_JSON}")
|
|
180
|
+
add_dependencies(stb_bench_throughput stb_bench_verify stb_bench_corpus stb_bench_real_corpus)
|
|
181
181
|
|
|
182
182
|
# ------------------------------------------------------- throughput memory --
|
|
183
183
|
# Memory alongside speed for the SAME operations, libraries and corpus
|
|
@@ -198,8 +198,8 @@ add_custom_command(
|
|
|
198
198
|
COMMENT "libstb benchmarks: peak memory for decode / encode / resize, all libraries"
|
|
199
199
|
USES_TERMINAL
|
|
200
200
|
)
|
|
201
|
-
add_custom_target(
|
|
202
|
-
add_dependencies(
|
|
201
|
+
add_custom_target(stb_bench_throughput_memory DEPENDS "${THROUGHPUT_MEMORY_JSON}")
|
|
202
|
+
add_dependencies(stb_bench_throughput_memory stb_bench_verify stb_bench_corpus stb_bench_real_corpus)
|
|
203
203
|
|
|
204
204
|
# -------------------------------------------------------------- scaling --
|
|
205
205
|
|
|
@@ -213,8 +213,8 @@ add_custom_command(
|
|
|
213
213
|
COMMENT "libstb benchmarks: time vs image size (0.016 to 16.8 megapixels)"
|
|
214
214
|
USES_TERMINAL
|
|
215
215
|
)
|
|
216
|
-
add_custom_target(
|
|
217
|
-
add_dependencies(
|
|
216
|
+
add_custom_target(stb_bench_scaling DEPENDS "${SCALING_JSON}")
|
|
217
|
+
add_dependencies(stb_bench_scaling stb_bench_verify)
|
|
218
218
|
|
|
219
219
|
# ---------------------------------------------------------------- fonts --
|
|
220
220
|
# Needs a real .ttf (LIBSTB_REAL_FONT, from FetchRealCorpus.cmake). If it
|
|
@@ -231,9 +231,9 @@ if(LIBSTB_REAL_FONT)
|
|
|
231
231
|
COMMENT "libstb benchmarks: text (stb_truetype vs FreeType via Pillow)"
|
|
232
232
|
USES_TERMINAL
|
|
233
233
|
)
|
|
234
|
-
add_custom_target(
|
|
234
|
+
add_custom_target(stb_bench_fonts DEPENDS "${FONTS_JSON}")
|
|
235
235
|
else()
|
|
236
|
-
add_custom_target(
|
|
236
|
+
add_custom_target(stb_bench_fonts
|
|
237
237
|
COMMENT "libstb benchmarks: no font available (download failed), skipping the font benchmark"
|
|
238
238
|
)
|
|
239
239
|
endif()
|
|
@@ -251,7 +251,7 @@ add_custom_command(
|
|
|
251
251
|
COMMENT "libstb benchmarks: recording machine specs (CPU/RAM/OS)"
|
|
252
252
|
USES_TERMINAL
|
|
253
253
|
)
|
|
254
|
-
add_custom_target(
|
|
254
|
+
add_custom_target(stb_bench_system_info DEPENDS "${SYSTEM_INFO_JSON}")
|
|
255
255
|
|
|
256
256
|
# Expose to the parent scope (report/CMakeLists.txt needs these paths)
|
|
257
257
|
set(LIBSTB_BENCH_RESULT_JSON_DIR "${RESULTS_DIR}" PARENT_SCOPE)
|