Python – clone() function in wand library

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.

Syntax :

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

Code :

Let’s write a code to clone an image and then change the format of the cloned image.





# import Image from wand.image module
from wand.image import Image
# read original file using Image() function
with Image(filename ='koala.jpg') as original:
    # creating clone image of original image
    with original.clone() as copy:
        # convert format of cloned image
        converted.format = 'png'


Output :

A copy image will be saved with png extension/format
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.