clone() function makes an exact copy of the original image. One can use this clone image to manipulate without affecting the original image. clone() is one of the most important function because it helps in safe manipulation of image.
For example, If you get an image and you mess up with the original file, this may leads to a huge loss to a person. But this problem can be avoided using clone() function. Before performing manipulation in image one can create an exact copy of image and manipulate the copy of original file.
original = Image(filename='filename.format') copy = original.clone() // other manipulation code
with Image(filename='filename.format') as original: with original.clone() as copy: // other image manipulation code
Let’s write a code to clone an image and then change the format of the cloned image.
A copy image will be saved with png extension/format
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.