Download the file
Rotate.png
from the Packt website. Alternatively, you can use any supported image file of your choice.Write the following code in Python interpreter or in a Python file. As always, specify the appropriate path strings for
inPath
andoutPath
variables.1 import Image 2 inPath = "C:\\images\\Rotate.png" 3 img = Image.open(inPath) 4 deg = 45 5 filterOpt = Image.BICUBIC 6 outPath = "C:\\images\\Rotate_out.png" 7 foo = img.rotate(deg, filterOpt) 8 foo.save(outPath)
Upon running this code, the output image, rotated by 45 degrees, is saved to the
outPath
. The filter optionImage.BICUBIC
ensures highest quality. The next illustration shows the original and the images rotated by 45 and 180 degrees respectively—the original and rotated images.There is another way to accomplish rotation for certain angles by using the
Image.transpose
functionality. The following code achieves a 270-degree rotation. Other valid options for rotation areImage.ROTATE_90
andImage...
Python Multimedia
By :
Python Multimedia
By:
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
Free Chapter
Python and Multimedia
Working with Images
Enhancing Images
Fun with Animations
Working with Audios
Audio Controls and Effects
Working with Videos
GUI-based Media Players Using QT Phonon
Customer Reviews