Closed bnomei closed 1 year ago
Thanks for bringing the library up to speed with current PHP versions! I'm perfectly fine accepting this PR, but it's going to require a version bump to 4.0 to prevent breaking things for existing users.
Before we proceed, are there any other breaking changes you think should be made?
like you said in https://github.com/claviska/SimpleImage/issues/284 i would also v4 mainly to upgrade php version. the api in its current state does not need changing imho - it get the job done well.
EXIF personally i would love to see the exif https://github.com/claviska/SimpleImage/issues/157 issue solved but that would also mean to introduce an option for people that depend on the data being removed to keep it that way. maybe copying exif also has and performance impact (when a bulk of images is created via a CMS etc)
FORMAT SPECIFIC OPTIONS
some GD image methods would accept additional options that use defaults but can not be set right now. maybe all toXXX()
api methods could get a new generic $option
value that gets expanded as params into the functions if it exists?
imagebmp()
has compression
(see https://github.com/claviska/SimpleImage/pull/286)imageavif()
has a speed
imagepng()
has quality
and filters
example:
public function toString($mimeType = null, $quality = 100, $options = null)
{
return $this->generate($mimeType, $quality, $options)['data'];
}
protected function generate($mimeType = null, $quality = 100, $options = null)
{
// OTHER CODE
is_array($options) ?
imageavif($this->image, null, $quality, ...$options) :
imageavif($this->image, null, $quality);
}
used like this...
echo $image->toScreen('image/avif', 80, ['speed' => 8]);
maybe all toXXX() api methods could get a new generic $option value that gets expanded as params into the functions if it exists?
Should we also combine $quality
into $options
since it varies with some formats? Do you want to take this on, or would you rather me do it?
i will add a suggestion to my PR during the next few days.
@claviska updated the PR with toXXX()
adjustments and added type declarations.
decided that i will not work on the exif issue. feel free to release v4 without it.
I just wanted to say that this PR looks really good. I only noticed that one issue with bestFit()
passing a float to resize()
, breaking the image. Again, the same problem might be affecting other methods so we may want to check for that.
It's been awhile, but IIRC most of the GD functions require integers so we should probably use round()
whenever we divide. Do you want to take a stab at getting those updated as well?
sure. i can do that.
there are lots remaining related resource/GDImage/false and since some methods return false instead of throwing an error. but I think it should be good enough for now.
Thanks so much for this. A 4.0.0 tag has been created.
this PR
.gitattributes
file