---
Product: psd
Platform: python
Page Type: reference
Canonical URL: https://reference.aspose.org/psd/python/rectangle
---

# Rectangle

## Overview

`Rectangle` is a class in Aspose.PSD FOSS for Python.

Stores a set of four integers that represent the location and size of a rectangle.

This class declares 24 methods for Rectangle objects in Python programs.
Available methods include: `__copy__`, `__eq__`, `__hash__`, `__init__`, `__ne__`, `__repr__`, `__str__`, `ceiling`, `contains`, `empty`, `from_left_top_right_bottom`, `from_ltrb`, and 12 additional methods.
Public members are accessible to any Python application after installing the Aspose.PSD FOSS for Python package.
Properties: `bottom`, `height`, `is_empty`, `left`, `location`, `right`, and 5 more.

## Properties

| Name | Type | Access | Description |
|------|------|--------|-------------|
| `bottom` | - | Read/Write | Gets or sets the y-coordinate of the bottom edge of this Rectangle. |
| `is_empty` | - | Read | Gets a value indicating whether this Rectangle has no location or size. |
| `left` | - | Read/Write | Gets or sets the x-coordinate of the left edge of this Rectangle. |
| `right` | - | Read/Write | Gets or sets the x-coordinate of the right edge of this Rectangle. |
| `top` | - | Read/Write | Gets or sets the y-coordinate of the top edge of this Rectangle. |
| `location` | - | Read/Write | Gets or sets the coordinates of the upper-left corner of this Rectangle. |
| `size` | - | Read/Write | Gets or sets the size of this Rectangle. |
| `x` | - | Read | Gets the x. |
| `y` | - | Read | Gets the y. |
| `width` | - | Read | Gets the width. |
| `height` | - | Read | Gets the height. |

## Methods

| Signature | Description |
|-----------|-------------|
| `__init__(x, y, width, height)` | Calls __init__(x, y, width, height) on this Rectangle instance. |
| `empty()` | Represents a Rectangle structure with its properties left uninitialized. |
| `from_left_top_right_bottom(left, top, right, bottom)` | Creates a rectangle from edge coordinates. |
| `from_ltrb(left, top, right, bottom)` | Creates a rectangle from edge coordinates for internal PSD record parsing. |
| `from_points(point1, point2)` | Creates a rectangle that spans the specified points. |
| `from_point_and_size(location: Point, size: Size)` | Initializes a new instance from a Point and a Size. |
| `ceiling(value)` | Converts a RectangleF structure to a Rectangle structure by rounding up the coordinates and size. |
| `round(value)` | Converts a RectangleF structure to a Rectangle structure by rounding the coordinates and size. |
| `truncate(value)` | Converts a RectangleF structure to a Rectangle structure by truncating the coordinates and size. |
| `inflate_rect(rectangle, x, y)` | Creates and returns an inflated copy of the specified rectangle. |
| `intersect_rect(a, b)` | Returns a rectangle that represents the intersection of two rectangles. |
| `union_rect(a, b)` | Returns a rectangle that contains the union of two rectangles. |
| `contains()` | Determines whether the specified point or rectangle is contained within this Rectangle. |
| `__eq__(other)` | Calls __eq__(other) on this Rectangle instance. |
| `__ne__(other)` | Calls __ne__(other) on this Rectangle instance. |
| `__hash__()` | Calls __hash__ on this Rectangle instance. |
| `__str__()` | Calls __str__ on this Rectangle instance. |
| `__repr__()` | Calls __repr__ on this Rectangle instance. |
| `__copy__()` | Calls __copy__ on this Rectangle instance. |
| `inflate()` | Inflates this rectangle by the specified size or dimensions. |
| `intersect(rectangle)` | Replaces this rectangle with its intersection with the specified rectangle. |
| `intersects_with(rectangle)` | Determines whether this rectangle intersects with the specified rectangle. |
| `normalize()` | Normalizes this rectangle so that width and height are non-negative. |
| `offset()` | Moves this rectangle by the specified point or offsets. |

## See Also

- [Aspose.PSD for Python — Enterprise API Reference](https://reference.aspose.com/psd/python-net/)