Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Python – clone() function in wand library

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

or

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
Last Updated : 08 May, 2020
Like Article
Save Article
Similar Reads
Related Tutorials