php - ImageMagick Reize canvas to specifications and scale image? -



php - ImageMagick Reize canvas to specifications and scale image? -

i have specific sized canvas (let's 400x300 pixels) , have image amount, want scale downwards (paying attending ratios proper ratio) , fit within canvas, part know how do. want create canvas 400x300.

so image let's 300x600. scaled 150x300 (so fits within 400x300) , centered , image "applied" white canvas of 400x300. , size image.

i don't know how lastly part.

update: noticed comment on post want php bindings. reply supplied applies command line, not php. can't help that. leaving reply in case helps.

to center smaller image on big canvas, utilize extent operator gravity. so, example, if img.gif resized 150x300 image, center image on 400x300 white canvas:

-gravity center -extent 400x300 img.gif

[note can set "-background " if want canvas other white, defaults white.]

php imagemagick

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -