File: README.rst

package info (click to toggle)
python-pgmagick 0.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 720 kB
  • ctags: 744
  • sloc: cpp: 3,522; python: 1,693; makefile: 152
file content (148 lines) | stat: -rw-r--r-- 3,668 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
About
=====
pgmagick is a yet another boost.python based wrapper for GraphicsMagick.


Install
=======
install to::

    $ pip install pgmagick


Require
=======
Python2.5++, GraphicsMagick and Boost.Python.

package install on Ubuntu(test on Ubuntu10.04+)::

    ### Ubuntu11.10+ ###
    $ apt-get install python-pgmagick

    ### Ubuntu10.04+ ###
    $ apt-get install libgraphicsmagick++1-dev
    $ apt-get install libboost-python1.40-dev

package install on Fedora::

    $ yum install GraphicsMagick-c++-devel
    $ yum install boost-devel

GraphicsMagick from source package::

    $ ./configure --enable-shared=yes
    $ make && make install

MacOSX
------
*update 2013.08.31*
with Homebrew_ ::

    $ brew install graphicsmagick     # or imagemagick
    $ brew install boost --with-thread-unsafe --build-from-source
    $ pip install pgmagick

install reported on MacOSX, Thanks Rohan Singh and Simon Harrison.

- http://rohanradio.com/blog/2011/12/02/installing-pgmagick-on-os-x/
- http://simonharrison.info/talk/2011/01/17/pgmagick-on-mac-os/ (old)

.. _Homebrew: http://brew.sh/

Windows
-------
Now, not official support.
However, *unofficial* binary packages exists.

- http://www.lfd.uci.edu/~gohlke/pythonlibs/#pgmagick

ImageMagick support
-------------------
pgmagick is supported to ImageMagick library. (*version:0.4+*)

package install on Ubuntu(test on Ubuntu10.04+)::

    $ apt-get install libmagick++-dev

show library name and version::

    >>> from pgmagick import gminfo
    >>> gminfo.library
    'GraphicsMagick'    # or 'ImageMagick'
    >>> gminfo.version
    '1.3.x'
    >>>

Usage
=====

scale example::

    >>> from pgmagick import Image, FilterTypes
    >>> im = Image('input.jpg')
    >>> im.quality(100)
    >>> im.filterType(FilterTypes.SincFilter)
    >>> im.scale('100x100')
    >>> im.sharpen(1.0)
    >>> im.write('output.jpg')

composite example::

    >>> from pgmagick import Image, CompositeOperator as co
    >>> base = Image('base.png')
    >>> layer = Image('layer_one.png')
    >>> base.composite(layer, 100, 100, co.OverCompositeOp)
    >>> im.write('output.png')

draw example::

    >>> from pgmagick import Image, DrawableCircle, DrawableText, Geometry, Color
    >>> im = Image(Geometry(300, 300), Color("yellow"))
    >>> circle = DrawableCircle(100, 100, 20, 20)
    >>> im.draw(circle)
    >>> im.fontPointsize(65)
    >>> text = DrawableText(30, 250, "Hello pgmagick")
    >>> im.draw(text)
    >>> im.write('hoge.png')

blob access::

    >>> from pgmagick import Image, Blob, Geometry
    >>> blob = Blob(open('filename.jpg').read())
    >>> blob.update(open('filename2.jpg').read())
    >>> img = Image(blob, Geometry(600, 480))
    >>> img.scale('300x200')
    >>> img.write('out.jpg')

create animated-GIF::

    from pgmagick import Image, ImageList, Geometry, Color

    imgs = ImageList()
    for color in ('red', 'blue', 'green', 'black', 'yellow'):
        imgs.append(Image(Geometry(200, 200), Color(color)))
    imgs.animationDelayImages(100)
    imgs.scaleImages(Geometry(100, 100))
    imgs.writeImages('output.gif')

more API detail... read to `Magick++ API for GraphicsMagick`_ document.

.. _`Magick++ API for GraphicsMagick`: http://www.graphicsmagick.org/Magick++/

Python APIs(*NOTICE!! this api is alpha version!!*)::

    >>> from pgmagick.api import Image
    >>> img = Image((300, 300), "gradient:#ffffff-#000000")
    >>> img.scale(0.8)
    >>> img.write('out.png')


Links
=====
* PyPI_
* bitbucket_
* `CI(Jenkins)`_

.. _PyPI: http://pypi.python.org/pypi/pgmagick/
.. _bitbucket: https://bitbucket.org/hhatto/pgmagick/
.. _`CI(Jenkins)`: http://jenkins.hexacosa.net/job/pgmagick/