【发布时间】:2020-03-29 05:07:38
【问题描述】:
我尝试使用 ImageMagic 为图像添加边框,使其尺寸可被 4 整除。我写道:
image_files=( "$alldir"/*.png )
current="${image_files[0]}"
page_height=$(identify -format "%h" $current)
page_width=$(identify -format "%w" $current)
border_x=$((4-(page_width%4) + 40))
border_y=$((4-(page_height%4) + 40))
使用border 命令后,我会:
page_height= page_height + 2*border_y
page_width= page_width + 2*border_x
最后的 page_height 和 page_width 预计可以被 4 整除,但宽度是奇数。我的方法有什么问题?
【问题讨论】:
-
你没有展示你是如何尝试添加边框的!您的代码暗示您正在调整图像的大小(因为您计算了新的宽度和高度),但在新大小之后您将需要
!,否则它将在保持纵横比的同时调整大小。显示您的代码,我会提供帮助。
标签: linux bash imagemagick