Book Image

Python Multimedia

By : Ninad Sathaye
Book Image

Python Multimedia

By: Ninad Sathaye

Overview of this book

Multimedia applications are used by a range of industries to enhance the visual appeal of a product. This book will teach the reader how to perform multimedia processing using Python. This step-by-step guide gives you hands-on experience for developing exciting multimedia applications using Python. This book will help you to build applications for processing images, creating 2D animations and processing audio and video. Writing applications that work with images, videos, and other sensory effects is great. Not every application gets to make full use of audio/visual effects, but a certain amount of multimedia makes any application a lot more appealing. There are numerous multimedia libraries for which Python bindings are available. These libraries enable working with different kinds of media, such as images, audio, video, games, and so on. This book introduces the reader to the most widely used open source libraries through several exciting, real world projects. Popular multimedia frameworks and libraries such as GStreamer,Pyglet, QT Phonon, and Python Imaging library are used to develop various multimedia applications.
Table of Contents (13 chapters)
Python Multimedia Beginner's Guide
Credits
About the Author
About the Reviewers
Preface

Time for action – enclosing a picture in a photoframe


Let's develop code that adds a frame around a picture.

  1. Download the image 0165_3_15_COLOR_TWEAK.png and rename it to FLOWER.png.

  2. Add the following code in a Python source file. Make sure to modify the code to specify in the input and output paths appropriately.

    1 import Image, ImageOps
    2 img = Image.open( "C:\\images\\FLOWER.png ")
    3 img = ImageOps.expand(img, border=20, fill='black')
    4 img = ImageOps.expand(img, border=40, fill='silver')
    5 img = ImageOps.expand(img, border=2, fill='black')
    6 img.save( "C:\\images\\PHOTOFRAME.png ")
    7 img.show()
  3. In this code snippet, three stacked borders are created. The innermost border layer is rendered with black color. This is intentionally chosen darker.

  4. Next, there is a middle layer of border, rendered with a lighter color (silver color in this case). This is done by the code on line 4. It is thicker than the innermost border.

  5. The outermost border is created by code on line 5. It is a very thin layer...