Module: Asposeimagingjava::CropMetafile

Defined in:
lib/asposeimagingjava/metafiles/cropmetafile.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/asposeimagingjava/metafiles/cropmetafile.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'

    # Load an existing image in an instance of Image class

    image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "sample.emf")

    # Create an instance of Rectangle class with desired size

    rectangle = Rjb::import('com.aspose.imaging.Rectangle').new(10, 10, 100, 100)

    # Perform the crop operation on object of Rectangle class

    image.crop(rectangle)

    # Save the result in PNG format

    image.save(data_dir + "CropMetafile.png")

    # Display Status.

    puts "Saved crop emf image to PNG successfully!"
end