Подтвердить что ты не робот

Документы и примеры PythonMagick

Где я могу найти документ и примеры PythonMagick?

Я сделал поиск в Google, но не было найдено никакой информации.

4b9b3361

Ответ 1

Это привязка к API MagickWand: http://www.assembla.com/wiki/show/pythonmagickwand

Таким образом, вы можете использовать все функции API 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()

Ответ 2

Я тоже не мог найти их нигде, но я так и думал об этом.

Пример

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)

Ответ 3

Чтобы узнать тип методов в 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']

Ответ 4

Из того, что я могу сказать, PythonMagick обертывает Библиотека Magick ++. Я смог скопировать и вставить код С++, используя эту библиотеку в python, и он работает так, как ожидалось. Кроме того, имена классов и функций-членов соответствуют (где, как и MagickWand, кажется, совершенно разные).

    import PythonMagick as Magick
    img = Magick.Image("testIn.jpg")
    img.quality(100) #full compression
    img.magick('PNG')
    img.write("testOut.png")