在哪里可以找到PythonMagick的文档和示例
我在谷歌上搜索了一下,但没有找到太多信息。
发布于 2009-11-16 18:04:41
编辑:这里没什么可看的。请参阅better answer below。
它是到MagickWand API的绑定:http://www.assembla.com/wiki/show/pythonmagickwand
因此,您可以使用所有的MagickWand应用编程接口函数。
#!/usr/bin/python
import Magick
# Use the Python Imaging Library to create a Tk display
dpy = Magick.TkDisplay(startmain=0)
# Read the image
img = Magick.read('test.gif')
# Display the image
dpy(img)
dpy(img.Swirl(90))
dpy.startmain=1
dpy.show()发布于 2011-03-04 09:24:21
我在任何地方也找不到它们,但这就是我如何使用它的。
示例
import PythonMagick
image = PythonMagick.Image("sample_image.jpg")
print image.fileName()
print image.magick()
print image.size().width()
print image.size().height()输出如下所示
sample_image.jpg
JPEG
345
229为了找出可用的图像方法,例如,我查看了cpp源代码。以图像对象绑定:在_Image.cpp中实现的图像为例,或者更好的是,在此页面上查看Klaus的另一个答案中包含的方法的建议。
在此文件中,您将看到如下所示的行
.def("contrast", &Magick::Image::contrast)
.def("convolve", &Magick::Image::convolve)
.def("crop", &Magick::Image::crop)
.def("cycleColormap", &Magick::Image::cycleColormap)
.def("despeckle", &Magick::Image::despeckle)引号中的位映射到Image对象的函数名。按照这种方法,你可以弄清楚足够有用的东西。例如,_Geometry.cpp中包含几何的特定方法,并且包括通常的可疑方法,如
.def("width", (size_t (Magick::Geometry::*)() const)&Magick::Geometry::width)
.def("height", (void (Magick::Geometry::*)(size_t) )&Magick::Geometry::height)
.def("height", (size_t (Magick::Geometry::*)() const)&Magick::Geometry::height)
.def("xOff", (void (Magick::Geometry::*)(ssize_t) )&Magick::Geometry::xOff)
.def("xOff", (ssize_t (Magick::Geometry::*)() const)&Magick::Geometry::xOff)发布于 2011-04-04 05:33:38
要找出这些方法,请在Python中键入:
import PythonMagick
dir(PythonMagick.Image())然后,您将得到如下输出:
['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__instance_size__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'adaptiveThreshold', 'addNoise', 'adjoin', 'affineTransform', 'animationDelay', 'animationIterations', 'annotate', 'antiAlias', 'attribute', 'backgroundColor', 'backgroundTexture', 'baseColumns', 'baseFilename', 'baseRows', 'blur', 'border', 'borderColor', 'boundingBox', 'boxColor', 'cacheThreshold', 'channel', 'channelDepth', 'charcoal', 'chop', 'chromaBluePrimary', 'chromaGreenPrimary', 'chromaRedPrimary', 'chromaWhitePoint', 'classType', 'clipMask', 'colorFuzz', 'colorMap', 'colorMapSize', 'colorSpace', 'colorize', 'columns', 'comment', 'compare', 'compose', 'composite', 'compressType', 'contrast', 'convolve', 'crop', 'cycleColormap', 'debug', 'defineSet', 'defineValue', 'density', 'depth', 'despeckle', 'directory', 'display', 'draw', 'edge', 'emboss', 'endian', 'enhance', 'equalize', 'erase', 'fileName', 'fileSize', 'fillColor', 'fillPattern', 'fillRule', 'filterType', 'flip', 'floodFillColor', 'floodFillOpacity', 'floodFillTexture', 'flop', 'font', 'fontPointsize', 'fontTypeMetrics', 'format', 'frame', 'gamma', 'gaussianBlur', 'geometry', 'gifDisposeMethod', 'iccColorProfile', 'implode', 'interlaceType', 'iptcProfile', 'isValid', 'label', 'lineWidth', 'magick', 'magnify', 'map', 'matte', 'matteColor', 'matteFloodfill', 'meanErrorPerPixel', 'medianFilter', 'minify', 'modifyImage', 'modulate', 'modulusDepth', 'monochrome', 'montageGeometry', 'negate', 'normalize', 'normalizedMaxError', 'normalizedMeanError', 'oilPaint', 'opacity', 'opaque', 'page', 'penColor', 'penTexture', 'ping', 'pixelColor', 'process', 'profile', 'quality', 'quantize', 'quantizeColorSpace', 'quantizeColors', 'quantizeDither', 'quantizeTreeDepth', 'raise', 'read', 'readPixels', 'reduceNoise', 'registerId', 'renderingIntent', 'resolutionUnits', 'roll', 'rotate', 'rows', 'sample', 'scale', 'scene', 'segment', 'shade', 'sharpen', 'shave', 'shear', 'signature', 'size', 'solarize', 'spread', 'statistics', 'stegano', 'stereo', 'strokeAntiAlias', 'strokeColor', 'strokeDashOffset', 'strokeLineCap', 'strokeLineJoin', 'strokeMiterLimit', 'strokePattern', 'strokeWidth', 'subImage', 'subRange', 'swirl', 'syncPixels', 'textEncoding', 'texture', 'threshold', 'throwImageException', 'tileName', 'totalColors', 'transform', 'transformOrigin', 'transformReset', 'transformRotation', 'transformScale', 'transformSkewX', 'transformSkewY', 'transparent', 'trim', 'type', 'unregisterId', 'unsharpmask', 'verbose', 'view', 'wave', 'write', 'writePixels', 'x11Display', 'xResolution', 'yResolution', 'zoom']
https://stackoverflow.com/questions/1740158
复制相似问题