Module: Asposeimagingjava::ResizeImage

Defined in:
lib/asposeimagingjava/images/resizeimage.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
# File 'lib/asposeimagingjava/images/resizeimage.rb', line 3

def initialize()
    # Simple Resizing

    simple_image_resizing()

    # Resizing with ResizeType Enumeration

    resizing_with_resizetype_enumeration()
end

#resizing_with_resizetype_enumerationObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/asposeimagingjava/images/resizeimage.rb', line 37

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

    # Load an existing image

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

    # Cache data if not cached previously

    if !image.isCached()
        image.cacheData()
    end

    # Specify only width

    new_width = image.getWidth() / 2
    image.resizeWidthProportionally(new_width, Rjb::import('com.aspose.imaging.ResizeType').LanczosResample)

    # Specify only height

    new_height = image.getHeight() / 2
    image.resizeHeightProportionally(new_height, Rjb::import('com.aspose.imaging.ResizeType').NearestNeighbourResample)

    # Save the image to disk

    image.save(data_dir + "resizing_with_resizetype_enumeration.jpg")

    # Display Status.

    puts "Resized image successfully!"
end

#simple_image_resizingObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/asposeimagingjava/images/resizeimage.rb', line 11

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

    # Load an existing image

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

    # Cache data if not cached previously

    if !image.isCached()
        image.cacheData()
    end

    # Specify only width

    new_width = image.getWidth() / 2
    image.resizeWidthProportionally(new_width)

    # Specify only height

    new_height = image.getHeight() / 2
    image.resizeHeightProportionally(new_height)

    # Save the image to disk

    image.save(data_dir + "simple_image_resizing.jpg")

    # Display Status.

    puts "Resized image successfully!"
end