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 – making composites with image mask


We will mix the same two images blended in another section. Just to try out something different, in the composite image, we will focus on the flying birds instead of the bridge.

  1. We will use the same set of input images as used in the Blending section.

    1 import Image
    2 
    3 img1 = Image.open( "C:\\images\\BRIDGE2.png ")
    4 img1 = img1.convert('RGBA')
    5
    6 img2 = Image.open( "C:\\images\\BIRDS2.png ")
    7 img2 = img2.convert('RGBA')
    8
    9 r, g, b, alpha = img2.split()
    10 alpha = alpha.point(lambda i: i>0 and 204)
    11
    12 img = Image.composite(img2, img1, alpha)
    13 img.show()
  2. The code until line 7 is identical to the one illustrated in the blending example. Note that the two input images need not have the same mode. On line 10, the Image.point method is called. The lambda function operates on the alpha band data. The code on lines 9 and 10 is similar to that illustrated in the section Creating Transparent Images. Please refer to that section for further...