Traversing a directory means get all files or subdirectories in it. To do it, we should know:How to check a file is file. How to check a file is directory. In this tutorial, we will write an example to show you how to traverse a directory in python.
In this tutorial, we will use python colorgram.py library to extract main colors and calculate their proportions from an image, this is very helpful for us to analysis images by their colors.
To convert images to pdf file, you may use python img2pdf library, however, you may find Error: Refusing to work on images with alpha channel. To fix this error, you have to use Wand and ImageMagick to remove alpha channel. In this tutorial, we will introduce a new way to convert images to pdf without processing alpha channel.
WebP format is a good choice for displaying images on website. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.
To convert pdf to images, we can use ImageMagick + Wand library or ImageMagick + PythonMagick library, you also can use poppler + pdf2image. However, this python library depends on other application. In this tutorial, we will use a pure python library PyMuPDF to convert pdf files to images.
In this tutorial, we will introduce a most simplest method to reverse python list, you can learn and do by our example code.
To reverse a python string is very simple, in this tutorial, we will introduce two simple methods to do it. You can learn and do by following our tutorial.
To compress an image in python, you can reduce its width and height or reduce its quality. In this tutorial, we will introduce how to compress images by reducing image quality wihout width and height reduce.
Python global variable is defined outside a function. It will work on the whole function if there is no the same named variable. In this tutorial, we will introduce how to use python global variable correctly.
Formatting a python string is basic operation in python, especailly when you want to print a string, we have two ways to format a string. In this tutorial, we will introduce this two methods to format a string.