Search code examples
phpimage-resizing

Is there a function in PHP (or ImageMagick) resize image to best cover?


I thought it was a simple question but I was surprised that there are no solution on Google. Sorry if I missed some results. Is there a way to resize an image to best covers an area instead of best fit without calculating the width height and position by myself?

For best covers, I mean something like background-size: cover; in CSS.


Solution

  • There's nothing built-in for this purpose. However, you may be able to find a package which can do this.