From 749e5561f79c64b51f338cc867853f4f510bf57c 2016-12-03 15:17:02 From: Branko Majic Date: 2016-12-03 15:17:02 Subject: [PATCH] PYD-7: Updated usage instructions to mention multiple output formats. --- diff --git a/docs/usage.rst b/docs/usage.rst index 92333920bdfa56d5c7022e0de7877f029a24a549..b4fa37416403c76264a319ada487702c5add26ae 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -85,6 +85,12 @@ Finally, the resulting identicons can be in different formats:: identicon_ascii = generator.generate("john.doe@example.com", 200, 200, output_format="ascii") +Supported output formats are dependant on the local Pillow installation. For +exact list of available formats, have a look at `Pillow documentation +`_. The ``ascii`` format is the only format +explicitly handled by the *Pydenticon* library itself (mainly useful for +debugging purposes). + Using the generated identicons ------------------------------ @@ -93,9 +99,11 @@ either to be stored somewhere on disk, or maybe streamed back to the user via HTTP response. Since the generate function returns raw data, this is quite easy to achieve:: - # Generate same identicon in two different formats. + # Generate same identicon in three different formats. identicon_png = generator.generate("john.doe@example.com", 200, 200, output_format="png") + identicon_gif = generator.generate("john.doe@example.com", 200, 200, + output_format="gif") identicon_ascii = generator.generate("john.doe@example.com", 200, 200, output_format="ascii") @@ -104,6 +112,10 @@ to achieve:: f.write(identicon_png) f.close() + f = open("sample.gif", "wb") + f.write(identicon_gif) + f.close() + # ASCII identicon can be printed-out to console directly. print identicon_ascii @@ -114,6 +126,10 @@ Working with transparency .. note:: New in version ``0.3``. +.. warning:: + The only output format that properly supports transparency at the moment is + ``PNG``. If you are using anything else, transparency will not work. + If you ever find yourself in need of having a transparent background or foreground, you can easily do this using the syntax ``rgba(224,224,224,0)``. All this does is effectively adding alpha channel to