stefangabos / Zebra_Image

A single-file lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters
https://stefangabos.github.io/Zebra_Image/Zebra_Image/Zebra_Image.html
Other
138 stars 51 forks source link

Cropped image black borders #18

Closed skerbis closed 4 years ago

skerbis commented 5 years ago

Is it possible to set the background color if the cropped result is outside the image? Now it gets a black border. I only see a definition in the resize method but not at the cropping.

stefangabos commented 4 years ago

You mean like if from an 100x100 image I would crop 50, 50, 150, 150?

stefangabos commented 4 years ago

i think the best way would be to have it transparent for images that support transparency and a user defined colour for JPEG

skerbis commented 4 years ago

That would be nice

skerbis commented 4 years ago

Look: From

Bildschirmfoto 2020-01-23 um 16 21 59

I get this: redaxo_1

skerbis commented 4 years ago

Because it's possible to set the cropping outside the picture, I get black bars.

stefangabos commented 4 years ago

yes, i understand. i'll try and work on it over the weekend

skerbis commented 4 years ago

I‘ll test it

stefangabos commented 4 years ago

I did a commit that should fix this issue. It will automatically use a transparent colour for transparent GIF and PNGs and black for non-transparent images. A custom colour can be also specified. I updated the documentation. Please consider this work-in-progress. Thanks!

skerbis commented 4 years ago

Cool 👍 thx. I will test it today

skerbis commented 4 years ago

@stefangabos tested 👍 .. thank you

stefangabos commented 4 years ago

thank you for reporting and testing. i've created a release so you can now update via composer