Imagemagick 集合抽样算法
我正在尝试使用PythonMagick从jpg图像创建缩略图:Imagemagick 集合抽样算法,imagemagick,pythonmagick,Imagemagick,Pythonmagick,我正在尝试使用PythonMagick从jpg图像创建缩略图: img.quality(90) # TODO set the sampling algo e.g. bilinear img.sample(Geometry(scaledWid, scaledHei)) img.crop(Geometry(THUMBNAIL_WID-1, THUMBNAIL_HEI-1,cropLeft, cropTop)) img.write(destFilePath) 如何设置要使用的采样算法?我相信现在它使
img.quality(90)
# TODO set the sampling algo e.g. bilinear
img.sample(Geometry(scaledWid, scaledHei))
img.crop(Geometry(THUMBNAIL_WID-1, THUMBNAIL_HEI-1,cropLeft, cropTop))
img.write(destFilePath)
如何设置要使用的采样算法?我相信现在它使用的是最近邻,看起来有点难看。在调用
.resize()
或者我想,.sample()
之前,通过图像集上的属性设置大小调整过滤器
该属性是.filterType()
,它是从PythonMagick.FilterTypes上的一个枚举值设置的,该值与
(注意,PythonMagick从来没有任何文档,但由于它本质上只是一个包装器,所以只需使用。)
所以请尝试(未经测试,我不使用Python):
注意默认的过滤器通常是LanczosFilter
,或者至少应该是这样,这很好
img.quality(90)
img.filterType(PythonMagick.FilterTypes.SincFilter)
img.sample(Geometry(scaledWid, scaledHei))
img.crop(Geometry(THUMBNAIL_WID-1, THUMBNAIL_HEI-1,cropLeft, cropTop))
img.write(destFilePath)