PHPackages                             dialloibrahima/intervention-image-mask - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. dialloibrahima/intervention-image-mask

ActiveLibrary[Image &amp; Media](/categories/media)

dialloibrahima/intervention-image-mask
======================================

Adds mask() and opacity() modifiers to Intervention Image v3

v1.0.1(6mo ago)2131↓73.3%MITPHPPHP ^8.3

Since Dec 10Pushed 6mo agoCompare

[ Source](https://github.com/ibra379/intervention-image-mask)[ Packagist](https://packagist.org/packages/dialloibrahima/intervention-image-mask)[ RSS](/packages/dialloibrahima-intervention-image-mask/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Intervention Image Mask
=======================

[](#intervention-image-mask)

[![Latest Version on Packagist](https://camo.githubusercontent.com/39ba00f60f62c5ca0553e12e85a7e96714144272596296ea1efb337f11ac9f82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6469616c6c6f6962726168696d612f696e74657276656e74696f6e2d696d6167652d6d61736b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dialloibrahima/intervention-image-mask)[![Tests](https://camo.githubusercontent.com/cb5a29472ac11bb5e73612c880efe1743f179181364a8a2891b3fd978c3c47f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d31372532307061737365642d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://github.com/dialloibrahima/intervention-image-mask/actions)[![PHP Version](https://camo.githubusercontent.com/c6a81ad6daf03a271e9bb8a8acfe9150bb6518eba29e5dba4c6acf621f603dc2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://php.net)[![License](https://camo.githubusercontent.com/ac049ef4e7a0b7196b09add6ac2d4f180e544c0ac779c2b2ac2fd2723a209579/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265)](LICENSE.md)

> 🎭 Restore the beloved `mask()` and `opacity()` methods removed in Intervention Image v3

---

🚀 Why This Package?
-------------------

[](#-why-this-package)

With the release of **Intervention Image v3**, the popular `mask()` and `opacity()` methods were removed. This package brings them back as clean, framework-agnostic modifiers that work seamlessly with both **GD** and **Imagick** drivers.

### ✨ Features

[](#-features)

- 🎭 **Apply masks** to images using alpha channels
- 🔮 **Control opacity** with precise float values (0.0 to 1.0)
- 🖼️ **Dual driver support** - Works with both GD and Imagick
- ⚡ **Zero configuration** - Just install and use
- 🧪 **Fully tested** - 17 tests with 25 assertions
- 📦 **Lightweight** - No extra dependencies beyond Intervention Image

---

📦 Installation
--------------

[](#-installation)

```
composer require dialloibrahima/intervention-image-mask
```

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Intervention Image 3.0 or higher
- GD or Imagick PHP extension

---

🎯 Quick Start
-------------

[](#-quick-start)

### Apply a Mask

[](#apply-a-mask)

Use a mask image to define transparency. The mask's alpha channel determines which parts of the original image become transparent.

```
use DialloIbrahima\InterventionMask\ApplyMask;
use Intervention\Image\ImageManager;
use Intervention\Image\Drivers\Gd\Driver;

$manager = new ImageManager(new Driver());

// Load your image and mask
$image = $manager->read('photo.jpg');
$mask = $manager->read('mask.png');

// Apply the mask
$result = $image->modify(new ApplyMask($mask));

// Save the result
$result->toPng()->save('masked-photo.png');
```

### Set Opacity

[](#set-opacity)

Control the transparency level of an entire image with a simple float value.

```
use DialloIbrahima\InterventionMask\SetOpacity;

$image = $manager->read('photo.png');

// 50% opacity
$result = $image->modify(new SetOpacity(0.5));

$result->toPng()->save('semi-transparent.png');
```

---

📖 API Reference
---------------

[](#-api-reference)

### `ApplyMask`

[](#applymask)

Applies a mask image to define transparency regions.

```
new ApplyMask(ImageInterface $mask)
```

ParameterTypeDescription`$mask``ImageInterface`The mask image. Its alpha channel defines transparency.**How it works:**

- White areas (or opaque) in the mask → Image is visible
- Black areas (or transparent) in the mask → Image becomes transparent
- Gray areas → Partial transparency

---

### `SetOpacity`

[](#setopacity)

Sets the overall opacity level of an image.

```
new SetOpacity(float $opacity)
```

ParameterTypeDescription`$opacity``float`Opacity level from 0.0 (fully transparent) to 1.0 (fully opaque)**Examples:**

- `0.0` → Completely invisible
- `0.5` → 50% transparent
- `1.0` → Fully opaque (no change)

---

💡 Use Cases
-----------

[](#-use-cases)

### 🧩 Puzzle Piece Effect

[](#-puzzle-piece-effect)

```
$piece = $manager->read('puzzle-background.jpg');
$shape = $manager->read('puzzle-piece-shape.png');

$puzzlePiece = $piece->modify(new ApplyMask($shape));
```

### 🖼️ Image Watermark with Transparency

[](#️-image-watermark-with-transparency)

```
$watermark = $manager->read('logo.png');
$fadedWatermark = $watermark->modify(new SetOpacity(0.3));
```

### 📸 Vignette Effect

[](#-vignette-effect)

```
$photo = $manager->read('portrait.jpg');
$vignette = $manager->read('vignette-mask.png');

$vintagePhoto = $photo->modify(new ApplyMask($vignette));
```

### 🎨 Gradient Fade

[](#-gradient-fade)

```
$image = $manager->read('landscape.jpg');
$gradientMask = $manager->read('horizontal-gradient.png');

$fadedImage = $image->modify(new ApplyMask($gradientMask));
```

---

🔧 Using with Imagick
--------------------

[](#-using-with-imagick)

The package automatically detects and uses the appropriate driver:

```
use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver;

$manager = new ImageManager(new ImagickDriver());

// Same API - driver is detected automatically
$result = $image->modify(new ApplyMask($mask));
```

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

Run static analysis:

```
composer analyse
```

Format code with Pint:

```
composer format
```

---

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---

🙏 Credits
---------

[](#-credits)

- [Ibrahima Diallo](https://github.com/ibra379)
- Inspired by the original Intervention Image v2 implementation

---

 Made with ❤️ for the PHP community

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance66

Regular maintenance activity

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

205d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/102914230?v=4)[Ibrahima Diallo](/maintainers/ibra379)[@ibra379](https://github.com/ibra379)

---

Top Contributors

[![ibra379](https://avatars.githubusercontent.com/u/102914230?v=4)](https://github.com/ibra379 "ibra379 (5 commits)")

---

Tags

phpimagegdimagickinterventionmaskopacity

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dialloibrahima-intervention-image-mask/health.svg)

```
[![Health](https://phpackages.com/badges/dialloibrahima-intervention-image-mask/health.svg)](https://phpackages.com/packages/dialloibrahima-intervention-image-mask)
```

###  Alternatives

[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k53.3M146](/packages/league-glide)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M183](/packages/intervention-image-laravel)[aplus/image

Aplus Framework Image Library

2241.6M1](/packages/aplus-image)[zenstruck/image

Image file wrapper with generic transformation support.

3135.6k1](/packages/zenstruck-image)[intervention/image-symfony

Symfony Integration of Intervention Image

1097.0k](/packages/intervention-image-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
