php - How to show image always in a square -


i want show image inside square of fixed dimension of 400 * 400. hence maintain aspect ratio, possible if width more, width reduced , remaining space per aspect ratio filled background color (i can give color on div). if height more, height adjusted show per aspect ratio , remaining space filled background.

could me how achieve this? can done imagemagick? http://php.net/manual/en/book.imagick.php

any appreciated.

use phpthumb.

    require_once '/path/to/thumblib.inc.php';       $thumb = phpthumbfactory::create('path/to/image.jpg');        //$thumb->resize(400, 400);       // resize image , make thumbnail cropping image automatically     $thumb->adaptiveresize(400, 400)->save('/path/to/thumb.jpg'); ; 

for more reading goto phpthumb


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -