This release focuses on thread-safety, reducing code boiler-plate, performance, increasing quality and test-coverage.
The C API intermediate interface has been rewritten from scratch. It introduces a concept of a bridge that isolates code execution from several threads into so called “C-thread” that takes care of correct synchronization and ensures thread-safety. Imaging operations are still performed in parallel thanks to OMP inside ImageMagick. Actually this approach yields even better performance as OMP may have strange interactions with threads resulting in excessive context switching.
pystacia.image.Image and pystacia.color.Color inherit now from common base pystacia.common.Resource that encapsulate all the details of tracing instances, allocating, freeing memory at right time and preventing memory leaks.
Underlying C function prototypes and ImageMagick itself are loaded lazily on-demand resulting in faster startup times when importing modules. Also cross-module dependencies have been greatly reduced.
From now on function calls that accept enumerations and color specifications can handle many formats without explicit casting. This approach reduces dependencies in your code and will be used in the documentation. Old way is still supported and in fact it gets auto-cast to it underneath.
>>> img1.overlay(img2, composite=composites.dst_over) # old way
>>> img1.overlay(img2, composite='dst_over') # new preferred way
>>> img1.get_pixel(0, 0) == from_rgb(1, 0, 0) # old way
>>> img1.get_pixel(0, 0) == (1, 0, 0) # new way
>>> img1.get_pixel(0, 0) == 'red' # even simpler
>>> img1.get_pixel(0, 0) == 0xFF0000 # or like that
TODO: Link it More information can be found in Enum handling and Working with color chapters.
The registry is a concept introducing control over global Pystacia behavior. E.g. you can use it to set class used instead of pystacia.image.Image when instantiating image objects:
>>> class MyImage(Image):
>>> def cool_stuff(self): pass
>>>
>>> from pystacia import registry
>>> registry.image_factory = MyImage
>>>
>>> blank(30, 30).__class__ == MyImage
True
TODO link: More on registry can be read in Controlling global behavior
New image operations include but are not necessarily limited to:
TODO: Bundled ImageMagick has been updated to version 6.3.7.X and built with
Color module gained support for pystacia.color.from_hsl(), pystacia.color.from_int24() and pystacia.color.from_rgb8() together with accompanying getters pystacia.color.Color.get_hsl(), pystacia.color.Color.get_rgb8(), pystacia.color.Color.get_int24().
Several symbols have been deprecated:
There is easy way to detect if you are using one of those symbols. To get all warning information sent to stdout just run your script with -W all switch.