summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Antognolli <antognolli@gmail.com>2009-07-13 22:29:13 +0000
committerRafael Antognolli <antognolli@gmail.com>2009-07-13 22:29:13 +0000
commitf6eeda654637394b08975c1d449b1fd94f81218e (patch)
treeed188882e3e5cea181356887290df094f3b6a6be
Added python bindings to ethumb client library.
These are first bindings, only for the client library that. Later I will add the rest of them and provide some documentation and examples. SVN revision: 41324
-rw-r--r--AUTHORS1
-rw-r--r--COPYING504
-rw-r--r--ethumb/__init__.py22
-rw-r--r--ethumb/ethumb.c_ethumb.pyx45
-rw-r--r--ethumb/ethumb.client.pyx306
-rw-r--r--ez_setup.py272
-rw-r--r--include/ethumb/__init__.py0
-rw-r--r--include/ethumb/c_ethumb.pxd29
-rw-r--r--include/ethumb/client.pxd70
-rw-r--r--include/ethumb/python.pxd20
-rw-r--r--setup.py128
11 files changed, 1397 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..cfc62b6
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
Rafael Antognolli <antognolli@profusion.mobi>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..5ab7695
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9[This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16freedom to share and change it. By contrast, the GNU General Public
17Licenses are intended to guarantee your freedom to share and change
18free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21specially designated software packages--typically libraries--of the
22Free Software Foundation and other authors who decide to use it. You
23can use it too, but we suggest you first think carefully about whether
24this license or the ordinary General Public License is the better
25strategy to use in any particular case, based on the explanations below.
26
27 When we speak of free software, we are referring to freedom of use,
28not price. Our General Public Licenses are designed to make sure that
29you have the freedom to distribute copies of free software (and charge
30for this service if you wish); that you receive source code or can get
31it if you want it; that you can change the software and use pieces of
32it in new free programs; and that you are informed that you can do
33these things.
34
35 To protect your rights, we need to make restrictions that forbid
36distributors to deny you these rights or to ask you to surrender these
37rights. These restrictions translate to certain responsibilities for
38you if you distribute copies of the library or if you modify it.
39
40 For example, if you distribute copies of the library, whether gratis
41or for a fee, you must give the recipients all the rights that we gave
42you. You must make sure that they, too, receive or can get the source
43code. If you link other code with the library, you must provide
44complete object files to the recipients, so that they can relink them
45with the library after making changes to the library and recompiling
46it. And you must show them these terms so they know their rights.
47
48 We protect your rights with a two-step method: (1) we copyright the
49library, and (2) we offer you this license, which gives you legal
50permission to copy, distribute and/or modify the library.
51
52 To protect each distributor, we want to make it very clear that
53there is no warranty for the free library. Also, if the library is
54modified by someone else and passed on, the recipients should know
55that what they have is not the original version, so that the original
56author's reputation will not be affected by problems that might be
57introduced by others.
58
59 Finally, software patents pose a constant threat to the existence of
60any free program. We wish to make sure that a company cannot
61effectively restrict the users of a free program by obtaining a
62restrictive license from a patent holder. Therefore, we insist that
63any patent license obtained for a version of the library must be
64consistent with the full freedom of use specified in this license.
65
66 Most GNU software, including some libraries, is covered by the
67ordinary GNU General Public License. This license, the GNU Lesser
68General Public License, applies to certain designated libraries, and
69is quite different from the ordinary General Public License. We use
70this license for certain libraries in order to permit linking those
71libraries into non-free programs.
72
73 When a program is linked with a library, whether statically or using
74a shared library, the combination of the two is legally speaking a
75combined work, a derivative of the original library. The ordinary
76General Public License therefore permits such linking only if the
77entire combination fits its criteria of freedom. The Lesser General
78Public License permits more lax criteria for linking other code with
79the library.
80
81 We call this license the "Lesser" General Public License because it
82does Less to protect the user's freedom than the ordinary General
83Public License. It also provides other free software developers Less
84of an advantage over competing non-free programs. These disadvantages
85are the reason we use the ordinary General Public License for many
86libraries. However, the Lesser license provides advantages in certain
87special circumstances.
88
89 For example, on rare occasions, there may be a special need to
90encourage the widest possible use of a certain library, so that it becomes
91a de-facto standard. To achieve this, non-free programs must be
92allowed to use the library. A more frequent case is that a free
93library does the same job as widely used non-free libraries. In this
94case, there is little to gain by limiting the free library to free
95software only, so we use the Lesser General Public License.
96
97 In other cases, permission to use a particular library in non-free
98programs enables a greater number of people to use a large body of
99free software. For example, permission to use the GNU C Library in
100non-free programs enables many more people to use the whole GNU
101operating system, as well as its variant, the GNU/Linux operating
102system.
103
104 Although the Lesser General Public License is Less protective of the
105users' freedom, it does ensure that the user of a program that is
106linked with the Library has the freedom and the wherewithal to run
107that program using a modified version of the Library.
108
109 The precise terms and conditions for copying, distribution and
110modification follow. Pay close attention to the difference between a
111"work based on the library" and a "work that uses the library". The
112former contains code derived from the library, whereas the latter must
113be combined with the library in order to run.
114
115 GNU LESSER GENERAL PUBLIC LICENSE
116 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118 0. This License Agreement applies to any software library or other
119program which contains a notice placed by the copyright holder or
120other authorized party saying it may be distributed under the terms of
121this Lesser General Public License (also called "this License").
122Each licensee is addressed as "you".
123
124 A "library" means a collection of software functions and/or data
125prepared so as to be conveniently linked with application programs
126(which use some of those functions and data) to form executables.
127
128 The "Library", below, refers to any such software library or work
129which has been distributed under these terms. A "work based on the
130Library" means either the Library or any derivative work under
131copyright law: that is to say, a work containing the Library or a
132portion of it, either verbatim or with modifications and/or translated
133straightforwardly into another language. (Hereinafter, translation is
134included without limitation in the term "modification".)
135
136 "Source code" for a work means the preferred form of the work for
137making modifications to it. For a library, complete source code means
138all the source code for all modules it contains, plus any associated
139interface definition files, plus the scripts used to control compilation
140and installation of the library.
141
142 Activities other than copying, distribution and modification are not
143covered by this License; they are outside its scope. The act of
144running a program using the Library is not restricted, and output from
145such a program is covered only if its contents constitute a work based
146on the Library (independent of the use of the Library in a tool for
147writing it). Whether that is true depends on what the Library does
148and what the program that uses the Library does.
149
150 1. You may copy and distribute verbatim copies of the Library's
151complete source code as you receive it, in any medium, provided that
152you conspicuously and appropriately publish on each copy an
153appropriate copyright notice and disclaimer of warranty; keep intact
154all the notices that refer to this License and to the absence of any
155warranty; and distribute a copy of this License along with the
156Library.
157
158 You may charge a fee for the physical act of transferring a copy,
159and you may at your option offer warranty protection in exchange for a
160fee.
161
162 2. You may modify your copy or copies of the Library or any portion
163of it, thus forming a work based on the Library, and copy and
164distribute such modifications or work under the terms of Section 1
165above, provided that you also meet all of these conditions:
166
167 a) The modified work must itself be a software library.
168
169 b) You must cause the files modified to carry prominent notices
170 stating that you changed the files and the date of any change.
171
172 c) You must cause the whole of the work to be licensed at no
173 charge to all third parties under the terms of this License.
174
175 d) If a facility in the modified Library refers to a function or a
176 table of data to be supplied by an application program that uses
177 the facility, other than as an argument passed when the facility
178 is invoked, then you must make a good faith effort to ensure that,
179 in the event an application does not supply such function or
180 table, the facility still operates, and performs whatever part of
181 its purpose remains meaningful.
182
183 (For example, a function in a library to compute square roots has
184 a purpose that is entirely well-defined independent of the
185 application. Therefore, Subsection 2d requires that any
186 application-supplied function or table used by this function must
187 be optional: if the application does not supply it, the square
188 root function must still compute square roots.)
189
190These requirements apply to the modified work as a whole. If
191identifiable sections of that work are not derived from the Library,
192and can be reasonably considered independent and separate works in
193themselves, then this License, and its terms, do not apply to those
194sections when you distribute them as separate works. But when you
195distribute the same sections as part of a whole which is a work based
196on the Library, the distribution of the whole must be on the terms of
197this License, whose permissions for other licensees extend to the
198entire whole, and thus to each and every part regardless of who wrote
199it.
200
201Thus, it is not the intent of this section to claim rights or contest
202your rights to work written entirely by you; rather, the intent is to
203exercise the right to control the distribution of derivative or
204collective works based on the Library.
205
206In addition, mere aggregation of another work not based on the Library
207with the Library (or with a work based on the Library) on a volume of
208a storage or distribution medium does not bring the other work under
209the scope of this License.
210
211 3. You may opt to apply the terms of the ordinary GNU General Public
212License instead of this License to a given copy of the Library. To do
213this, you must alter all the notices that refer to this License, so
214that they refer to the ordinary GNU General Public License, version 2,
215instead of to this License. (If a newer version than version 2 of the
216ordinary GNU General Public License has appeared, then you can specify
217that version instead if you wish.) Do not make any other change in
218these notices.
219
220 Once this change is made in a given copy, it is irreversible for
221that copy, so the ordinary GNU General Public License applies to all
222subsequent copies and derivative works made from that copy.
223
224 This option is useful when you wish to copy part of the code of
225the Library into a program that is not a library.
226
227 4. You may copy and distribute the Library (or a portion or
228derivative of it, under Section 2) in object code or executable form
229under the terms of Sections 1 and 2 above provided that you accompany
230it with the complete corresponding machine-readable source code, which
231must be distributed under the terms of Sections 1 and 2 above on a
232medium customarily used for software interchange.
233
234 If distribution of object code is made by offering access to copy
235from a designated place, then offering equivalent access to copy the
236source code from the same place satisfies the requirement to
237distribute the source code, even though third parties are not
238compelled to copy the source along with the object code.
239
240 5. A program that contains no derivative of any portion of the
241Library, but is designed to work with the Library by being compiled or
242linked with it, is called a "work that uses the Library". Such a
243work, in isolation, is not a derivative work of the Library, and
244therefore falls outside the scope of this License.
245
246 However, linking a "work that uses the Library" with the Library
247creates an executable that is a derivative of the Library (because it
248contains portions of the Library), rather than a "work that uses the
249library". The executable is therefore covered by this License.
250Section 6 states terms for distribution of such executables.
251
252 When a "work that uses the Library" uses material from a header file
253that is part of the Library, the object code for the work may be a
254derivative work of the Library even though the source code is not.
255Whether this is true is especially significant if the work can be
256linked without the Library, or if the work is itself a library. The
257threshold for this to be true is not precisely defined by law.
258
259 If such an object file uses only numerical parameters, data
260structure layouts and accessors, and small macros and small inline
261functions (ten lines or less in length), then the use of the object
262file is unrestricted, regardless of whether it is legally a derivative
263work. (Executables containing this object code plus portions of the
264Library will still fall under Section 6.)
265
266 Otherwise, if the work is a derivative of the Library, you may
267distribute the object code for the work under the terms of Section 6.
268Any executables containing that work also fall under Section 6,
269whether or not they are linked directly with the Library itself.
270
271 6. As an exception to the Sections above, you may also combine or
272link a "work that uses the Library" with the Library to produce a
273work containing portions of the Library, and distribute that work
274under terms of your choice, provided that the terms permit
275modification of the work for the customer's own use and reverse
276engineering for debugging such modifications.
277
278 You must give prominent notice with each copy of the work that the
279Library is used in it and that the Library and its use are covered by
280this License. You must supply a copy of this License. If the work
281during execution displays copyright notices, you must include the
282copyright notice for the Library among them, as well as a reference
283directing the user to the copy of this License. Also, you must do one
284of these things:
285
286 a) Accompany the work with the complete corresponding
287 machine-readable source code for the Library including whatever
288 changes were used in the work (which must be distributed under
289 Sections 1 and 2 above); and, if the work is an executable linked
290 with the Library, with the complete machine-readable "work that
291 uses the Library", as object code and/or source code, so that the
292 user can modify the Library and then relink to produce a modified
293 executable containing the modified Library. (It is understood
294 that the user who changes the contents of definitions files in the
295 Library will not necessarily be able to recompile the application
296 to use the modified definitions.)
297
298 b) Use a suitable shared library mechanism for linking with the
299 Library. A suitable mechanism is one that (1) uses at run time a
300 copy of the library already present on the user's computer system,
301 rather than copying library functions into the executable, and (2)
302 will operate properly with a modified version of the library, if
303 the user installs one, as long as the modified version is
304 interface-compatible with the version that the work was made with.
305
306 c) Accompany the work with a written offer, valid for at
307 least three years, to give the same user the materials
308 specified in Subsection 6a, above, for a charge no more
309 than the cost of performing this distribution.
310
311 d) If distribution of the work is made by offering access to copy
312 from a designated place, offer equivalent access to copy the above
313 specified materials from the same place.
314
315 e) Verify that the user has already received a copy of these
316 materials or that you have already sent this user a copy.
317
318 For an executable, the required form of the "work that uses the
319Library" must include any data and utility programs needed for
320reproducing the executable from it. However, as a special exception,
321the materials to be distributed need not include anything that is
322normally distributed (in either source or binary form) with the major
323components (compiler, kernel, and so on) of the operating system on
324which the executable runs, unless that component itself accompanies
325the executable.
326
327 It may happen that this requirement contradicts the license
328restrictions of other proprietary libraries that do not normally
329accompany the operating system. Such a contradiction means you cannot
330use both them and the Library together in an executable that you
331distribute.
332
333 7. You may place library facilities that are a work based on the
334Library side-by-side in a single library together with other library
335facilities not covered by this License, and distribute such a combined
336library, provided that the separate distribution of the work based on
337the Library and of the other library facilities is otherwise
338permitted, and provided that you do these two things:
339
340 a) Accompany the combined library with a copy of the same work
341 based on the Library, uncombined with any other library
342 facilities. This must be distributed under the terms of the
343 Sections above.
344
345 b) Give prominent notice with the combined library of the fact
346 that part of it is a work based on the Library, and explaining
347 where to find the accompanying uncombined form of the same work.
348
349 8. You may not copy, modify, sublicense, link with, or distribute
350the Library except as expressly provided under this License. Any
351attempt otherwise to copy, modify, sublicense, link with, or
352distribute the Library is void, and will automatically terminate your
353rights under this License. However, parties who have received copies,
354or rights, from you under this License will not have their licenses
355terminated so long as such parties remain in full compliance.
356
357 9. You are not required to accept this License, since you have not
358signed it. However, nothing else grants you permission to modify or
359distribute the Library or its derivative works. These actions are
360prohibited by law if you do not accept this License. Therefore, by
361modifying or distributing the Library (or any work based on the
362Library), you indicate your acceptance of this License to do so, and
363all its terms and conditions for copying, distributing or modifying
364the Library or works based on it.
365
366 10. Each time you redistribute the Library (or any work based on the
367Library), the recipient automatically receives a license from the
368original licensor to copy, distribute, link with or modify the Library
369subject to these terms and conditions. You may not impose any further
370restrictions on the recipients' exercise of the rights granted herein.
371You are not responsible for enforcing compliance by third parties with
372this License.
373
374 11. If, as a consequence of a court judgment or allegation of patent
375infringement or for any other reason (not limited to patent issues),
376conditions are imposed on you (whether by court order, agreement or
377otherwise) that contradict the conditions of this License, they do not
378excuse you from the conditions of this License. If you cannot
379distribute so as to satisfy simultaneously your obligations under this
380License and any other pertinent obligations, then as a consequence you
381may not distribute the Library at all. For example, if a patent
382license would not permit royalty-free redistribution of the Library by
383all those who receive copies directly or indirectly through you, then
384the only way you could satisfy both it and this License would be to
385refrain entirely from distribution of the Library.
386
387If any portion of this section is held invalid or unenforceable under any
388particular circumstance, the balance of the section is intended to apply,
389and the section as a whole is intended to apply in other circumstances.
390
391It is not the purpose of this section to induce you to infringe any
392patents or other property right claims or to contest validity of any
393such claims; this section has the sole purpose of protecting the
394integrity of the free software distribution system which is
395implemented by public license practices. Many people have made
396generous contributions to the wide range of software distributed
397through that system in reliance on consistent application of that
398system; it is up to the author/donor to decide if he or she is willing
399to distribute software through any other system and a licensee cannot
400impose that choice.
401
402This section is intended to make thoroughly clear what is believed to
403be a consequence of the rest of this License.
404
405 12. If the distribution and/or use of the Library is restricted in
406certain countries either by patents or by copyrighted interfaces, the
407original copyright holder who places the Library under this License may add
408an explicit geographical distribution limitation excluding those countries,
409so that distribution is permitted only in or among countries not thus
410excluded. In such case, this License incorporates the limitation as if
411written in the body of this License.
412
413 13. The Free Software Foundation may publish revised and/or new
414versions of the Lesser General Public License from time to time.
415Such new versions will be similar in spirit to the present version,
416but may differ in detail to address new problems or concerns.
417
418Each version is given a distinguishing version number. If the Library
419specifies a version number of this License which applies to it and
420"any later version", you have the option of following the terms and
421conditions either of that version or of any later version published by
422the Free Software Foundation. If the Library does not specify a
423license version number, you may choose any version ever published by
424the Free Software Foundation.
425
426 14. If you wish to incorporate parts of the Library into other free
427programs whose distribution conditions are incompatible with these,
428write to the author to ask for permission. For software which is
429copyrighted by the Free Software Foundation, write to the Free
430Software Foundation; we sometimes make exceptions for this. Our
431decision will be guided by the two goals of preserving the free status
432of all derivatives of our free software and of promoting the sharing
433and reuse of software generally.
434
435 NO WARRANTY
436
437 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456DAMAGES.
457
458 END OF TERMS AND CONDITIONS
459
460 How to Apply These Terms to Your New Libraries
461
462 If you develop a new library, and you want it to be of the greatest
463possible use to the public, we recommend making it free software that
464everyone can redistribute and change. You can do so by permitting
465redistribution under these terms (or, alternatively, under the terms of the
466ordinary General Public License).
467
468 To apply these terms, attach the following notices to the library. It is
469safest to attach them to the start of each source file to most effectively
470convey the exclusion of warranty; and each file should have at least the
471"copyright" line and a pointer to where the full notice is found.
472
473 <one line to give the library's name and a brief idea of what it does.>
474 Copyright (C) <year> <name of author>
475
476 This library is free software; you can redistribute it and/or
477 modify it under the terms of the GNU Lesser General Public
478 License as published by the Free Software Foundation; either
479 version 2.1 of the License, or (at your option) any later version.
480
481 This library is distributed in the hope that it will be useful,
482 but WITHOUT ANY WARRANTY; without even the implied warranty of
483 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 Lesser General Public License for more details.
485
486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software
488 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
489
490Also add information on how to contact you by electronic and paper mail.
491
492You should also get your employer (if you work as a programmer) or your
493school, if any, to sign a "copyright disclaimer" for the library, if
494necessary. Here is a sample; alter the names:
495
496 Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
499 <signature of Ty Coon>, 1 April 1990
500 Ty Coon, President of Vice
501
502That's all there is to it!
503
504
diff --git a/ethumb/__init__.py b/ethumb/__init__.py
new file mode 100644
index 0000000..8898d9b
--- /dev/null
+++ b/ethumb/__init__.py
@@ -0,0 +1,22 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18from c_ethumb import shutdown, Ethumb, ETHUMB_THUMB_NORMAL, \
19 ETHUMB_THUMB_LARGE, ETHUMB_THUMB_FDO, ETHUMB_THUMB_JPEG, \
20 ETHUMB_THUMB_EET, \
21 ETHUMB_THUMB_KEEP_ASPECT, ETHUMB_THUMB_IGNORE_ASPECT, \
22 ETHUMB_THUMB_CROP
diff --git a/ethumb/ethumb.c_ethumb.pyx b/ethumb/ethumb.c_ethumb.pyx
new file mode 100644
index 0000000..dfd9d1a
--- /dev/null
+++ b/ethumb/ethumb.c_ethumb.pyx
@@ -0,0 +1,45 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18__extra_epydoc_fields__ = (
19 ("parm", "Parameter", "Parameters"), # epydoc don't support pyrex properly
20 )
21
22def init():
23 return ethumb_init()
24
25def shutdown():
26 ethumb_shutdown()
27
28ETHUMB_THUMB_NORMAL = 0
29ETHUMB_THUMB_LARGE = 1
30
31ETHUMB_THUMB_FDO = 0
32ETHUMB_THUMB_JPEG = 1
33ETHUMB_THUMB_EET = 2
34
35ETHUMB_THUMB_KEEP_ASPECT = 0
36ETHUMB_THUMB_IGNORE_ASPECT = 1
37ETHUMB_THUMB_CROP = 2
38
39cdef class Ethumb:
40 """Ethumb thumbnail generator"""
41 def __init__(self):
42 """Ethumb constructor."""
43
44
45init()
diff --git a/ethumb/ethumb.client.pyx b/ethumb/ethumb.client.pyx
new file mode 100644
index 0000000..d1a336f
--- /dev/null
+++ b/ethumb/ethumb.client.pyx
@@ -0,0 +1,306 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18cimport ethumb.python as python
19import traceback
20
21__extra_epydoc_fields__ = (
22 ("parm", "Parameter", "Parameters"), # epydoc don't support pyrex properly
23 )
24
25def shutdown():
26 ethumb_client_shutdown()
27
28def init():
29 return ethumb_client_init()
30
31cdef void _connect_cb(Ethumb_Client *client, Eina_Bool success, void *data) with gil:
32 obj = <object>data
33 (self, func, args, kargs) = obj
34 if success:
35 s = True
36 else:
37 s = False
38 try:
39 func(self, s, *args, **kargs)
40 except Exception, e:
41 traceback.print_exc()
42
43cdef void _free_connect_cb_data(void *data) with gil:
44 obj = <object>data
45 python.Py_DECREF(obj)
46
47cdef void _generated_cb(int id, char *file, char *key, char *thumb_path, char *thumb_key, Eina_Bool success, void *data) with gil:
48 obj = <object>data
49 (self, func, args, kargs) = obj
50 f = str_from_c(file)
51 k = str_from_c(key)
52 tp = str_from_c(thumb_path)
53 tk = str_from_c(thumb_key)
54 s = success != 0
55 if success:
56 s = True
57 else:
58 s = False
59 try:
60 func(id, f, k, tp, tk, s, *args, **kargs)
61 except Exception, e:
62 traceback.print_exc()
63
64cdef void _generated_cb_free_data(void *data) with gil:
65 obj = <object>data
66 python.Py_DECREF(obj)
67
68cdef char *str_to_c(object s):
69 cdef char *mystr
70 if s is None:
71 mystr = NULL
72 else:
73 mystr = s
74 return mystr
75
76cdef object str_from_c(char *mystr):
77 if mystr != NULL:
78 return mystr
79
80cdef class Client:
81 """Client for Ethumbd server."""
82 def __init__(self, func, *args, **kargs):
83 """Ethumb Client constructor."""
84 if not callable(func):
85 raise TypeError("Parameter 'func' must be callable")
86 if self.obj == NULL:
87 targs = (self, func, args, kargs)
88 python.Py_INCREF(targs)
89 self.obj = ethumb_client_connect(
90 _connect_cb, <void*>targs, _free_connect_cb_data)
91
92 # FDO
93 def fdo_set(self, int s):
94 ethumb_client_fdo_set(self.obj, s)
95
96 # Size
97 def size_set(self, int w, int h):
98 ethumb_client_size_set(self.obj, w, h)
99
100 def size_get(self):
101 cdef int w, h
102 ethumb_client_size_get(self.obj, &w, &h)
103 return (w, h)
104
105 property size:
106 def __set__(self, value):
107 cdef int w, h
108 w, h = value
109 self.size_set(w, h)
110
111 def __get__(self):
112 return self.size_get()
113
114 # Format
115 def format_set(self, int f):
116 ethumb_client_format_set(self.obj, f)
117
118 def format_get(self):
119 return ethumb_client_format_get(self.obj)
120
121 property format:
122 def __set__(self, value):
123 self.format_set(value)
124
125 def __get__(self):
126 return self.format_get()
127
128 # Aspect
129 def aspect_set(self, int a):
130 ethumb_client_aspect_set(self.obj, a)
131
132 def aspect_get(self):
133 return ethumb_client_aspect_get(self.obj)
134
135 property aspect:
136 def __set__(self, value):
137 self.aspect_set(value)
138
139 def __get__(self):
140 return self.aspect_get()
141
142 # Crop
143 def crop_set(self, float x, float y):
144 ethumb_client_crop_align_set(self.obj, x, y)
145
146 def crop_get(self):
147 cdef float x, y
148 ethumb_client_crop_align_get(self.obj, &x, &y)
149 return (x, y)
150
151 property crop:
152 def __set__(self, value):
153 cdef float x, y
154 x, y = value
155 self.crop_set(x, y)
156
157 def __get__(self):
158 return self.crop_get()
159
160 # Quality
161 def quality_set(self, int quality):
162 ethumb_client_quality_set(self.obj, quality)
163
164 def quality_get(self):
165 return ethumb_client_quality_get(self.obj)
166
167 property quality:
168 def __set__(self, value):
169 self.quality_set(value)
170
171 def __get__(self):
172 return self.quality_get()
173
174 # Compress
175 def compress_set(self, int compress):
176 ethumb_client_compress_set(self.obj, compress)
177
178 def compress_get(self):
179 return ethumb_client_compress_get(self.obj)
180
181 property compress:
182 def __set__(self, value):
183 self.compress_set(value)
184
185 def __get__(self):
186 return self.compress_get()
187
188 # Directory
189 def directory_set(self, path):
190 ethumb_client_dir_path_set(self.obj, str_to_c(path))
191
192 def directory_get(self):
193 return str_from_c(ethumb_client_dir_path_get(self.obj))
194
195 property directory:
196 def __set__(self, value):
197 self.directory_set(value)
198
199 def __get__(self):
200 return self.directory_get()
201
202 # Category
203 def category_set(self, category):
204 ethumb_client_category_set(self.obj, str_to_c(category))
205
206 def category_get(self):
207 return str_from_c(ethumb_client_category_get(self.obj))
208
209 property category:
210 def __set__(self, value):
211 self.category_set(value)
212
213 def __get__(self):
214 return self.category_get()
215
216 # frame
217 def frame_set(self, file, group, swallow):
218 cdef char *f, *g, *s
219 f = str_to_c(file)
220 g = str_to_c(group)
221 s = str_to_c(swallow)
222 return ethumb_client_frame_set(self.obj, f, g, s)
223
224 # file
225 def file_set(self, path, key=None):
226 cdef char *p, *k
227 p = str_to_c(path)
228 k = str_to_c(key)
229 ethumb_client_file_set(self.obj, p, k)
230
231 def file_get(self):
232 cdef char *p, *k
233 ethumb_client_file_get(self.obj, &p, &k)
234 return (str_from_c(p), str_from_c(k))
235
236 property file:
237 def __set__(self, value):
238 p, k = value
239 self.file_set(p, k)
240
241 def __get__(self):
242 return self.file_get()
243
244 def file_free(self):
245 ethumb_client_file_free(self.obj)
246
247 # thumbnail
248 def thumb_set(self, path, key=None):
249 cdef char *p, *k
250 p = str_to_c(path)
251 k = str_to_c(key)
252 ethumb_client_thumb_path_set(self.obj, p, k)
253
254 def thumb_get(self):
255 cdef char *p, *k
256 ethumb_client_thumb_path_get(self.obj, &p, &k)
257 return (str_from_c(p), str_from_c(k))
258
259 property thumb_path:
260 def __set__(self, value):
261 p, k = value
262 self.thumb_set(p, k)
263 def __get__(self):
264 return self.thumb_get()
265
266 # video_time
267 def video_time_set(self, float time):
268 ethumb_client_video_time_set(self.obj, time)
269
270 def video_start_set(self, float start):
271 ethumb_client_video_start_set(self.obj, start)
272
273 def video_interval_set(self, float interval):
274 ethumb_client_video_interval_set(self.obj, interval)
275
276 def video_ntimes_set(self, int ntimes):
277 ethumb_client_video_ntimes_set(self.obj, ntimes)
278
279 def video_fps_set(self, int fps):
280 ethumb_client_video_fps_set(self.obj, fps)
281
282 # document_page
283 def document_page_set(self, int page):
284 ethumb_client_document_page_set(self.obj, page)
285
286 # thumbnail generation
287 def exists(self):
288 return ethumb_client_thumb_exists(self.obj)
289
290 def generate(self, func, *args, **kargs):
291 targs = (self, func, args, kargs)
292 python.Py_INCREF(targs)
293 r = ethumb_client_generate(self.obj, _generated_cb, <void*>targs,
294 _generated_cb_free_data)
295 return r
296
297 def cancel(self, int id):
298 ethumb_client_queue_remove(self.obj, id, NULL, NULL)
299
300 def clear(self):
301 ethumb_client_queue_clear(self.obj)
302
303 def __dealloc__(self):
304 ethumb_client_disconnect(self.obj)
305
306init()
diff --git a/ez_setup.py b/ez_setup.py
new file mode 100644
index 0000000..2f5a226
--- /dev/null
+++ b/ez_setup.py
@@ -0,0 +1,272 @@
1#!python
2"""Bootstrap setuptools installation
3
4If you want to use setuptools in your package's setup.py, just include this
5file in the same directory with it, and add this to the top of your setup.py::
6
7 from ez_setup import use_setuptools
8 use_setuptools()
9
10If you want to require a specific version of setuptools, set a download
11mirror, or use an alternate download directory, you can do so by supplying
12the appropriate options to ``use_setuptools()``.
13
14This file can also be run as a script to install or upgrade setuptools.
15"""
16import sys
17DEFAULT_VERSION = "0.6c9"
18DEFAULT_URL = "http://pypi.python.org/packages/%s/s/setuptools/" % sys.version[:3]
19
20md5_data = {
21 'setuptools-0.6b1-py2.3.egg': '8822caf901250d848b996b7f25c6e6ca',
22 'setuptools-0.6b1-py2.4.egg': 'b79a8a403e4502fbb85ee3f1941735cb',
23 'setuptools-0.6b2-py2.3.egg': '5657759d8a6d8fc44070a9d07272d99b',
24 'setuptools-0.6b2-py2.4.egg': '4996a8d169d2be661fa32a6e52e4f82a',
25 'setuptools-0.6b3-py2.3.egg': 'bb31c0fc7399a63579975cad9f5a0618',
26 'setuptools-0.6b3-py2.4.egg': '38a8c6b3d6ecd22247f179f7da669fac',
27 'setuptools-0.6b4-py2.3.egg': '62045a24ed4e1ebc77fe039aa4e6f7e5',
28 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4',
29 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c',
30 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b',
31 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27',
32 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277',
33 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa',
34 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e',
35 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e',
36 'setuptools-0.6c4-py2.3.egg': 'b0b9131acab32022bfac7f44c5d7971f',
37 'setuptools-0.6c4-py2.4.egg': '2a1f9656d4fbf3c97bf946c0a124e6e2',
38 'setuptools-0.6c4-py2.5.egg': '8f5a052e32cdb9c72bcf4b5526f28afc',
39 'setuptools-0.6c5-py2.3.egg': 'ee9fd80965da04f2f3e6b3576e9d8167',
40 'setuptools-0.6c5-py2.4.egg': 'afe2adf1c01701ee841761f5bcd8aa64',
41 'setuptools-0.6c5-py2.5.egg': 'a8d3f61494ccaa8714dfed37bccd3d5d',
42 'setuptools-0.6c6-py2.3.egg': '35686b78116a668847237b69d549ec20',
43 'setuptools-0.6c6-py2.4.egg': '3c56af57be3225019260a644430065ab',
44 'setuptools-0.6c6-py2.5.egg': 'b2f8a7520709a5b34f80946de5f02f53',
45 'setuptools-0.6c7-py2.3.egg': '209fdf9adc3a615e5115b725658e13e2',
46 'setuptools-0.6c7-py2.4.egg': '5a8f954807d46a0fb67cf1f26c55a82e',
47 'setuptools-0.6c7-py2.5.egg': '45d2ad28f9750e7434111fde831e8372',
48 'setuptools-0.6c8-py2.3.egg': '50759d29b349db8cfd807ba8303f1902',
49 'setuptools-0.6c8-py2.4.egg': 'cba38d74f7d483c06e9daa6070cce6de',
50 'setuptools-0.6c8-py2.5.egg': '1721747ee329dc150590a58b3e1ac95b',
51}
52
53import sys, os
54try: from hashlib import md5
55except ImportError: from md5 import md5
56
57def _validate_md5(egg_name, data):
58 if egg_name in md5_data:
59 digest = md5(data).hexdigest()
60 if digest != md5_data[egg_name]:
61 print >>sys.stderr, (
62 "md5 validation of %s failed! (Possible download problem?)"
63 % egg_name
64 )
65 sys.exit(2)
66 return data
67
68def use_setuptools(
69 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
70 download_delay=15
71):
72 """Automatically find/download setuptools and make it available on sys.path
73
74 `version` should be a valid setuptools version number that is available
75 as an egg for download under the `download_base` URL (which should end with
76 a '/'). `to_dir` is the directory where setuptools will be downloaded, if
77 it is not already available. If `download_delay` is specified, it should
78 be the number of seconds that will be paused before initiating a download,
79 should one be required. If an older version of setuptools is installed,
80 this routine will print a message to ``sys.stderr`` and raise SystemExit in
81 an attempt to abort the calling script.
82 """
83 was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules
84 def do_download():
85 egg = download_setuptools(version, download_base, to_dir, download_delay)
86 sys.path.insert(0, egg)
87 import setuptools; setuptools.bootstrap_install_from = egg
88 try:
89 import pkg_resources
90 except ImportError:
91 return do_download()
92 try:
93 pkg_resources.require("setuptools>="+version); return
94 except pkg_resources.VersionConflict, e:
95 if was_imported:
96 print >>sys.stderr, (
97 "The required version of setuptools (>=%s) is not available, and\n"
98 "can't be installed while this script is running. Please install\n"
99 " a more recent version first, using 'easy_install -U setuptools'."
100 "\n\n(Currently using %r)"
101 ) % (version, e.args[0])
102 sys.exit(2)
103 else:
104 del pkg_resources, sys.modules['pkg_resources'] # reload ok
105 return do_download()
106 except pkg_resources.DistributionNotFound:
107 return do_download()
108
109def download_setuptools(
110 version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
111 delay = 15
112):
113 """Download setuptools from a specified location and return its filename
114
115 `version` should be a valid setuptools version number that is available
116 as an egg for download under the `download_base` URL (which should end
117 with a '/'). `to_dir` is the directory where the egg will be downloaded.
118 `delay` is the number of seconds to pause before an actual download attempt.
119 """
120 import urllib2, shutil
121 egg_name = "setuptools-%s-py%s.egg" % (version,sys.version[:3])
122 url = download_base + egg_name
123 saveto = os.path.join(to_dir, egg_name)
124 src = dst = None
125 if not os.path.exists(saveto): # Avoid repeated downloads
126 try:
127 from distutils import log
128 if delay:
129 log.warn("""
130---------------------------------------------------------------------------
131This script requires setuptools version %s to run (even to display
132help). I will attempt to download it for you (from
133%s), but
134you may need to enable firewall access for this script first.
135I will start the download in %d seconds.
136
137(Note: if this machine does not have network access, please obtain the file
138
139 %s
140
141and place it in this directory before rerunning this script.)
142---------------------------------------------------------------------------""",
143 version, download_base, delay, url
144 ); from time import sleep; sleep(delay)
145 log.warn("Downloading %s", url)
146 src = urllib2.urlopen(url)
147 # Read/write all in one block, so we don't create a corrupt file
148 # if the download is interrupted.
149 data = _validate_md5(egg_name, src.read())
150 dst = open(saveto,"wb"); dst.write(data)
151 finally:
152 if src: src.close()
153 if dst: dst.close()
154 return os.path.realpath(saveto)
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191def main(argv, version=DEFAULT_VERSION):
192 """Install or upgrade setuptools and EasyInstall"""
193 try:
194 import setuptools
195 except ImportError:
196 egg = None
197 try:
198 egg = download_setuptools(version, delay=0)
199 sys.path.insert(0,egg)
200 from setuptools.command.easy_install import main
201 return main(list(argv)+[egg]) # we're done here
202 finally:
203 if egg and os.path.exists(egg):
204 os.unlink(egg)
205 else:
206 if setuptools.__version__ == '0.0.1':
207 print >>sys.stderr, (
208 "You have an obsolete version of setuptools installed. Please\n"
209 "remove it from your system entirely before rerunning this script."
210 )
211 sys.exit(2)
212
213 req = "setuptools>="+version
214 import pkg_resources
215 try:
216 pkg_resources.require(req)
217 except pkg_resources.VersionConflict:
218 try:
219 from setuptools.command.easy_install import main
220 except ImportError:
221 from easy_install import main
222 main(list(argv)+[download_setuptools(delay=0)])
223 sys.exit(0) # try to force an exit
224 else:
225 if argv:
226 from setuptools.command.easy_install import main
227 main(argv)
228 else:
229 print "Setuptools version",version,"or greater has been installed."
230 print '(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)'
231
232def update_md5(filenames):
233 """Update our built-in md5 registry"""
234
235 import re
236
237 for name in filenames:
238 base = os.path.basename(name)
239 f = open(name,'rb')
240 md5_data[base] = md5(f.read()).hexdigest()
241 f.close()
242
243 data = [" %r: %r,\n" % it for it in md5_data.items()]
244 data.sort()
245 repl = "".join(data)
246
247 import inspect
248 srcfile = inspect.getsourcefile(sys.modules[__name__])
249 f = open(srcfile, 'rb'); src = f.read(); f.close()
250
251 match = re.search("\nmd5_data = {\n([^}]+)}", src)
252 if not match:
253 print >>sys.stderr, "Internal error!"
254 sys.exit(2)
255
256 src = src[:match.start(1)] + repl + src[match.end(1):]
257 f = open(srcfile,'w')
258 f.write(src)
259 f.close()
260
261
262if __name__=='__main__':
263 if len(sys.argv)>2 and sys.argv[1]=='--md5update':
264 update_md5(sys.argv[2:])
265 else:
266 main(sys.argv[1:])
267
268
269
270
271
272
diff --git a/include/ethumb/__init__.py b/include/ethumb/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/include/ethumb/__init__.py
diff --git a/include/ethumb/c_ethumb.pxd b/include/ethumb/c_ethumb.pxd
new file mode 100644
index 0000000..6ae6883
--- /dev/null
+++ b/include/ethumb/c_ethumb.pxd
@@ -0,0 +1,29 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18cdef extern from "Ethumb.h":
19 cdef struct _Ethumb:
20 int tw
21 int th
22 int format
23 int aspect
24
25 int ethumb_init()
26 void ethumb_shutdown()
27
28cdef class Ethumb:
29 cdef _Ethumb *obj
diff --git a/include/ethumb/client.pxd b/include/ethumb/client.pxd
new file mode 100644
index 0000000..d102f20
--- /dev/null
+++ b/include/ethumb/client.pxd
@@ -0,0 +1,70 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18cdef extern from "Eina.h":
19 ctypedef int Eina_Bool
20
21cdef extern from "Ethumb_Client.h":
22 ctypedef struct Ethumb_Client
23 ctypedef void (*connect_callback_t)(Ethumb_Client *client, Eina_Bool success, void *data)
24 ctypedef void (*generated_callback_t)(int id, char *file, char *key, char *thumb_path, char *thumb_key, Eina_Bool success, void *data)
25
26 int ethumb_client_init()
27 ethumb_client_shutdown()
28
29 Ethumb_Client *ethumb_client_connect(connect_callback_t cb, void *data, void (*free_data)(void *))
30 void ethumb_client_disconnect(Ethumb_Client *client)
31
32 void ethumb_client_fdo_set(Ethumb_Client *client, int s)
33
34 void ethumb_client_size_set(Ethumb_Client *client, int tw, int th)
35 void ethumb_client_size_get(Ethumb_Client *client, int *tw, int *th)
36 void ethumb_client_format_set(Ethumb_Client *client, int f)
37 int ethumb_client_format_get(Ethumb_Client *client)
38 void ethumb_client_aspect_set(Ethumb_Client *client, int a)
39 int ethumb_client_aspect_get(Ethumb_Client *client)
40 void ethumb_client_crop_align_set(Ethumb_Client *client, float x, float y)
41 void ethumb_client_crop_align_get(Ethumb_Client *client, float *x, float *y)
42 void ethumb_client_quality_set(Ethumb_Client *client, int quality)
43 int ethumb_client_quality_get(Ethumb_Client *client)
44 void ethumb_client_compress_set(Ethumb_Client *client, int compress)
45 int ethumb_client_compress_get(Ethumb_Client *client)
46 Eina_Bool ethumb_client_frame_set(Ethumb_Client *client, char *file, char *group, char *swallow)
47 void ethumb_client_dir_path_set(Ethumb_Client *client, char *path)
48 char * ethumb_client_dir_path_get(Ethumb_Client *client)
49 void ethumb_client_category_set(Ethumb_Client *client, char *category)
50 char * ethumb_client_category_get(Ethumb_Client *client)
51 void ethumb_client_video_time_set(Ethumb_Client *client, float time)
52 void ethumb_client_video_start_set(Ethumb_Client *client, float start)
53 void ethumb_client_video_interval_set(Ethumb_Client *client, float interval)
54 void ethumb_client_video_ntimes_set(Ethumb_Client *client, int ntimes)
55 void ethumb_client_video_fps_set(Ethumb_Client *client, int fps)
56 void ethumb_client_document_page_set(Ethumb_Client *client, int page)
57
58 Eina_Bool ethumb_client_file_set(Ethumb_Client *client, char *path, char *key)
59 void ethumb_client_file_get(Ethumb_Client *client, char **path, char **key)
60 void ethumb_client_file_free(Ethumb_Client *client)
61
62 void ethumb_client_thumb_path_set(Ethumb_Client *client, char *path, char *key)
63 void ethumb_client_thumb_path_get(Ethumb_Client *client, char **path, char **key)
64 Eina_Bool ethumb_client_thumb_exists(Ethumb_Client *client)
65 int ethumb_client_generate(Ethumb_Client *client, generated_callback_t generated_cb, void *data, void (*free_data)(void *))
66 void ethumb_client_queue_remove(Ethumb_Client *client, int id, void (*queue_remove_cb)(Eina_Bool success, void *data), void *data)
67 void ethumb_client_queue_clear(Ethumb_Client *client)
68
69cdef class Client:
70 cdef Ethumb_Client *obj
diff --git a/include/ethumb/python.pxd b/include/ethumb/python.pxd
new file mode 100644
index 0000000..93a73ed
--- /dev/null
+++ b/include/ethumb/python.pxd
@@ -0,0 +1,20 @@
1# Copyright (C) 2009 by ProFUSION embedded systems
2#
3# This file is part of Python-Ethumb.
4#
5# Python-Ethumb is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ethumb is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ethumb. If not, see <http://www.gnu.org/licenses/>.
17
18cdef extern from "Python.h":
19 void Py_INCREF(object)
20 void Py_DECREF(object)
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..743a119
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,128 @@
1import sys
2import os
3
4if not os.path.exists("ethumb/ethumb.c_ethumb.c"):
5 try:
6 import Cython
7 except ImportError:
8 raise SystemExit("You need Cython -- http://cython.org/")
9 try:
10 import Pyrex
11 except ImportError:
12 raise SystemExit(
13 "You need Pyrex -- "
14 "http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/")
15
16from ez_setup import use_setuptools
17use_setuptools('0.6c9')
18
19from setuptools import setup, find_packages, Extension
20import subprocess
21import shlex
22
23from Cython.Distutils import build_ext
24
25def getstatusoutput(cmdline):
26 cmd = shlex.split(cmdline)
27 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
28 out, err = p.communicate()
29 return p.returncode, out
30
31
32def pkgconfig(*packages, **kw):
33 flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries',
34 '-D': 'prepro_vars'}
35 pkgs = ' '.join(packages)
36 cmdline = 'pkg-config --libs --cflags %s' % pkgs
37
38 status, output = getstatusoutput(cmdline)
39 if status != 0:
40 raise ValueError("could not find pkg-config module: %s" % pkgs)
41
42 for token in output.split():
43 flag = flag_map.get(token[:2], None)
44 if flag is not None:
45 kw.setdefault(flag, []).append(token[2:])
46 elif token.startswith("-Wl,"):
47 kw.setdefault("extra_link_args", []).append(token)
48 else:
49 kw.setdefault("extra_compile_args", []).append(token)
50
51 if "extra_link_args" in kw:
52 print "Using extra_link_args: %s" % " ".join(kw["extra_link_args"])
53 if "extra_compile_args" in kw:
54 print "Using extra_compile_args: %s" % " ".join(kw["extra_compile_args"])
55
56 return kw
57
58
59ethumbmodule = Extension('ethumb.c_ethumb',
60 sources=['ethumb/ethumb.c_ethumb.pyx',
61 ],
62 depends=['include/ethumb/c_ethumb.pxd',
63 'include/ethumb/python.pxd',
64 ],
65 **pkgconfig('"ethumb >= 0.1"'))
66
67ethumbclientmodule = Extension('ethumb.client',
68 sources=['ethumb/ethumb.client.pyx',
69 ],
70 depends=['include/ethumb/c_ethumb.pxd',
71 'include/ethumb/client.pxd',
72 'include/ethumb/python.pxd',
73 ],
74 **pkgconfig('"ethumb >= 0.1" "ethumb_client >= 0.1"'))
75
76
77trove_classifiers = [
78 "Development Status :: 3 - Alpha",
79 "Environment :: Console :: Framebuffer",
80 "Environment :: X11 Applications",
81 "Intended Audience :: Developers",
82 "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
83 "Operating System :: MacOS :: MacOS X",
84 "Operating System :: POSIX",
85 "Programming Language :: C",
86 "Programming Language :: Python",
87 "Topic :: Software Development :: Libraries :: Python Modules",
88 "Topic :: Software Development :: User Interfaces",
89 ]
90
91
92long_description = """\
93Python bindings for Ethumb, part of Enlightenment Foundation Libraries.
94
95Ethumb is a small, display independent, and quick thumbnailing library.
96
97The lib itself conforms to the standard put forth by freedesktop.org You
98can find out more information about it at
99http://triq.net/~jens/thumbnail-spec/index.html. It seemed better to
100break it out into a component that only depended on what was absolutely
101necessary.
102
103Ethumb uses Evas to create thumbnails.
104"""
105
106
107class ethumb_build_ext(build_ext):
108 def finalize_options(self):
109 build_ext.finalize_options(self)
110 self.include_dirs.insert(0, 'include')
111 self.pyrex_include_dirs.extend(self.include_dirs)
112
113
114setup(name='python-ethumb',
115 version='0.1',
116 license='LGPL',
117 author='Rafael Antognolli',
118 author_email='antognolli@profusion.mobi',
119 url='http://www.enlightenment.org/',
120 description='Python bindings for Ethumb',
121 long_description=long_description,
122 keywords='wrapper binding enlightenment graphics jpg jpeg png thumbnail freedesktop.org',
123 classifiers=trove_classifiers,
124 packages=find_packages(),
125 ext_modules=[ethumbmodule, ethumbclientmodule],
126 zip_safe=False,
127 cmdclass={'build_ext': ethumb_build_ext,},
128 )