在 Imagemagick 中调整大小之前使用印章
Use chop before resize in Imagemagick
我正在使用回形针gem处理图像。
在某些图像中,我需要切掉源图像的前 35 个像素,然后进行转换和处理
目前我正在使用
:convert_options => {
all: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x35' : '' } -limit memory 64 -limit map 128"},
mobile_sm: "-resize 620 -quality 90 -strip -interlace Plane",
mobile_lg: "-resize 1280 -quality 80 -strip -interlace Plane",
feature: "-quality 90 -strip -interlace Plane",
medium: "-quality 85 -strip -interlace Plane",
preview: "-quality 85 -strip -interlace Plane",
tiny: "-quality 90 -strip -interlace Plane"}
这在大多数情况下是有效的,但在 mobile_lg
上似乎在调整大小后发生了印章(我想这也发生在其他人身上,只是不太明显)
如何使用 -chop
以便它在调整大小之前完成?
用 +repage
解决了它,而不是 :all
所以基本上它看起来像
all: "-limit memory 64 -limit map 128",
mobile_sm: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x31 +repage' : '' } -resize 640 -quality 90 -strip -interlace Plane"},
mobile_lg: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x31 +repage' : '' } -resize 1280 -quality 80 -strip -interlace Plane"},
它可以被重构,但 c'est la vie
出于某种原因,将 lambda 放在 all
中不起作用,所以我猜这是不同的行为。
我正在使用回形针gem处理图像。
在某些图像中,我需要切掉源图像的前 35 个像素,然后进行转换和处理
目前我正在使用
:convert_options => {
all: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x35' : '' } -limit memory 64 -limit map 128"},
mobile_sm: "-resize 620 -quality 90 -strip -interlace Plane",
mobile_lg: "-resize 1280 -quality 80 -strip -interlace Plane",
feature: "-quality 90 -strip -interlace Plane",
medium: "-quality 85 -strip -interlace Plane",
preview: "-quality 85 -strip -interlace Plane",
tiny: "-quality 90 -strip -interlace Plane"}
这在大多数情况下是有效的,但在 mobile_lg
上似乎在调整大小后发生了印章(我想这也发生在其他人身上,只是不太明显)
如何使用 -chop
以便它在调整大小之前完成?
用 +repage
解决了它,而不是 :all
所以基本上它看起来像
all: "-limit memory 64 -limit map 128",
mobile_sm: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x31 +repage' : '' } -resize 640 -quality 90 -strip -interlace Plane"},
mobile_lg: lambda{ |instance| "#{!instance.chop_top.blank? ? '-chop 0x31 +repage' : '' } -resize 1280 -quality 80 -strip -interlace Plane"},
它可以被重构,但 c'est la vie
出于某种原因,将 lambda 放在 all
中不起作用,所以我猜这是不同的行为。