SlideShare a Scribd company logo
Python Media
Library
Python is a very powerful language that can accomplish many
tasks such as image manipulation(The process of editing an
image is called image manipulation). Processing a video
means, performing operations on the video frame by frame.
Frames are nothing but just the particular instance of the
video in a single point of time.
Pillow is built on top of PIL (Python Image Library).
PIL is one of the important modules for image
processing in Python. Pillow supports a large number
of image file formats including BMP, PNG, JPEG, and
TIFF. It incorporates lightweight image processing
tools that aids in editing, creating and saving images.
Python Imaging Library
This method is used to display the image. For displaying
the image Pillow first converts the image to a .png format
(on Windows OS) and stores it in a temporary buffer and
then displays it.
from PIL import Image
img =
Image.open(r“pic1.png")
#Open image
img.show()
#Display image
To resize an image, you call
the resize() method on it,
passing in a two-integer tuple
argument representing the
width and height of the resized
image.
from PIL import Image
size = (40, 40)
img =
Image.open(r“pic1.png")
img1 = img.resize(size)
img1.show()
Example
Image rotation is done
by specific angles and
for that again specific
keywords need to
passed. You can rotate
image 90 degree, 45
degree, 180 degree etc.
Rotating Images
Example
from PIL import Image
# Open image using
Image module
n= Image.open(“girl.jpg”)
# Show actual image
n.show()
#show rotated image
n =n.rotate(45)
n.show()
Rotated image
It applies a blurring effect on to the image as
specified through a specific kernel or a
convolution matrix.
Syntax
filter(ImageFilter.BLUR)
Blurred Image
#Import required Image library from PIL
import Image, ImageFilter
OriImage = Image.open('girl.jpg')
OriImage.show()
blurImage =
OriImage.filter(ImageFilter.BLUR)
blurImage.show() #Save blurImage
blurImage.save(‘girl.jpg')
Example
Python media library
While using the save() method
Destination path must have
the image filename and
extension as well. The
extension could be omitted in
Destination path if the
extension is specified in the
format argument.
from PIL import Image
size = (40, 40)
img = Image.open(r“pic1.png")
r_img = img.resize(size, resample = Image.BILINEAR)
# resized_test.png => Destination_path
r_img.save("resized_pic1.png")
# Opening the new image
img = Image.open(r"resized_pic1.png“)
print(img.size)
Show Image
Resize Image
Rotate Image
Blured Image
Pillow Library allow you to perform difference task such
show image, resize image, rotate image, blurred image
etc.
OpenCV VideoCapture
OpenCV provides the VideoCature() function
which is used to work with the Camera. We
can do the following task:
Read video, display video, and save video.
Capture from the camera and display it.
The cv2.imwrite() function is used to save the video
into the file. First, we need to create a VideoWriter
object. Then we should specify the FourCC code and
the number of frames per second (fps). The frame
size should be passed within the function.
Saving a Video
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read() # Capture image frame-by-frame
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',gray) # Display the resulting frame
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
Example
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
frame = cv2.flip(frame,0)
# write the flipped frame
out.write(frame)
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
Saving a Video
MoviePy
MoviePy is a Python module for video
editing, which can be used for basic
operations (like cuts, concatenations,
title insertions), video compositing
(a.k.a. non-linear editing), video
processing, or to create advanced
effects. It can read and write the most
common video formats, including GIF.
We will load the video and we will cut a clip
from the whole video then we will add text in
the video, in this example we have to install
ImageMagick otherwise it will not work.
Example
from moviepy.editor import *
clip = VideoFileClip("dsa_v.webm“)
# loading video dsa gfg intro video
# getting video for only starting 10 seconds
clip = clip.subclip(0, 10)
clip = clip.volumex(0.8) # Reduce the audio volume (volume x 0.8)
# Generate a text clip
txt_clip = TextClip(“RaginiTutorial", fontsize = 50, color = 'white‘)
txt_clip = txt_clip.set_pos('center').set_duration(10)
# Overlay the text clip on the first video clip
video = CompositeVideoClip([clip, txt_clip])# showing video
video.ipython_display(width = 280)
Python offers multiple libraries to ease
our work. Here we will learn how to
take a screenshot using Python.
Python provides a module
called pyscreenshot for this task. It is
only a pure Python wrapper, a thin
layer over existing backends.
Performance and interactivity are not
important for this library.
import pyscreenshot
# To capture the screen
image = pyscreenshot.grab()
#To display the captured
screenshot
image.show()
# To save the screenshot
image.save(“schreenshot2.png")
Example
Here is the simple Python
program to capture the part of
the screen. Here we need to
provide the pixel positions in
the grab() function. We need
to pass the coordinates in the
form of a tuple.
import pyscreenshot
image=pyscreenshot.grab(bbox=(10,10,500, 500))
image.show() # To view the screenshot
image.save(“screenshot1.png“)
Example
For more presentation in
any subject please contact
us
raginijain0208@gmail.com
Python media library
Ad

More Related Content

What's hot (20)

Object oriented programming in python
Object oriented programming in pythonObject oriented programming in python
Object oriented programming in python
baabtra.com - No. 1 supplier of quality freshers
 
Data warehouse,data mining & Big Data
Data warehouse,data mining & Big DataData warehouse,data mining & Big Data
Data warehouse,data mining & Big Data
Ravinder Kamboj
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learning
leopauly
 
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Simplilearn
 
Convolutional Neural Network and Its Applications
Convolutional Neural Network and Its ApplicationsConvolutional Neural Network and Its Applications
Convolutional Neural Network and Its Applications
Kasun Chinthaka Piyarathna
 
Data Mining: Association Rules Basics
Data Mining: Association Rules BasicsData Mining: Association Rules Basics
Data Mining: Association Rules Basics
Benazir Income Support Program (BISP)
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
Porimol Chandro
 
Basic Introduction To Graphic File Formats
Basic Introduction To Graphic File FormatsBasic Introduction To Graphic File Formats
Basic Introduction To Graphic File Formats
Ankit Mishra
 
Deep Learning for Computer Vision: Data Augmentation (UPC 2016)
Deep Learning for Computer Vision: Data Augmentation (UPC 2016)Deep Learning for Computer Vision: Data Augmentation (UPC 2016)
Deep Learning for Computer Vision: Data Augmentation (UPC 2016)
Universitat Politècnica de Catalunya
 
Understanding Random Forests: From Theory to Practice
Understanding Random Forests: From Theory to PracticeUnderstanding Random Forests: From Theory to Practice
Understanding Random Forests: From Theory to Practice
Gilles Louppe
 
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
Mohammed Anzil
 
Association rule mining and Apriori algorithm
Association rule mining and Apriori algorithmAssociation rule mining and Apriori algorithm
Association rule mining and Apriori algorithm
hina firdaus
 
Association Rule Learning Part 1: Frequent Itemset Generation
Association Rule Learning Part 1: Frequent Itemset GenerationAssociation Rule Learning Part 1: Frequent Itemset Generation
Association Rule Learning Part 1: Frequent Itemset Generation
Knoldus Inc.
 
Multimedia technology
Multimedia technologyMultimedia technology
Multimedia technology
Vishnu Ram
 
Introduction to text classification using naive bayes
Introduction to text classification using naive bayesIntroduction to text classification using naive bayes
Introduction to text classification using naive bayes
Dhwaj Raj
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural Networks
Christian Perone
 
Audio and Video Compression
Audio and Video CompressionAudio and Video Compression
Audio and Video Compression
Er. Ashish Pandey
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
Sungjoon Choi
 
Naive Bayes
Naive BayesNaive Bayes
Naive Bayes
CloudxLab
 
Multimedia networking
Multimedia networkingMultimedia networking
Multimedia networking
Kikima Jimmy
 
Data warehouse,data mining & Big Data
Data warehouse,data mining & Big DataData warehouse,data mining & Big Data
Data warehouse,data mining & Big Data
Ravinder Kamboj
 
Introduction to Deep learning
Introduction to Deep learningIntroduction to Deep learning
Introduction to Deep learning
leopauly
 
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Convolutional Neural Network - CNN | How CNN Works | Deep Learning Course | S...
Simplilearn
 
Convolutional Neural Network and Its Applications
Convolutional Neural Network and Its ApplicationsConvolutional Neural Network and Its Applications
Convolutional Neural Network and Its Applications
Kasun Chinthaka Piyarathna
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
Porimol Chandro
 
Basic Introduction To Graphic File Formats
Basic Introduction To Graphic File FormatsBasic Introduction To Graphic File Formats
Basic Introduction To Graphic File Formats
Ankit Mishra
 
Understanding Random Forests: From Theory to Practice
Understanding Random Forests: From Theory to PracticeUnderstanding Random Forests: From Theory to Practice
Understanding Random Forests: From Theory to Practice
Gilles Louppe
 
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
DATA VISUALIZATION USING MATPLOTLIB (PYTHON)
Mohammed Anzil
 
Association rule mining and Apriori algorithm
Association rule mining and Apriori algorithmAssociation rule mining and Apriori algorithm
Association rule mining and Apriori algorithm
hina firdaus
 
Association Rule Learning Part 1: Frequent Itemset Generation
Association Rule Learning Part 1: Frequent Itemset GenerationAssociation Rule Learning Part 1: Frequent Itemset Generation
Association Rule Learning Part 1: Frequent Itemset Generation
Knoldus Inc.
 
Multimedia technology
Multimedia technologyMultimedia technology
Multimedia technology
Vishnu Ram
 
Introduction to text classification using naive bayes
Introduction to text classification using naive bayesIntroduction to text classification using naive bayes
Introduction to text classification using naive bayes
Dhwaj Raj
 
Deep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural NetworksDeep Learning - Convolutional Neural Networks
Deep Learning - Convolutional Neural Networks
Christian Perone
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
Sungjoon Choi
 
Multimedia networking
Multimedia networkingMultimedia networking
Multimedia networking
Kikima Jimmy
 

Similar to Python media library (20)

Python imaging-library-overview - [cuuduongthancong.com]
Python imaging-library-overview - [cuuduongthancong.com]Python imaging-library-overview - [cuuduongthancong.com]
Python imaging-library-overview - [cuuduongthancong.com]
Dinh Sinh Mai
 
Unit 6 Image processing Libraries.[pptx]
Unit 6  Image processing Libraries.[pptx]Unit 6  Image processing Libraries.[pptx]
Unit 6 Image processing Libraries.[pptx]
AmrutaSakhare1
 
Topic 1_PPT.pptx
Topic 1_PPT.pptxTopic 1_PPT.pptx
Topic 1_PPT.pptx
BharatiPatelPhDStude
 
Random And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python CgiRandom And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python Cgi
AkramWaseem
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
Hotland Sitorus
 
What is image in Swift?/はるふ
What is image in Swift?/はるふWhat is image in Swift?/はるふ
What is image in Swift?/はるふ
ha1f Yamaguchi
 
Performance and Memory Tuning - Part III - Transcript.pdf
Performance and Memory Tuning - Part III - Transcript.pdfPerformance and Memory Tuning - Part III - Transcript.pdf
Performance and Memory Tuning - Part III - Transcript.pdf
ShaiAlmog1
 
Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgrounds
nobel mujuji
 
05. Graphic Engineering with Visual C#.pptx
05. Graphic Engineering with Visual C#.pptx05. Graphic Engineering with Visual C#.pptx
05. Graphic Engineering with Visual C#.pptx
PoEnyaRaTna
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricks
Shem Magnezi
 
Chapter1 8
Chapter1 8Chapter1 8
Chapter1 8
oussamayakoubi
 
Image Handling in iOS_InnovationM
Image Handling in iOS_InnovationMImage Handling in iOS_InnovationM
Image Handling in iOS_InnovationM
InnovationM
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Observational Science With Python and a Webcam
Observational Science With Python and a WebcamObservational Science With Python and a Webcam
Observational Science With Python and a Webcam
Intellovations, LLC
 
Introduction to Machine Learning by MARK
Introduction to Machine Learning by MARKIntroduction to Machine Learning by MARK
Introduction to Machine Learning by MARK
MRKUsafzai0607
 
Editing session 1
Editing session 1Editing session 1
Editing session 1
mollyallen19
 
Chtp430
Chtp430Chtp430
Chtp430
giovanniveitch
 
The Ring programming language version 1.7 book - Part 51 of 196
The Ring programming language version 1.7 book - Part 51 of 196The Ring programming language version 1.7 book - Part 51 of 196
The Ring programming language version 1.7 book - Part 51 of 196
Mahmoud Samir Fayed
 
Android UI Tips & Tricks
Android UI Tips & TricksAndroid UI Tips & Tricks
Android UI Tips & Tricks
DroidConTLV
 
Vanmathy python
Vanmathy python Vanmathy python
Vanmathy python
PriyadharshiniVS
 
Python imaging-library-overview - [cuuduongthancong.com]
Python imaging-library-overview - [cuuduongthancong.com]Python imaging-library-overview - [cuuduongthancong.com]
Python imaging-library-overview - [cuuduongthancong.com]
Dinh Sinh Mai
 
Unit 6 Image processing Libraries.[pptx]
Unit 6  Image processing Libraries.[pptx]Unit 6  Image processing Libraries.[pptx]
Unit 6 Image processing Libraries.[pptx]
AmrutaSakhare1
 
Random And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python CgiRandom And Dynamic Images Using Python Cgi
Random And Dynamic Images Using Python Cgi
AkramWaseem
 
What is image in Swift?/はるふ
What is image in Swift?/はるふWhat is image in Swift?/はるふ
What is image in Swift?/はるふ
ha1f Yamaguchi
 
Performance and Memory Tuning - Part III - Transcript.pdf
Performance and Memory Tuning - Part III - Transcript.pdfPerformance and Memory Tuning - Part III - Transcript.pdf
Performance and Memory Tuning - Part III - Transcript.pdf
ShaiAlmog1
 
Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgrounds
nobel mujuji
 
05. Graphic Engineering with Visual C#.pptx
05. Graphic Engineering with Visual C#.pptx05. Graphic Engineering with Visual C#.pptx
05. Graphic Engineering with Visual C#.pptx
PoEnyaRaTna
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricks
Shem Magnezi
 
Image Handling in iOS_InnovationM
Image Handling in iOS_InnovationMImage Handling in iOS_InnovationM
Image Handling in iOS_InnovationM
InnovationM
 
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation  Websites Session 7 by Muhammad Ehtisham SiddiquiBuilding Next Generation  Websites Session 7 by Muhammad Ehtisham Siddiqui
Building Next Generation Websites Session 7 by Muhammad Ehtisham Siddiqui
Muhammad Ehtisham Siddiqui
 
Observational Science With Python and a Webcam
Observational Science With Python and a WebcamObservational Science With Python and a Webcam
Observational Science With Python and a Webcam
Intellovations, LLC
 
Introduction to Machine Learning by MARK
Introduction to Machine Learning by MARKIntroduction to Machine Learning by MARK
Introduction to Machine Learning by MARK
MRKUsafzai0607
 
The Ring programming language version 1.7 book - Part 51 of 196
The Ring programming language version 1.7 book - Part 51 of 196The Ring programming language version 1.7 book - Part 51 of 196
The Ring programming language version 1.7 book - Part 51 of 196
Mahmoud Samir Fayed
 
Android UI Tips & Tricks
Android UI Tips & TricksAndroid UI Tips & Tricks
Android UI Tips & Tricks
DroidConTLV
 
Ad

More from RaginiJain21 (8)

Jump statment in python
Jump statment in pythonJump statment in python
Jump statment in python
RaginiJain21
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
RaginiJain21
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
RaginiJain21
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Python second ppt
Python second pptPython second ppt
Python second ppt
RaginiJain21
 
Final presentation on python
Final presentation on pythonFinal presentation on python
Final presentation on python
RaginiJain21
 
Jump statment in python
Jump statment in pythonJump statment in python
Jump statment in python
RaginiJain21
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
RaginiJain21
 
Conditionalstatement
ConditionalstatementConditionalstatement
Conditionalstatement
RaginiJain21
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
RaginiJain21
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and Modules
RaginiJain21
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Final presentation on python
Final presentation on pythonFinal presentation on python
Final presentation on python
RaginiJain21
 
Ad

Recently uploaded (20)

OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptxOAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
hiddenlevers
 
The Economy of United States, GDP, AND Development
The Economy of United States, GDP, AND DevelopmentThe Economy of United States, GDP, AND Development
The Economy of United States, GDP, AND Development
bebibamlaku
 
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdfJoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
FinTech Belgium
 
VSLA Methodology Training 2024 - Copy.ppt
VSLA Methodology Training 2024 - Copy.pptVSLA Methodology Training 2024 - Copy.ppt
VSLA Methodology Training 2024 - Copy.ppt
wodajodagim
 
stereochemistryuyguhihihihihuiihiuuhiuhiuhi
stereochemistryuyguhihihihihuiihiuuhiuhiuhistereochemistryuyguhihihihihuiihiuuhiuhiuhi
stereochemistryuyguhihihihihuiihiuuhiuhiuhi
4mg22ec401
 
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdfEconomic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Group-1 Manufacturing Growth and Structural Transformation.pptx
Group-1 Manufacturing Growth and Structural Transformation.pptxGroup-1 Manufacturing Growth and Structural Transformation.pptx
Group-1 Manufacturing Growth and Structural Transformation.pptx
nowrinmorshed207
 
Lundin Gold Corporate Presentation - May 2025
Lundin Gold Corporate Presentation -  May 2025Lundin Gold Corporate Presentation -  May 2025
Lundin Gold Corporate Presentation - May 2025
Adnet Communications
 
GCF - Master Presentation - UK - 0525.pdf
GCF - Master Presentation - UK - 0525.pdfGCF - Master Presentation - UK - 0525.pdf
GCF - Master Presentation - UK - 0525.pdf
hkmd5mqzjb
 
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Philip Caputo Toms River
 
Gender neutral hiring of young scholars: an experiment
Gender neutral hiring of young scholars: an experimentGender neutral hiring of young scholars: an experiment
Gender neutral hiring of young scholars: an experiment
GRAPE
 
2025 0507 Macro Trends and their impact on Enterprise AI.pptx
2025 0507 Macro Trends and their impact on Enterprise AI.pptx2025 0507 Macro Trends and their impact on Enterprise AI.pptx
2025 0507 Macro Trends and their impact on Enterprise AI.pptx
Sunil Grover
 
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
Adnet Communications
 
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdfTrumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Henry Tapper
 
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdfCLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
hkmd5mqzjb
 
An indepth study of behavioral finances.
An indepth study of behavioral finances.An indepth study of behavioral finances.
An indepth study of behavioral finances.
Khushboo Dange
 
GCF - Master Presentation - UK GCF - 0525 .pdf
GCF - Master Presentation - UK GCF - 0525 .pdfGCF - Master Presentation - UK GCF - 0525 .pdf
GCF - Master Presentation - UK GCF - 0525 .pdf
hkmd5mqzjb
 
Format Meeting Bulanan Minimalist Aesthetic
Format Meeting Bulanan Minimalist AestheticFormat Meeting Bulanan Minimalist Aesthetic
Format Meeting Bulanan Minimalist Aesthetic
frenkywhijaya
 
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
gxcypx
 
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docxTelegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Henry Tapper
 
OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptxOAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
OAT_RI_Ep31 WeighingTheRisks_Apr25_Financials.pptx
hiddenlevers
 
The Economy of United States, GDP, AND Development
The Economy of United States, GDP, AND DevelopmentThe Economy of United States, GDP, AND Development
The Economy of United States, GDP, AND Development
bebibamlaku
 
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdfJoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
JoinM2020_FTBEmembers.pptx.SIDEEVENTTpdf
FinTech Belgium
 
VSLA Methodology Training 2024 - Copy.ppt
VSLA Methodology Training 2024 - Copy.pptVSLA Methodology Training 2024 - Copy.ppt
VSLA Methodology Training 2024 - Copy.ppt
wodajodagim
 
stereochemistryuyguhihihihihuiihiuuhiuhiuhi
stereochemistryuyguhihihihihuiihiuuhiuhiuhistereochemistryuyguhihihihihuiihiuuhiuhiuhi
stereochemistryuyguhihihihihuiihiuuhiuhiuhi
4mg22ec401
 
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdfEconomic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
Economic_Planning_and_Development_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Group-1 Manufacturing Growth and Structural Transformation.pptx
Group-1 Manufacturing Growth and Structural Transformation.pptxGroup-1 Manufacturing Growth and Structural Transformation.pptx
Group-1 Manufacturing Growth and Structural Transformation.pptx
nowrinmorshed207
 
Lundin Gold Corporate Presentation - May 2025
Lundin Gold Corporate Presentation -  May 2025Lundin Gold Corporate Presentation -  May 2025
Lundin Gold Corporate Presentation - May 2025
Adnet Communications
 
GCF - Master Presentation - UK - 0525.pdf
GCF - Master Presentation - UK - 0525.pdfGCF - Master Presentation - UK - 0525.pdf
GCF - Master Presentation - UK - 0525.pdf
hkmd5mqzjb
 
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Commerce on the Rise_ Toms River’s Economic Revival by Philip Caputo Toms Riv...
Philip Caputo Toms River
 
Gender neutral hiring of young scholars: an experiment
Gender neutral hiring of young scholars: an experimentGender neutral hiring of young scholars: an experiment
Gender neutral hiring of young scholars: an experiment
GRAPE
 
2025 0507 Macro Trends and their impact on Enterprise AI.pptx
2025 0507 Macro Trends and their impact on Enterprise AI.pptx2025 0507 Macro Trends and their impact on Enterprise AI.pptx
2025 0507 Macro Trends and their impact on Enterprise AI.pptx
Sunil Grover
 
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
2025-05-08 - Torex Gold - Corporate Presentation - May 2025.pdf
Adnet Communications
 
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdfTrumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Trumps-Tariffs-and-UK-Pensions-7.5.25.pdf
Henry Tapper
 
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdfCLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
CLUB DEAL - UK - GEREJECORPORATEFINANCE.pdf
hkmd5mqzjb
 
An indepth study of behavioral finances.
An indepth study of behavioral finances.An indepth study of behavioral finances.
An indepth study of behavioral finances.
Khushboo Dange
 
GCF - Master Presentation - UK GCF - 0525 .pdf
GCF - Master Presentation - UK GCF - 0525 .pdfGCF - Master Presentation - UK GCF - 0525 .pdf
GCF - Master Presentation - UK GCF - 0525 .pdf
hkmd5mqzjb
 
Format Meeting Bulanan Minimalist Aesthetic
Format Meeting Bulanan Minimalist AestheticFormat Meeting Bulanan Minimalist Aesthetic
Format Meeting Bulanan Minimalist Aesthetic
frenkywhijaya
 
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
Mastering Crypto Security: How GXCYPX Solutions Help Prevent Social Engineeri...
gxcypx
 
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docxTelegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Telegraph - 'Rachel Reeves paves way for Dutch-style pensions' May 2025.docx
Henry Tapper
 

Python media library

  • 2. Python is a very powerful language that can accomplish many tasks such as image manipulation(The process of editing an image is called image manipulation). Processing a video means, performing operations on the video frame by frame. Frames are nothing but just the particular instance of the video in a single point of time.
  • 3. Pillow is built on top of PIL (Python Image Library). PIL is one of the important modules for image processing in Python. Pillow supports a large number of image file formats including BMP, PNG, JPEG, and TIFF. It incorporates lightweight image processing tools that aids in editing, creating and saving images. Python Imaging Library
  • 4. This method is used to display the image. For displaying the image Pillow first converts the image to a .png format (on Windows OS) and stores it in a temporary buffer and then displays it.
  • 5. from PIL import Image img = Image.open(r“pic1.png") #Open image img.show() #Display image
  • 6. To resize an image, you call the resize() method on it, passing in a two-integer tuple argument representing the width and height of the resized image.
  • 7. from PIL import Image size = (40, 40) img = Image.open(r“pic1.png") img1 = img.resize(size) img1.show() Example
  • 8. Image rotation is done by specific angles and for that again specific keywords need to passed. You can rotate image 90 degree, 45 degree, 180 degree etc. Rotating Images Example from PIL import Image # Open image using Image module n= Image.open(“girl.jpg”) # Show actual image n.show() #show rotated image n =n.rotate(45) n.show()
  • 10. It applies a blurring effect on to the image as specified through a specific kernel or a convolution matrix. Syntax filter(ImageFilter.BLUR) Blurred Image
  • 11. #Import required Image library from PIL import Image, ImageFilter OriImage = Image.open('girl.jpg') OriImage.show() blurImage = OriImage.filter(ImageFilter.BLUR) blurImage.show() #Save blurImage blurImage.save(‘girl.jpg') Example
  • 13. While using the save() method Destination path must have the image filename and extension as well. The extension could be omitted in Destination path if the extension is specified in the format argument.
  • 14. from PIL import Image size = (40, 40) img = Image.open(r“pic1.png") r_img = img.resize(size, resample = Image.BILINEAR) # resized_test.png => Destination_path r_img.save("resized_pic1.png") # Opening the new image img = Image.open(r"resized_pic1.png“) print(img.size)
  • 15. Show Image Resize Image Rotate Image Blured Image Pillow Library allow you to perform difference task such show image, resize image, rotate image, blurred image etc.
  • 16. OpenCV VideoCapture OpenCV provides the VideoCature() function which is used to work with the Camera. We can do the following task: Read video, display video, and save video. Capture from the camera and display it.
  • 17. The cv2.imwrite() function is used to save the video into the file. First, we need to create a VideoWriter object. Then we should specify the FourCC code and the number of frames per second (fps). The frame size should be passed within the function. Saving a Video
  • 18. import cv2 import numpy as np cap = cv2.VideoCapture(0) while(True): ret, frame = cap.read() # Capture image frame-by-frame # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) # Display the resulting frame if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything done, release the capture cap.release() cv2.destroyAllWindows() Example
  • 19. import numpy as np import cv2 cap = cv2.VideoCapture(0) fourcc = cv2.VideoWriter_fourcc(*'XVID') out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480)) while(cap.isOpened()): ret, frame = cap.read() if ret==True: frame = cv2.flip(frame,0) # write the flipped frame out.write(frame) cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break else: break cap.release() out.release() cv2.destroyAllWindows() Saving a Video
  • 20. MoviePy MoviePy is a Python module for video editing, which can be used for basic operations (like cuts, concatenations, title insertions), video compositing (a.k.a. non-linear editing), video processing, or to create advanced effects. It can read and write the most common video formats, including GIF.
  • 21. We will load the video and we will cut a clip from the whole video then we will add text in the video, in this example we have to install ImageMagick otherwise it will not work. Example
  • 22. from moviepy.editor import * clip = VideoFileClip("dsa_v.webm“) # loading video dsa gfg intro video # getting video for only starting 10 seconds clip = clip.subclip(0, 10) clip = clip.volumex(0.8) # Reduce the audio volume (volume x 0.8) # Generate a text clip txt_clip = TextClip(“RaginiTutorial", fontsize = 50, color = 'white‘) txt_clip = txt_clip.set_pos('center').set_duration(10) # Overlay the text clip on the first video clip video = CompositeVideoClip([clip, txt_clip])# showing video video.ipython_display(width = 280)
  • 23. Python offers multiple libraries to ease our work. Here we will learn how to take a screenshot using Python. Python provides a module called pyscreenshot for this task. It is only a pure Python wrapper, a thin layer over existing backends. Performance and interactivity are not important for this library.
  • 24. import pyscreenshot # To capture the screen image = pyscreenshot.grab() #To display the captured screenshot image.show() # To save the screenshot image.save(“schreenshot2.png") Example
  • 25. Here is the simple Python program to capture the part of the screen. Here we need to provide the pixel positions in the grab() function. We need to pass the coordinates in the form of a tuple. import pyscreenshot image=pyscreenshot.grab(bbox=(10,10,500, 500)) image.show() # To view the screenshot image.save(“screenshot1.png“) Example
  • 26. For more presentation in any subject please contact us raginijain0208@gmail.com
  翻译: