Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.86k stars 1.5k forks source link

Image not trimming using bottom-right with GD or with Imagick #1201

Closed Kalan-Brock closed 5 months ago

Kalan-Brock commented 1 year ago
$full_image = Image::make(storage_path('app/images_to_import/' . $product['file_name']));
$full_width = $full_image->width();
$full_image->crop($full_width, 288)->trim('bottom-right', null, 60)->save(storage_path('app/generated_images/' . $file_name . '.webp', 100, 'webp'));

I've tried with both GD and Imagick.

It's leaving a white border on the right side of my image still:

image

MarcBrillault commented 1 year ago

I cannot reproduce using this code with php 8.2.1, could you try ?

<?php

use Intervention\Image\ImageManager;

require_once __DIR__ . '/vendor/autoload.php';

// Photo by Gabriel Ramos https://unsplash.com/fr/photos/w-irkTtm8VI
$image = 'https://images.unsplash.com/photo-1677616842809-0a5297aced15?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=735&q=80';

$manager = new ImageManager();
$full_image = $manager->make($image);
$full_width = $full_image->width();
$full_image->crop($full_width, 288)->trim('bottom-right', null, 60)->save('./image.webp', 100, 'webp');