PHPackages                             maagi/imagine-focalresizer - 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. maagi/imagine-focalresizer

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

maagi/imagine-focalresizer
==========================

Focal point resizing for Imagine

0.2.0(10y ago)29.4k21MITPHP

Since Feb 1Pushed 10y ago3 watchersCompare

[ Source](https://github.com/maagi/imagine-focalresizer)[ Packagist](https://packagist.org/packages/maagi/imagine-focalresizer)[ RSS](/packages/maagi-imagine-focalresizer/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

\#ImagineFocalResizer

A tool for [Imagine Image manipulation library](http://imagine.readthedocs.org/) for PHP to resize its image instances using a central "focal point". The image will always be cropped so that the focal point remains within the resized image. This allows to create versions for different screen sizes while maintaining a "responsive crop".

The focal point defined by x and y coordinates ranging from the left top corner (-1,1) to the right bottom corner (1,-1). The center of the image is at (0,0).

**Note:** The y-axis has been flipped in version 0.2.0 so that the top edge is at 1 and bottom edge at -1.

The idea comes from Jono Menz's jQuery FocusPoint plugin. Its [documentation](https://github.com/jonom/jquery-focuspoint) illustrates how the approach works.

\##Installation##

Use [Composer](https://getcomposer.org/) to install.

```
$ composer require maagi/imagine-focalresizer
```

\##Usage##

```
use Imagine\Gd\Imagine; // or Imagick/Gmagick
use Imagine\Image\ImageInterface;
use Imagine\Image\Box;
use Maagi\ImagineFocalResizer\Resizer;
use Maagi\ImagineFocalResizer\FocalPoint;

$imagine = new Imagine();
$image = $imagine->open('dragonfly.jpg');

$resizer = new Resizer();

$resizer->resize(
    $image,
    // target size
    new Box(100, 200),
    // crop around the point at 50% to the right and 70% to the top
    new FocalPoint(0.5, 0.7),
    // Imagine filter for resize (optional)
    ImageInterface::FILTER_UNDEFINED
);

// maybe do further processing with the image...

$image->save('dragonfly-resized.jpg');

```

\##How it works##

The cropping strategy used here is very simple. It just compares the width and height ratios of the original and target sizes. The focal point will be on the center of the crop on the axis on which the ratio is greater while the other axis will remain uncropped. If a part of the crop area goes beyond the image's edge it will be moved accordingly.

\##Contribution##

I know there are other cropping strategies and some fit certain scenarios better than the others. Please suggest other (better) ways to do this. The logic could then be extracted to several strategy classes and let the user decide which one to use.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

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

Every ~34 days

Total

2

Last Release

3718d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79fb02391b1c5583b311ffbb6de9a8f5c22f4f46bda04f6efb8e5a93ae0d1a84?d=identicon)[maagi](/maintainers/maagi)

---

Tags

imageresizingscaling

### Embed Badge

![Health badge](/badges/maagi-imagine-focalresizer/health.svg)

```
[![Health](https://phpackages.com/badges/maagi-imagine-focalresizer/health.svg)](https://phpackages.com/packages/maagi-imagine-focalresizer)
```

###  Alternatives

[liip/imagine-bundle

This bundle provides an image manipulation abstraction toolkit for Symfony-based projects.

1.7k38.3M217](/packages/liip-imagine-bundle)[folklore/image

Image manipulation library for Laravel 5 based on Imagine and inspired by Croppa for easy url based manipulation

270248.2k5](/packages/folklore-image)[orchestra/imagine

Imagine (Wrapper) Component for Laravel

70207.0k3](/packages/orchestra-imagine)[media-alchemyst/media-alchemyst

An Object Oriented wrapper for easy multimedia conversion, based on Imagine, FFMpeg, SwfTools, Unoconv and other libs

65216.4k1](/packages/media-alchemyst-media-alchemyst)[toinekamps/responsive-pics

Responsive Pics is a Wordpress tool for resizing images on the fly.

831.2k](/packages/toinekamps-responsive-pics)[webcoast/deferred-image-processing

Handles image processing on request instead of during page generation

1336.1k](/packages/webcoast-deferred-image-processing)

PHPackages © 2026

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