Figure 2: A sample Python session using a program built with SWIG
>>> # Have Python load the new Image module ... import Image >>> >>> # Create an ImageInfo structure, and load Ship.gif ... II = Image.ImageInfo(); >>> II.filename = "Ship.gif"; >>> Ship = Image.ReadImage ( II ); >>> >>> # Python representation of a pointer to Image* ... Ship.this '_1012cb08_Image_p' >>> >>> # Some attributes of the Ship ... Ship.rows 289 >>> Ship.columns 406 >>> Ship.depth; # Bits per pixel 8 >>> >>> # Emboss effect ... Embossed = Ship.Emboss(); >>> Embossed.filename = "Embossed.gif"; >>> Embossed.Write ( II ); 1 >>> >>> # Load an image of a frog, and swirl it ... II.filename = "Frog.gif"; >>> Frog = Image.ReadImage ( II ); >>> Swirl = Frog.Swirl ( 30.0 ); >>> Swirl.filename = "Swirl.gif"; >>> Swirl.Write ( II ); 1 >>> >>> # Distort an image of the earth ... II.filename = "Earth.gif" >>> Earth = Image.ReadImage ( II ); >>> >>> # Since each effect returns a new object, ... # I can string them together, and let ... # Python take care of memory management ... OuterSpace = Earth.Blur ( 100.0 ).Wave ( 5.0, 15.0 ); >>> OuterSpace.filename = "OuterSpace.gif"; >>> OuterSpace.Write ( II ); 1 >>>