Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Imagemagick 集合抽样算法_Imagemagick_Pythonmagick - Fatal编程技术网

Imagemagick 集合抽样算法

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) 如何设置要使用的采样算法?我相信现在它使

我正在尝试使用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)

如何设置要使用的采样算法?我相信现在它使用的是最近邻,看起来有点难看。

在调用
.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)