10 killer Python automation scripts
<p>Repeating tasks are always time-consuming and boring. Imagine cutting 100 photos one by one or doing tasks such as Fetching APIs, correcting spelling and grammar, etc., all of which take a lot of time. Why not automate them? In today’s article, I will share with you 10 Python automation scripts.</p>
<p>So, please keep this article in your bookmark for future reference. In the IT industry, programmers never stop learning…</p>
<p>Now, let’s get started.</p>
<p>01、 Image Optimizer</p>
<p>This great automation script can help you process images better and you can edit them just like in Photoshop.</p>
<p>The script uses the popular Pillow module.</p>
<pre>
# Image Optimizing
# pip install Pillow
import PIL
# Croping
im = PIL.Image.open("Image1.jpg")
im = im.crop((34, 23, 100, 100))
# Resizing
im = PIL.Image.open("Image1.jpg")
im = im.resize((50, 50))
# Flipping
im = PIL.Image.open("Image1.jpg")
im = im.transpose(PIL.Image.FLIP_LEFT_RIGHT)
# Rotating
im = PIL.Image.open("Image1.jpg")
im = im.rotate(360)
# Compressing
im = PIL.Image.open("Image1.jpg")
im.save("Image1.jpg", optimize=True, quality=90)
# Bluring
im = PIL.Image.open("Image1.jpg")
im = im.filter(PIL.ImageFilter.BLUR)
# Sharpening
im = PIL.Image.open("Image1.jpg")
im = im.filter(PIL.ImageFilter.SHARPEN)
# Set Brightness
im = PIL.Image.open("Image1.jpg")
im = PIL.ImageEnhance.Brightness(im)
im = im.enhance(1.5)
# Set Contrast
im = PIL.Image.open("Image1.jpg")
im = PIL.ImageEnhance.Contrast(im)
im = im.enhance(1.5)
# Adding Filters
im = PIL.Image.open("Image1.jpg")
im = PIL.ImageOps.grayscale(im)
im = PIL.ImageOps.invert(im)
im = PIL.ImageOps.posterize(im, 4)
# Saving
im.save("Image1.jpg")</pre>
<p>02、 Video Optimizer</p>
<p>With the following automation script, you can not only use Python to optimize videos, but also use it to optimize images. The script uses the Moviepy module, which allows you to trim, add audio, set video speed, add VFX, etc.</p>
<p><a href="https://medium.com/@Evenword/10-killer-python-automation-scripts-141b591254c5">Read More</a></p>