skillfed

rectangle-packer

Pack a set of rectangles into a bounding box with minimum area

rectangle-packer v2.1.0 207.7K downloads/30d#9,544 on PyPI77
Permissive license MIT Active released

What it is and what it does

rectangle-packer is a Python library that solves the 2D rectangle packing problem: given a collection of rectangles with fixed dimensions, it arranges them into a bounding box with minimal area and no overlaps. The package is implemented in C for performance and exposes a simple Python API that takes a list of (width, height) tuples and returns the (x, y) coordinates where each rectangle should be placed.

The library targets developers working on layout problems in graphics, game engines, texture atlasing, or any domain requiring efficient spatial arrangement of rectangular objects. It has no runtime dependencies and supports modern Python versions (3.9 through 3.14) across Linux, macOS, and Windows with precompiled wheels.

Use it for:

  • Generate texture atlases for game engines by packing sprite sheets into minimal-area canvases.
  • Optimize UI layout in graphics applications by arranging rectangular elements with minimal wasted space.
  • Arrange rectangular bins or containers in warehouse or logistics planning simulations.
  • Pack rectangular images or tiles into a single image file for efficient storage and rendering.
  • Solve bin-packing problems in manufacturing or material-cutting scenarios.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Packs a set of rectangles with fixed orientations into a minimal-area bounding box with no overlaps, returning the (x, y) coordinates of each rectangle's lower-left corner.

Yes. The package is stable (Production/Stable status), actively maintained, has no known vulnerabilities, and solves a well-defined problem with a clean API. The medium install friction is offset by precompiled wheels for common platforms and Python versions. Install it if you need to pack rectangles efficiently.

Install

rectangle-packer on PyPI

pip

pip install rectangle-packer

uv

uv add rectangle-packer

poetry

poetry add rectangle-packer

Installing rectangle-packer

Before you install

Medium install friction due to compiled wheels for multiple platforms and Python versions (3.9–3.14). Active maintenance with recent release (155 days ago) and no known vulnerabilities.

License in practice

MIT license is permissive; you can use, modify, and distribute this package with minimal restrictions.

Quickstart

python3 -m pip install rectangle-packer

Import the module and call pack() with a list of (width, height) tuples to get (x, y) coordinates for each rectangle's lower-left corner.

Requires Python 3.9 or later.

Verify before relying

  • Whether the packing algorithm guarantees optimal solutions or uses a heuristic approach.
  • Performance characteristics (time/space complexity) for large numbers of rectangles.
  • Whether rectangles can be rotated or only placed in fixed orientations.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 155 days since the last release
Last repo commit
First released
Downloads 207,686/month — #9,544 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: rectangle_packer-2.1.0-cp311-cp311-macosx_10_9_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-musllinux_1_2_aarch64.whl; rectangle_packer-2.1.0-cp311-cp311-musllinux_1_2_x86_64.whl; rectangle_packer-2.1.0-cp311-cp311-win32.whl; rectangle_packer-2.1.0-cp311-cp311-win_amd64.whl; rectangle_packer-2.1.0-cp312-cp312-macosx_10_13_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-musllinux_1_2_aarch64.whl; rectangle_packer-2.1.0-cp312-cp312-musllinux_1_2_x86_64.whl; rectangle_packer-2.1.0-cp312-cp312-win32.whl; rectangle_packer-2.1.0-cp312-cp312-win_amd64.whl; rectangle_packer-2.1.0-cp313-cp313-macosx_10_13_x86_64.whl; rectangle_packer-2.1.0-cp313-cp313-macosx_11_0_arm64.whl; rectangle_packer-2.1.0-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; rectangle_packer-2.1.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Keywords: pack, rectangle, packing, rectangles, enclosing, 2D

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: MacOSOperating System :: Microsoft :: Windows :: Windows 10Operating System :: POSIX :: LinuxProgramming Language :: CProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPython

Tags

rectangle packing algorithm2D bin packingrectangle layout optimizationminimize bounding box areapack rectangles no overlap2D rectangle placementenclosing bounding box
geometryoptimizationspatial-layout

More Mathematics packages