使用ImageMagick将图像放在较大的画布中 [英] Use ImageMagick to place an image inside a larger canvas

查看:193
本文介绍了使用ImageMagick将图像放在较大的画布中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开始使用ImageMagic并试图找到一种方法来执行此操作...如果图像高度小于50像素或宽度为50像素,我想将其放置在水平/垂直方向(未缩放)在白色背景上的新50x50像素画布的中心 - 并将其保存为新图像。任何人都知道ImageMagick是否可以实现这一目标?谢谢!

Getting started with ImageMagic and trying to find a way to do this... If an image is less than 50 pixels tall or 50 pixels wide, I'd like to place it (un-scaled) in the horizontal/vertical center of a new 50x50 pixel canvas on top of a white background - and save that as the new image. Anyone know if this is possible with ImageMagick? Thanks!

推荐答案

我用-extent来做到这一点:

I used -extent to do this:

convert input.jpg -gravity center -background white -extent 50x50  output.jpg

这篇关于使用ImageMagick将图像放在较大的画布中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆