Python wget.download() | Download Image from URL

Simplest way to download an image from it’s URL using Python wget module’s download method. Contents Syntax Examples Code#1 Code#2 Prerequisites:1. Install wget library Syntax: get.download(URL, Target Directory (optional)) Parameters: URL – Image URL Example: https://gethowstuff.com/wp-content/uploads/2020/03/python-crash-course-001.jpg Target Directory (optional) – Path where downloaded image will be saved. Otherwise, it will be saved to current working […]

Python PIL getpixel() method to get pixel value

Python PIL getpixel() method provides image data at pixel level. You can extract the pixel value by passing it’s (x,y) coordinates. getpixel() Syntax Syntax: getpixel(xy) Parameters: xy, pixel coordinates represented as a tuple (x,y) i.e.(row, column) Returns: a pixel value for single band images (grey-scale images), a tuple of pixel values for multi-layer images. For […]

Batch File – “Press Any Button To Continue” command

To implement “Press Any Key To Continue” in a batch file, add below commands in your batch file. It simply pauses the batch file execution until the user presses any keyboard button. Note: You can change the “Press Any Key To Continue” as per your requirement. It is just a message. pause > nul command […]

Resize Image keeping aspect ratio – Python PIL Image Module

Below Python code resizes an image keeping it’s aspect ratio using PIL library Image Module. The above code is tested on Windows 10 PC using PyCharm 2019.3.3 In the code, we have set the height of the image to 900 Percentage of height of the resized image calculation proportional width value calculation using below formula […]

Python Pillow (PIL) Tutorial [Installation and Examples]

Python Pillow Pillow is a Python Imaging Library (called as PIL), which supports opening, manipulating (filtering, enhancing, masking, watermarking, resizing etc) and saving of images. The latest version can identify and read more than 30 image formats. Write support is intentionally restricted to few image formats. Installing Python Pillow on Windows To install Python Pillow […]

Top Rated Python Books on Amazon 2020

1. Python Crash Course: A Hands-on, Project based Introduction To Programming This book is highly recommended by many verified purchasers on Amazon. They mentioned that it is a great book for beginners to learn Python. Below are some of their comments “Effective For Teaching The Basics” “From your first exception error to your first Hello […]

Python: Get last 4 characters of a string [one line code]

Python code to get last four characters of a string. This single line code, excluding string line, prints the last 4 characters of the string. Change the number to get more or less characters. Example string: GetHowStuff Expected Output (last 4 characters): tuff string=”GetHowStuff” #prints last 4 characters of the string print(string[-4:])