I was trying to find out how to crop-to-fit an image with GD
. But there were no examples with Phalcon. There was one post that mentioned using Imagick
. The only problem was that you needed to compiled Imagick with --lrf
in order to use liquidRescale
. This may not be an option on many hosting platforms. For that reason, I wanted to use GD
instead.
I found this post after a quick Google search. It helped me create the base for my Phalcon version of the function. This may seem pretty easy for some people, but I found enough people asking, that I figured I would share the whole code.
If you really wanted to use Imagick, then you could just replace GD in the constructor (Phalcon\Image\Adapter\Imagick($source)
) and it should work fine. This way you don't need to compile Imagick from source in order to get liquidRescale
.
James Doyle
I'm a full-stack developer, co-organizer of PHP Vancouver meetup, and winner of a Canadian Developer 30 under 30 award. I'm a huge Open Source advocate and contributor to a lot of projects in my community. When I am not sitting at a computer, I'm trying to perfect some other skill.