You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# py_gd
1
+
# `py_gd`
2
2
3
3
Python wrappers for libgd graphics drawing lib.
4
4
5
-
Welcome to the py_gd project.
5
+
Welcome to the `py_gd` project.
6
6
7
-
py-gd aims to provide nice pythonic wrappers around libgd -- a nice, fast, and simple drawing lib:
7
+
py-gd aims to provide nice Pythonic wrappers around libgd -- a nice, fast, and simple drawing lib:
8
8
9
9
https://github.com/libgd/libgd/
10
10
@@ -14,52 +14,51 @@ For the project at hand we needed fast and simple drawing -- 8-bit color, no ant
14
14
We also wanted a nice simple API to work with. There are a number of newer drawing libs (AGG, Skia)
15
15
that produce some pretty results, but are not as simple to use, and are focused on 32 bit fully
16
16
anti-aliased drawing. If you want the prettiest rendering possible, I encourage you to check those out.
17
-
If you want something fast and simple -- py_gd may be for you.
17
+
If you want something fast and simple -- `py_gd` may be for you.
18
18
19
19
## Why a new python wrapper for gd?
20
20
21
-
gdmodule (recently moved to gitHub: https://github.com/Solomoriah/gdmodule) is a wrapper
22
-
for gd that has been aaround along time. However:
21
+
`gdmodule` (recently moved to gitHub: https://github.com/Solomoriah/gdmodule) is a wrapper
22
+
for gd that has been around along time. However:
23
23
- It appears to be minimally maintained
24
24
- It is a pretty direct wrapper around the gd old-style-C API
25
25
- It is hand-written C extension code -- more or less the state of the art for 1995
26
26
when it was first written, but I really don't want to work on that code!
27
27
28
28
On the other hand:
29
-
- py_gd is being actively worked on now. While only supporting Py2 at the moment,
30
-
it should be pretty easy to make a Py3k version.
31
-
- py_gd is a "thick" wrapper -- we're trying to provide a nice object oriented, pythonic inteface.
32
-
- py_gd uses numpy (and the PEP3118 buffer interface) to allow efficient transfer of data back and forth between Python and gd.
33
-
- py_gd is written in cython, which is likely to be more robust and error free and easier to maintain.
29
+
-`py_gd` is being actively maintained.
30
+
-`py_gd` is a "thick" wrapper -- we're trying to provide a nice object oriented, Pythonic interface.
31
+
-`py_gd` uses numpy (and the PEP3118 buffer interface) to allow efficient transfer of data back and forth between Python and gd.
32
+
-`py_gd` is written in Cython, which is likely to be more robust and error free and easier to maintain.
34
33
35
-
However, there is some nice stuff in gdmodule (like including a truetype font) that I we want to borrow.
34
+
However, there is some nice stuff in gdmodule (like including a truetype font) that we want to borrow at some point.
36
35
37
-
## How is py_gd built?
36
+
## How is `py_gd` built?
38
37
39
-
py_gd is built using Cython: (www.cython.org). Cython allows us to both call into the existing gd C lib, and to also write wrapper code to make a nicer API in a very efficient way. You shouldn't need Cython to use py_gd, but you'll need it if you want to contribute to the wrappers.
38
+
`py_gd` is built using Cython: (www.cython.org). Cython allows us to both call into the existing gd C lib, and to also write wrapper code to make a nicer API in a very efficient way. You shouldn't need Cython to use `py_gd`, but you'll need it if you want to contribute to the wrappers or compile the code yourself.
40
39
41
40
42
41
## Dependencies:
43
42
44
-
py_gd currently requires the numpy package: http://www.numpy.org
43
+
`py_gd` currently requires the numpy package: http://www.numpy.org
45
44
46
-
numpy is used to allow you to very efficiently pass in data structures for things like vertexes of large polygons, etc, and can be used to get a copy of the image buffer, and manipulate it in various ways, as well as passing it back to py_gd.
45
+
numpy is used to allow you to very efficiently pass in data structures for things like vertices of large polygons, etc, and can be used to get a copy of the image buffer, and manipulate it in various ways, as well as passing it back to `py_gd`.
47
46
48
-
In order to build py_gd, the Cython package is also required: http://cython.org/
47
+
In order to build `py_gd`, the Cython package is also: http://cython.org/
49
48
50
-
## Is py_gd a complete wrapper around gd?
49
+
## Is `py_gd` a complete wrapper around gd?
51
50
52
51
In a word: no.
53
52
54
-
py_gd is in its infancy, and not the least bit complete. It does, however have enough to be useful (at least to us).
53
+
`py_gd` was developed to meet particular needs, and is not the least bit complete. It does, however have enough to be useful (at least to us).
55
54
56
55
Major Working features:
57
56
* 8-bit "paletted" images
58
57
* transparent background
59
58
* built-in fonts for text
60
59
* lines, polygons, arcs
61
60
* copying between images
62
-
* saving as gif, bmp, png, jpeg
61
+
* saving as gif, bmp, png, jpeg, and animated gif.
63
62
* numpy arrays for input and image buffer exchange.
64
63
65
64
Major Missing features:
@@ -75,46 +74,47 @@ You sure you can -- fork the source, and hack away -- you can actually add featu
75
74
Here's what you need to do:
76
75
77
76
* find the function you want to wrap in gd.h
78
-
* copy the prototype to py_gd.pxd, and edit it to make it Cython-compatible (copy what's done for the ones already there)
79
-
* add a method to the Image class in py_gd.pyx -- look for similar methods already, and try to keep the API similar.
80
-
* add a test to test_gd.py (Or a new test file) that tests your new method
81
-
* re-build (``pip install -e ./`` or ``setup.py build_ext --inplace``)
77
+
* copy the prototype to `py_gd.pxd`, and edit it to make it
78
+
Cython-compatible (copy what's done for the ones already there)
79
+
* add a method to the Image class in `py_gd.pyx` -- look for similar
80
+
methods already, and try to keep the API similar.
81
+
* add a test to `test_gd.py` (Or a new test file) that tests your new
82
+
method
83
+
* re-build (``pip install -e ./`` or
84
+
``setup.py build_ext --inplace``)
82
85
* try out your test...
83
86
* lather, rinse, repeat, 'till it all works
84
87
85
88
# Build/Install
86
89
87
90
## Windows
88
91
89
-
py_gd depends on libgd which, in turn, depends on libpng, and others -- this makes it a major pain to build on Windows. Unless you are an expert, we suggest using Anaconda Python [https://www.continuum.io/why-anaconda], and the conda packages found in the noaa-orr-erd Anaconda channel. It should be as easy as:
92
+
`py_gd` depends on libgd which, in turn, depends on libpng, and others -- this makes it a major pain to build on Windows. Unless you are an expert, we suggest using Anaconda Python [https://www.continuum.io/why-anaconda], or miniconda and the conda packages found in the conda-forge channel. It should be as easy as:
py_gd depends on libgd which, in turn, depends on libpng, and others -- You can use macports or homebrew or roll your own to get these, but it's probably easier to use Anaconda Python [https://www.continuum.io/why-anaconda], and the conda packages found in the noaa-orr-erd Anaconda channel. It should then be as easy as:
100
+
`py_gd` depends on libgd which, in turn, depends on libpng, and others -- You can use macports or homebrew or roll your own to get these, but it's probably easier to use Anaconda Python [https://www.continuum.io/why-anaconda], or miniconda and the conda packages found in the conda-forge channel. It should be as easy as:
py_gd depends on libgd, which may be available in your distro's repo (it's used heavily by PHP). However your distro's version may be too old for py_gd, so you may have to built it yourself
106
106
107
-
### Anaconda
107
+
##Linux
108
108
109
-
We've put up pacakges for the Anaconda python distribution [https://www.continuum.io/why-anaconda] in our channel. So if yo'pve got Anaconda (or miniconda) installed, it should be as easy as:
109
+
`py_gd` depends on libgd, which may be available in your distro's repo (it's used heavily by PHP). However your distro's version may be too old for `py_gd`, so you may have to built it yourself. However, uyou can also use conda pacakges on Linux. Install Anaconda Python [https://www.continuum.io/why-anaconda], or miniconda and use the conda packages found in the conda-forge channel. It should be as easy as:
py_gd requires libgd version 2.1.1 (or maybe greater?). If your Linux distro has an up to date version, you can probably simply install it (and the development headers) from the system repos. something like:
117
+
`py_gd` requires libgd version 2.1.1 (or maybe greater?). If your Linux distro has an up to date version, you can probably simply install it (and the development headers) from the system repos. something like:
118
118
119
119
```bash
120
120
apt-get install libgd, libgd-dev
@@ -139,16 +139,16 @@ dance. This will install into ``/usr/local/`` if you use the defaults. If your s
139
139
```bash
140
140
export LD_LIBRARY_PATH='/usr/local/lib'
141
141
```
142
-
(or set that globally) It needs to be set whenever you are running py_gd.
142
+
(or set that globally) It needs to be set whenever you are running `py_gd`.
143
143
144
144
Note: If you determine that you lack jpeg support these libs are known to be compatible and can be installed through yum:
145
145
146
146
* libjpeg-turbo-devel
147
147
* libjpeg-turbo
148
148
149
-
## Building py_gd
149
+
## Building `py_gd`
150
150
151
-
* Clone the [py_gd repository](https://github.com/NOAA-ORR-ERD/py_gd) to your local machine
151
+
* Clone the [`py_gd` repository](https://github.com/NOAA-ORR-ERD/py_gd) to your local machine
152
152
* Create a virtualenv or conda environemnt to scope your python installations to this project (<i>optional</i>)
153
153
* pip install cython
154
154
* pip install numpy
@@ -157,7 +157,7 @@ Note: If you determine that you lack jpeg support these libs are known to be com
157
157
158
158
```bash
159
159
$ python setup.py build
160
-
$ pip install -e ./
160
+
$ pip install ./
161
161
```
162
162
163
163
* pip install pytest and run py.test to see that everything is working:
0 commit comments