web-dev-qa-db-ja.com

PythonMagickのドキュメントと例

PythonMagick のドキュメントと例はどこにありますか?

私はグーグルで検索をしましたが、あまり情報が見つかりませんでした。

30
jack

どこにも見つかりませんでしたが、とにかく使ってみました。

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オブジェクトバインディングの取得:_ 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特定のメソッドが_ 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)
31
David Kierans

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']

17
klaus

私が言えることから、PythonMagickは Magick ++ライブラリ をラップします。このライブラリを使用してC++コードをpythonにコピーして貼り付けることができ、期待どおりに機能します。さらに、クラスとメンバー関数の名前が一致します(MagickWandは完全に異なるようです) 。

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

PythonMagickのドキュメントを探している人にとって、PythonMagickはMagick ++(C++のAPI)とまったく同じです。 ここ はMagick ++のドキュメントです。いくつかの特定のパラメーターについては、タイプと列挙を見つける必要があります(例:重力-> PythonMagick.GravityType.thegravityyouwant)

2
Smelly Potato