SlideShare a Scribd company logo
1 of 27
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
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

More Related Content

What's hot

Grid based method & model based clustering method
Grid based method & model based clustering methodGrid based method & model based clustering method
Grid based method & model based clustering methodrajshreemuthiah
 
Overview Of Video Object Tracking System
Overview Of Video Object Tracking SystemOverview Of Video Object Tracking System
Overview Of Video Object Tracking SystemEditor IJMTER
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Decision tree induction \ Decision Tree Algorithm with Example| Data science
Decision tree induction \ Decision Tree Algorithm with Example| Data scienceDecision tree induction \ Decision Tree Algorithm with Example| Data science
Decision tree induction \ Decision Tree Algorithm with Example| Data scienceMaryamRehman6
 
Suspicious Activity Detection
Suspicious Activity DetectionSuspicious Activity Detection
Suspicious Activity DetectionMushahid Ali
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides Sheamus McGovern
 
Deep learning frameworks v0.40
Deep learning frameworks v0.40Deep learning frameworks v0.40
Deep learning frameworks v0.40Jessica Willis
 
3.2 partitioning methods
3.2 partitioning methods3.2 partitioning methods
3.2 partitioning methodsKrish_ver2
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...vikas dhakane
 
Object tracking a survey
Object tracking a surveyObject tracking a survey
Object tracking a surveyHaseeb Hassan
 
Comparative study on image segmentation techniques
Comparative study on image segmentation techniquesComparative study on image segmentation techniques
Comparative study on image segmentation techniquesgmidhubala
 
Real Time Object Tracking
Real Time Object TrackingReal Time Object Tracking
Real Time Object TrackingVanya Valindria
 
Applications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldApplications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldAshwani Srivastava
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Project Student
 

What's hot (20)

Grid based method & model based clustering method
Grid based method & model based clustering methodGrid based method & model based clustering method
Grid based method & model based clustering method
 
Overview Of Video Object Tracking System
Overview Of Video Object Tracking SystemOverview Of Video Object Tracking System
Overview Of Video Object Tracking System
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Decision tree induction \ Decision Tree Algorithm with Example| Data science
Decision tree induction \ Decision Tree Algorithm with Example| Data scienceDecision tree induction \ Decision Tree Algorithm with Example| Data science
Decision tree induction \ Decision Tree Algorithm with Example| Data science
 
Suspicious Activity Detection
Suspicious Activity DetectionSuspicious Activity Detection
Suspicious Activity Detection
 
Deep Learning Frameworks slides
Deep Learning Frameworks slides Deep Learning Frameworks slides
Deep Learning Frameworks slides
 
Deep learning frameworks v0.40
Deep learning frameworks v0.40Deep learning frameworks v0.40
Deep learning frameworks v0.40
 
3.2 partitioning methods
3.2 partitioning methods3.2 partitioning methods
3.2 partitioning methods
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
I.INFORMED SEARCH IN ARTIFICIAL INTELLIGENCE II. HEURISTIC FUNCTION IN AI III...
 
Chaptr 7 (final)
Chaptr 7 (final)Chaptr 7 (final)
Chaptr 7 (final)
 
Object tracking a survey
Object tracking a surveyObject tracking a survey
Object tracking a survey
 
Comparative study on image segmentation techniques
Comparative study on image segmentation techniquesComparative study on image segmentation techniques
Comparative study on image segmentation techniques
 
Application of image processing
Application of image processingApplication of image processing
Application of image processing
 
Real Time Object Tracking
Real Time Object TrackingReal Time Object Tracking
Real Time Object Tracking
 
Applications of Digital image processing in Medical Field
Applications of Digital image processing in Medical FieldApplications of Digital image processing in Medical Field
Applications of Digital image processing in Medical Field
 
Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)Data Compression (Lossy and Lossless)
Data Compression (Lossy and Lossless)
 
Data Mining: Association Rules Basics
Data Mining: Association Rules BasicsData Mining: Association Rules Basics
Data Mining: Association Rules Basics
 
Digital Watermarking
Digital WatermarkingDigital Watermarking
Digital Watermarking
 

Similar to Python media library

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
 
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 CgiAkramWaseem
 
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.pdfShaiAlmog1
 
Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgroundsnobel mujuji
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricksShem Magnezi
 
Image Handling in iOS_InnovationM
Image Handling in iOS_InnovationMImage Handling in iOS_InnovationM
Image Handling in iOS_InnovationMInnovationM
 
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 SiddiquiMuhammad 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 WebcamIntellovations, LLC
 
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 196Mahmoud Samir Fayed
 
Android UI Tips & Tricks
Android UI Tips & TricksAndroid UI Tips & Tricks
Android UI Tips & TricksDroidConTLV
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processingAsad Ali
 
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editorIMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editorRAHUL DANGWAL
 

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]
 
Topic 1_PPT.pptx
Topic 1_PPT.pptxTopic 1_PPT.pptx
Topic 1_PPT.pptx
 
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
 
Resize image vb.net
Resize image vb.netResize image vb.net
Resize image vb.net
 
What is image in Swift?/はるふ
What is image in Swift?/はるふWhat is image in Swift?/はるふ
What is image in Swift?/はるふ
 
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
 
Html images and html backgrounds
Html images and html backgroundsHtml images and html backgrounds
Html images and html backgrounds
 
Android ui tips & tricks
Android ui tips & tricksAndroid ui tips & tricks
Android ui tips & tricks
 
Chapter1 8
Chapter1 8Chapter1 8
Chapter1 8
 
Image Handling in iOS_InnovationM
Image Handling in iOS_InnovationMImage Handling in iOS_InnovationM
Image Handling in iOS_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
 
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
 
Editing session 1
Editing session 1Editing session 1
Editing session 1
 
Chtp430
Chtp430Chtp430
Chtp430
 
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
 
Android UI Tips & Tricks
Android UI Tips & TricksAndroid UI Tips & Tricks
Android UI Tips & Tricks
 
Vanmathy python
Vanmathy python Vanmathy python
Vanmathy python
 
Mathematical operations in image processing
Mathematical operations in image processingMathematical operations in image processing
Mathematical operations in image processing
 
M14 overview
M14 overviewM14 overview
M14 overview
 
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editorIMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
IMAGE ENHANCEMENT /ENHANCHING the feature of an image/ Image editor
 

More from RaginiJain21

Jump statment in python
Jump statment in pythonJump statment in python
Jump statment in pythonRaginiJain21
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in pythonRaginiJain21
 
Conditionalstatement
ConditionalstatementConditionalstatement
ConditionalstatementRaginiJain21
 
Basic python programs
Basic python programsBasic python programs
Basic python programsRaginiJain21
 
Python Libraries and Modules
Python Libraries and ModulesPython Libraries and Modules
Python Libraries and ModulesRaginiJain21
 
Data types in python
Data types in pythonData types in python
Data types in pythonRaginiJain21
 
Final presentation on python
Final presentation on pythonFinal presentation on python
Final presentation on pythonRaginiJain21
 

More from RaginiJain21 (8)

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

Recently uploaded

OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptx
OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptxOAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptx
OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptxhiddenlevers
 
Instant Issue Debit Cards - School Designs
Instant Issue Debit Cards - School DesignsInstant Issue Debit Cards - School Designs
Instant Issue Debit Cards - School Designsegoetzinger
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...Suhani Kapoor
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignHenry Tapper
 
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawl
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service AizawlVip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawl
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawlmakika9823
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfAdnet Communications
 
How Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingHow Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingAggregage
 
20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdfAdnet Communications
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办fqiuho152
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Roomdivyansh0kumar0
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managmentfactical
 
Andheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot ModelsAndheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot Modelshematsharma006
 
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...yordanosyohannes2
 
Stock Market Brief Deck for 4/24/24 .pdf
Stock Market Brief Deck for 4/24/24 .pdfStock Market Brief Deck for 4/24/24 .pdf
Stock Market Brief Deck for 4/24/24 .pdfMichael Silva
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHenry Tapper
 

Recently uploaded (20)

OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptx
OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptxOAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptx
OAT_RI_Ep19 WeighingTheRisks_Apr24_TheYellowMetal.pptx
 
Instant Issue Debit Cards - School Designs
Instant Issue Debit Cards - School DesignsInstant Issue Debit Cards - School Designs
Instant Issue Debit Cards - School Designs
 
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsHigh Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
High Class Call Girls Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service NashikHigh Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
High Class Call Girls Nashik Maya 7001305949 Independent Escort Service Nashik
 
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
VIP Call Girls LB Nagar ( Hyderabad ) Phone 8250192130 | ₹5k To 25k With Room...
 
Log your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaignLog your LOA pain with Pension Lab's brilliant campaign
Log your LOA pain with Pension Lab's brilliant campaign
 
Commercial Bank Economic Capsule - April 2024
Commercial Bank Economic Capsule - April 2024Commercial Bank Economic Capsule - April 2024
Commercial Bank Economic Capsule - April 2024
 
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawl
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service AizawlVip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawl
Vip B Aizawl Call Girls #9907093804 Contact Number Escorts Service Aizawl
 
Lundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdfLundin Gold April 2024 Corporate Presentation v4.pdf
Lundin Gold April 2024 Corporate Presentation v4.pdf
 
How Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of ReportingHow Automation is Driving Efficiency Through the Last Mile of Reporting
How Automation is Driving Efficiency Through the Last Mile of Reporting
 
20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf20240417-Calibre-April-2024-Investor-Presentation.pdf
20240417-Calibre-April-2024-Investor-Presentation.pdf
 
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
(办理原版一样)QUT毕业证昆士兰科技大学毕业证学位证留信学历认证成绩单补办
 
Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024Monthly Economic Monitoring of Ukraine No 231, April 2024
Monthly Economic Monitoring of Ukraine No 231, April 2024
 
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130  Available With RoomVIP Kolkata Call Girl Serampore 👉 8250192130  Available With Room
VIP Kolkata Call Girl Serampore 👉 8250192130 Available With Room
 
SBP-Market-Operations and market managment
SBP-Market-Operations and market managmentSBP-Market-Operations and market managment
SBP-Market-Operations and market managment
 
Andheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot ModelsAndheri Call Girls In 9825968104 Mumbai Hot Models
Andheri Call Girls In 9825968104 Mumbai Hot Models
 
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...
AfRESFullPaper22018EmpiricalPerformanceofRealEstateInvestmentTrustsandShareho...
 
Stock Market Brief Deck for 4/24/24 .pdf
Stock Market Brief Deck for 4/24/24 .pdfStock Market Brief Deck for 4/24/24 .pdf
Stock Market Brief Deck for 4/24/24 .pdf
 
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Maya Call 7001035870 Meet With Nagpur Escorts
 
House of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview documentHouse of Commons ; CDC schemes overview document
House of Commons ; CDC schemes overview document
 

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
  • 12.
  • 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