Convert an Image From One Format To Another¶
Problem¶
You have an image, “Patches with ball.jpg”, stored as a jpeg, but wish to have it in exr format.
Solution¶
import Draft
img = Draft.Image.ReadFromFile( 'Patches with ball.jpg' )
img.WriteToFile( 'Patches with ball.exr' )
Discussion¶
Converting an image from one format to another is as simple as reading in the image and saving it in a new file with the appropriate file extension. Draft automatically converts the image based on the file extension specified. Draft supports the following image extensions: .jpg (or .jpeg), .png, .tif (or .tiff), .exr, .dpx, .gif, .bmp, .hdr, .tga.
See Also¶
For more information on the import statement, ReadFromFile(), and WriteToFile(), see the Creating an Image section of this Cookbook.
