php-imagine / Imagine

PHP Object Oriented image manipulation library
https://imagine.readthedocs.io
Other
4.42k stars 530 forks source link

Enables the GD support for resolution options group for PHP 7 >= 7.2, PHP 8.0. #813

Open gutocf opened 2 years ago

gutocf commented 2 years ago

Example:

<?php

use Imagine\Image\ImageInterface;

$imagine = new Imagine\Gd\Imagine();

$options = array(
    'resolution-units' => ImageInterface::RESOLUTION_PIXELSPERINCH,
    'resolution-x' => 300,
    'resolution-y' => 300,
);

$imagine->open('/path/to/image.jpg')->save('/path/to/image.jpg', $options);
bartthys commented 7 months ago

Hi @gutocf @ausi I'm looking for exactly this feature, I see the PR was approved but it was never merged?

ausi commented 7 months ago

@bartthys I’m not a maintainer of this repository, so my approval has no “official” meaning ☺️

ausi commented 7 months ago

In the meantime you can workaround that by using something like this in your code:

if ($yourImage instanceof \Imagine\Gd\Image) {
    imageresolution($yourImage->getGdResource(), $resolutionXppi, $resolutionYppi);
}