File: README.rst

package info (click to toggle)
python-pgmagick 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 712 kB
  • sloc: cpp: 3,481; python: 1,618; makefile: 147
file content (122 lines) | stat: -rw-r--r-- 3,089 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
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
------
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)

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