---
name: "PDF::Builder::Resource::XObject::Image"
section: "3pm"
platform: "linux"
package: "perl-pdf-builder"
version: "3.028-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/PDF::Builder::Resource::XObject::Image"
---

# PDF::Builder::Resource::XObject::Image(3pm)

Base class for external raster image objects Inherits from PDF::Builder::Resource::XObject

## NAME

PDF::Builder::Resource::XObject::Image - Base class for external raster image objects

Inherits from PDF::Builder::Resource::XObject

## METHODS

### new

```
    $image = PDF::Builder::Resource::XObject::Image->new($pdf, $name)
```

Returns an image resource object.

### width

```
    $width = $image->width()
```

Get the width (in points) of the image object.

**Note** that this function also has the ability to *set* the width, by giving the new width (in points), but it appears that it never  worked correctly. The *set* capability has been **deprecated**, and  may be removed soon, unless it is found to be needed for an \<img\> tag in `column()`. If you are using the `width()` method in some manner to *set* the image width, please let us know, so we can plan to keep it enabled!

### height

```
    $height = $image->height()
```

Get the height (in points) of the image object.

**Note** that this function also has the ability to *set* the height, by giving the new height (in points), but it appears that it never  worked correctly. The *set* capability has been **deprecated**, and  may be removed soon, unless it is found to be needed for an \<img\> tag in `column()`. If you are using the `height()` method in some manner to *set* the image height, please let us know, so we can plan to keep it enabled!

### smask

```
    $image->smask($xobject)
```

Set the soft-mask image object.

### mask

```
    $image->mask(@color_range)
    $image->mask($xobject)
```

Set the mask to an image mask XObject or an array containing a range of colors to be applied as a color key mask.

### colorspace

```
    $image->colorspace($name)
    $image->colorspace($array)
```

Set the color space used by the image. Depending on the color space, this will either be just the name of the color space, or it will be an array containing the color space and any required parameters.

If passing an array, parameters must already be encoded as PDF objects. The array itself may also be a PDF object. If not, one will be created.

### bits\_per\_component

```
    $image->bits_per_component($integer)
```

Set the number of bits used to represent each color component.
