asposeimagingjava 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/asposeimagingjava.gemspec +27 -0
- data/config/aspose.yml +5 -0
- data/data/aspose.bmp +0 -0
- data/data/bizcard.psd +0 -0
- data/data/demo.djvu +0 -0
- data/data/demo.tif +0 -0
- data/data/multipage.tiff +0 -0
- data/data/sample.djvu +0 -0
- data/data/sample.emf +0 -0
- data/data/sample.gif +0 -0
- data/data/sample.jpg +0 -0
- data/data/sample.png +0 -0
- data/data/sample.tiff +0 -0
- data/data/samples/sample.jpg +0 -0
- data/data/samples/test.jpg +0 -0
- data/data/test.jpg +0 -0
- data/data/test.tiff +0 -0
- data/lib/asposeimagingjava.rb +71 -0
- data/lib/asposeimagingjava/asposeimaging.rb +5 -0
- data/lib/asposeimagingjava/djvu.rb +5 -0
- data/lib/asposeimagingjava/djvu/convertingdjvutopdf.rb +29 -0
- data/lib/asposeimagingjava/djvu/convertingdjvutotiff.rb +23 -0
- data/lib/asposeimagingjava/djvu/convertingrangeofdjvupages.rb +26 -0
- data/lib/asposeimagingjava/djvu/convertingrangeofdjvupagestoseparateimages.rb +30 -0
- data/lib/asposeimagingjava/djvu/convertingspecificportionofdjvupage.rb +32 -0
- data/lib/asposeimagingjava/drawing.rb +6 -0
- data/lib/asposeimagingjava/drawing/drawingarc.rb +37 -0
- data/lib/asposeimagingjava/drawing/drawingellipse.rb +43 -0
- data/lib/asposeimagingjava/drawing/drawingimagesusingcorefunctionality.rb +33 -0
- data/lib/asposeimagingjava/drawing/drawingimagesusinggraphics.rb +34 -0
- data/lib/asposeimagingjava/drawing/drawinglines.rb +53 -0
- data/lib/asposeimagingjava/drawing/drawingrectangle.rb +44 -0
- data/lib/asposeimagingjava/images.rb +20 -0
- data/lib/asposeimagingjava/images/addimagesasseparateframesintiff.rb +57 -0
- data/lib/asposeimagingjava/images/addthumbnailtoexifsegment.rb +25 -0
- data/lib/asposeimagingjava/images/addthumbnailtojfifsegment.rb +25 -0
- data/lib/asposeimagingjava/images/addwatermarktoimage.rb +30 -0
- data/lib/asposeimagingjava/images/adjustingcolors.rb +80 -0
- data/lib/asposeimagingjava/images/autocorrectorientationofjpegimage.rb +19 -0
- data/lib/asposeimagingjava/images/compresspngimage.rb +22 -0
- data/lib/asposeimagingjava/images/concatenatemultipletiffimages.rb +24 -0
- data/lib/asposeimagingjava/images/convertingrasterimages.rb +80 -0
- data/lib/asposeimagingjava/images/createjpegthumbnail.rb +21 -0
- data/lib/asposeimagingjava/images/cropimages.rb +63 -0
- data/lib/asposeimagingjava/images/datarecoverytiffimages.rb +21 -0
- data/lib/asposeimagingjava/images/ditheringimage.rb +19 -0
- data/lib/asposeimagingjava/images/exportimagetodifferentformats.rb +24 -0
- data/lib/asposeimagingjava/images/extracttiffframestootherformat.rb +19 -0
- data/lib/asposeimagingjava/images/readandmodifyjpegexiftags.rb +91 -0
- data/lib/asposeimagingjava/images/resizeimage.rb +63 -0
- data/lib/asposeimagingjava/images/rotateandflipimage.rb +18 -0
- data/lib/asposeimagingjava/images/specifybitdepthforpngimage.rb +25 -0
- data/lib/asposeimagingjava/images/specifytransparencyforpngimage.rb +32 -0
- data/lib/asposeimagingjava/metafiles.rb +2 -0
- data/lib/asposeimagingjava/metafiles/convertmetafiletootherformats.rb +28 -0
- data/lib/asposeimagingjava/metafiles/cropmetafile.rb +22 -0
- data/lib/asposeimagingjava/photoshop/createpsd.rb +42 -0
- data/lib/asposeimagingjava/photoshop/exportimagetopsd.rb +26 -0
- data/lib/asposeimagingjava/psd.rb +2 -0
- data/lib/asposeimagingjava/version.rb +3 -0
- data/samples/djvu.rb +13 -0
- data/samples/drawing.rb +14 -0
- data/samples/images.rb +29 -0
- data/samples/metafiles.rb +10 -0
- data/samples/psd.rb +10 -0
- metadata +170 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ConcatenateMultipleTiffImages
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Create an instance of TiffImage and load the copied source image
|
7
|
+
source = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.tiff")
|
8
|
+
|
9
|
+
# Create an instance of TiffImage and load the source image
|
10
|
+
destination = Rjb::import('com.aspose.imaging.Image').load(data_dir + "demo.tif")
|
11
|
+
|
12
|
+
# Create an instance of TIffFrame and copy active frame of source image
|
13
|
+
frame = Rjb::import('com.aspose.imaging.fileformats.tiff.TiffFrame').copyFrame(source.getActiveFrame())
|
14
|
+
|
15
|
+
# Add copied frame to destination image
|
16
|
+
destination.addFrame(frame)
|
17
|
+
|
18
|
+
# save the changes
|
19
|
+
destination.save()
|
20
|
+
|
21
|
+
puts "Concatenated Multiple Tiff Images Successfully!"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ConvertingRasterImages
|
3
|
+
def initialize()
|
4
|
+
# Binarization with Fixed Threshold
|
5
|
+
binarization_with_fixed_threshold()
|
6
|
+
|
7
|
+
# Binarization with Otsu Threshold
|
8
|
+
binarization_with_otsu_threshold()
|
9
|
+
|
10
|
+
# Transform image to its grayscale representation
|
11
|
+
transform_image_to_grayscale()
|
12
|
+
end
|
13
|
+
|
14
|
+
def binarization_with_fixed_threshold()
|
15
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
16
|
+
|
17
|
+
# Load an existing image
|
18
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
19
|
+
|
20
|
+
# Check if image is cached
|
21
|
+
if !image.isCached()
|
22
|
+
# Cache image if not already cached
|
23
|
+
image.cacheData()
|
24
|
+
end
|
25
|
+
|
26
|
+
# Binarize image with predefined fixed threshold
|
27
|
+
image.binarizeFixed(100)
|
28
|
+
|
29
|
+
# Save the image to disk
|
30
|
+
image.save(data_dir + "binarization_with_fixed_threshold.jpg")
|
31
|
+
|
32
|
+
# Display Status.
|
33
|
+
puts "Binarization image with Fixed Threshold successfully!"
|
34
|
+
end
|
35
|
+
|
36
|
+
def binarization_with_otsu_threshold()
|
37
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
38
|
+
|
39
|
+
# Load an existing image
|
40
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
41
|
+
|
42
|
+
# Check if image is cached
|
43
|
+
if !image.isCached()
|
44
|
+
# Cache image if not already cached
|
45
|
+
image.cacheData()
|
46
|
+
end
|
47
|
+
|
48
|
+
# Binarize image with Otsu Thresholding
|
49
|
+
image.binarizeOtsu()
|
50
|
+
|
51
|
+
# Save the image to disk
|
52
|
+
image.save(data_dir + "binarization_with_otsu_threshold.jpg")
|
53
|
+
|
54
|
+
# Display Status.
|
55
|
+
puts "Binarization image with Otsu Threshold successfully!"
|
56
|
+
end
|
57
|
+
|
58
|
+
def transform_image_to_grayscale()
|
59
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
60
|
+
|
61
|
+
# Load an existing image
|
62
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
63
|
+
|
64
|
+
# Check if image is cached
|
65
|
+
if !image.isCached()
|
66
|
+
# Cache image if not already cached
|
67
|
+
image.cacheData()
|
68
|
+
end
|
69
|
+
|
70
|
+
# Transform image to its grayscale representation
|
71
|
+
image.grayscale()
|
72
|
+
|
73
|
+
# Save the image to disk
|
74
|
+
image.save(data_dir + "transform_image_to_grayscale.jpg")
|
75
|
+
|
76
|
+
# Display Status.
|
77
|
+
puts "Transform image to its grayscale representation successfully!"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module CreateJpegThumbnail
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Load an existing image (of type bmp) in an instance of Image class
|
7
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
8
|
+
|
9
|
+
if image.getExifData() != nil
|
10
|
+
# Get the image thumbnail information and save it in an instance of JpegImage
|
11
|
+
thumbnail = image.getExifData().get_Thumbnail()
|
12
|
+
|
13
|
+
# Save the thumbnail to disk with a new name
|
14
|
+
thumbnail.save(data_dir + "JpegThumbnail.jpeg")
|
15
|
+
|
16
|
+
# Display Status.
|
17
|
+
puts "Created thumbnail of JPEG image successfully!"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module CropImages
|
3
|
+
def initialize()
|
4
|
+
# Cropping by Shifts
|
5
|
+
crop_by_shifts()
|
6
|
+
|
7
|
+
# Cropping by Rectangle
|
8
|
+
crop_by_rectangle()
|
9
|
+
end
|
10
|
+
|
11
|
+
def crop_by_shifts()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Load an existing image (of type bmp) in an instance of Image class
|
15
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
16
|
+
|
17
|
+
# Before cropping, the image should be cached for better performance
|
18
|
+
if !image.isCached()
|
19
|
+
image.cacheData()
|
20
|
+
end
|
21
|
+
|
22
|
+
# Define shift values for all four sides
|
23
|
+
left_shift = 10
|
24
|
+
right_shift = 10
|
25
|
+
top_shift = 10
|
26
|
+
bottom_shift = 10
|
27
|
+
|
28
|
+
# Based on the shift values, apply the cropping on image
|
29
|
+
# Crop method will shift the image bounds toward the center of image
|
30
|
+
image.crop(left_shift, right_shift, top_shift, bottom_shift)
|
31
|
+
|
32
|
+
# Save the image to disk
|
33
|
+
image.save(data_dir + "CropByShifts.jpg")
|
34
|
+
|
35
|
+
# Display Status.
|
36
|
+
puts "Cropped image by shifts successfully!"
|
37
|
+
end
|
38
|
+
|
39
|
+
def crop_by_rectangle()
|
40
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
41
|
+
|
42
|
+
# Load an existing image (of type bmp) in an instance of Image class
|
43
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
44
|
+
|
45
|
+
# Before cropping, the image should be cached for better performance
|
46
|
+
if !image.isCached()
|
47
|
+
image.cacheData()
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create an instance of Rectangle class with desired size
|
51
|
+
rectangle = Rjb::import('com.aspose.imaging.Rectangle').new(10, 10, 100, 100)
|
52
|
+
|
53
|
+
# Perform the crop operation on object of Rectangle class
|
54
|
+
image.crop(rectangle)
|
55
|
+
|
56
|
+
# Save the image to disk
|
57
|
+
image.save(data_dir + "crop_by_rectangle.jpg")
|
58
|
+
|
59
|
+
# Display Status.
|
60
|
+
puts "Cropped image by rectangle successfully!"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module DataRecoveryForTiffImages
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Create an instance of LoadOptions
|
7
|
+
load_options = Rjb::import('com.aspose.imaging.LoadOptions').new
|
8
|
+
|
9
|
+
# Specify the DataRecoveryMode for the object of LoadOptions
|
10
|
+
load_options.setDataRecoveryMode(Rjb::import('com.aspose.imaging.DataRecoveryMode').ConsistentRecover)
|
11
|
+
|
12
|
+
# Specify the DataBackgroundColor for the object of LoadOptions
|
13
|
+
load_options.setDataBackgroundColor(Rjb::import('java.awt.Color').getRed())
|
14
|
+
|
15
|
+
# Load an existing image
|
16
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "multipage.tiff", load_options)
|
17
|
+
|
18
|
+
# do some work
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module DitheringImage
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Load an existing image
|
7
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
8
|
+
|
9
|
+
# Perform Floyd Steinberg dithering on the current image
|
10
|
+
image.dither(Rjb::import('com.aspose.imaging.DitheringMethod').ThresholdDithering, 4)
|
11
|
+
|
12
|
+
# Save the image to disk
|
13
|
+
image.save(data_dir + "DitheringImage.jpg")
|
14
|
+
|
15
|
+
# Display Status.
|
16
|
+
puts "Dithering image successfully!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ExportImageToDifferentFormats
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Load an existing image (of type Gif) in an instance of Image class
|
7
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "sample.gif")
|
8
|
+
|
9
|
+
# Export to BMP file format using the default options
|
10
|
+
image.save(data_dir + "output.bmp" , Rjb::import('com.aspose.imaging.imageoptions.BmpOptions').new)
|
11
|
+
|
12
|
+
# Export to JPEG file format using the default options
|
13
|
+
image.save(data_dir + "output.jpg", Rjb::import('com.aspose.imaging.imageoptions.JpegOptions').new)
|
14
|
+
|
15
|
+
# Export to PNG file format using the default options
|
16
|
+
image.save(data_dir + "output.png", Rjb::import('com.aspose.imaging.imageoptions.PngOptions').new)
|
17
|
+
|
18
|
+
# Export to TIFF file format using the default options
|
19
|
+
image.save(data_dir + "output.tiff", Rjb::import('com.aspose.imaging.imageoptions.TiffOptions').new(Rjb::import('com.aspose.imaging.fileformats.tiff.enums.TiffExpectedFormat').Default))
|
20
|
+
|
21
|
+
puts "Saved images."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ExtractTiffFramesToOtherFormat
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Load an existing image
|
7
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "multipage.tiff")
|
8
|
+
|
9
|
+
frames = image.getFrames()
|
10
|
+
i = 1
|
11
|
+
frames.each do |frame|
|
12
|
+
frame.save(data_dir + "frame#{i}.jpg", Rjb::import('com.aspose.imaging.imageoptions.JpegOptions').new)
|
13
|
+
i +=1
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "Saved images successfully!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ReadAndModifyJpegEXIFTags
|
3
|
+
def initialize()
|
4
|
+
# Reading EXIF Data Using ExifData Class
|
5
|
+
read_jpeg_exif_tags_using_exifdata_class()
|
6
|
+
|
7
|
+
# Writing & Modifying EXIF Data Using ExifData Class
|
8
|
+
modify_jpeg_exif_tags_using_exifdata_class()
|
9
|
+
|
10
|
+
# Reading EXIF Data Using JpegExifData Class
|
11
|
+
read_jpeg_exif_tags_using_jpegexifdata_class()
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_jpeg_exif_tags_using_exifdata_class()
|
15
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
16
|
+
|
17
|
+
# Load an existing image
|
18
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
19
|
+
|
20
|
+
# Initialize an object of ExifData and fill it will image's EXIF information
|
21
|
+
exif = image.getExifData()
|
22
|
+
|
23
|
+
# Check if image has any EXIF entries defined
|
24
|
+
if exif != nil
|
25
|
+
# Display a few EXIF entries
|
26
|
+
puts "Exif WhiteBalance: " + exif.get_WhiteBalance().to_s
|
27
|
+
puts "Exif PixelXDimension: " + exif.get_PixelXDimension().to_s
|
28
|
+
puts "Exif PixelYDimension: " + exif.get_PixelYDimension().to_s
|
29
|
+
puts "Exif ISOSpeed: " + exif.get_ISOSpeed().to_s
|
30
|
+
puts "Exif BodySerialNumber: " + exif.get_BodySerialNumber().to_s
|
31
|
+
puts "Exif CameraOwnerName: " + exif.get_CameraOwnerName().to_s
|
32
|
+
puts "Exif ColorSpace: " + exif.get_ColorSpace().to_s
|
33
|
+
puts "Exif Contrast: " + exif.get_Contrast().to_s
|
34
|
+
puts "Exif CustomRendered: " + exif.get_CustomRendered().to_s
|
35
|
+
puts "Exif DateTimeDigitized: " + exif.get_DateTimeDigitized().to_s
|
36
|
+
puts "Exif DateTimeOriginal: " + exif.get_DateTimeOriginal().to_s
|
37
|
+
puts "Exif ExposureMode: " + exif.get_ExposureMode().to_s
|
38
|
+
puts "Exif ExposureProgram: " + exif.get_ExposureProgram().to_s
|
39
|
+
puts "Exif Flash: " + exif.get_Flash().to_s
|
40
|
+
puts "Exif FocalLengthIn35MmFilm: " + exif.get_FocalLengthIn35MmFilm().to_s
|
41
|
+
puts "Exif FocalPlaneResolutionUnit: " + exif.get_FocalPlaneResolutionUnit().to_s
|
42
|
+
puts "Exif GainControl: " + exif.get_GainControl().to_s
|
43
|
+
puts "Exif ImageUniqueID: " + exif.get_ImageUniqueID().to_s
|
44
|
+
puts "Exif Sharpness: " + exif.get_Sharpness().to_s
|
45
|
+
puts "Exif MeteringMode: " + exif.get_MeteringMode().to_s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def modify_jpeg_exif_tags_using_exifdata_class()
|
50
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
51
|
+
|
52
|
+
# Load an existing image
|
53
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
54
|
+
|
55
|
+
# Initialize an object of ExifData and fill it will image's EXIF information
|
56
|
+
exif = image.getExifData()
|
57
|
+
|
58
|
+
# Set Lens Make information
|
59
|
+
exif.set_LensMake("Sony")
|
60
|
+
|
61
|
+
# Set WhiteBalance information
|
62
|
+
exif.set_WhiteBalance(Rjb::import('com.aspose.imaging.exif.enums.ExifWhiteBalance').Auto)
|
63
|
+
|
64
|
+
# Set that Flash was fires
|
65
|
+
exif.set_Flash(Rjb::import('com.aspose.imaging.exif.enums.ExifFlash').Fired)
|
66
|
+
|
67
|
+
# Save the changes to the original image
|
68
|
+
image.save(data_dir + "ModifyExifTags.jpg")
|
69
|
+
|
70
|
+
# Display result
|
71
|
+
puts "Modified JPEG exif tags using ExifData class."
|
72
|
+
end
|
73
|
+
|
74
|
+
def read_jpeg_exif_tags_using_jpegexifdata_class()
|
75
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
76
|
+
|
77
|
+
# Load an existing image
|
78
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
79
|
+
|
80
|
+
# Initialize an object of ExifData and fill it will image's EXIF information
|
81
|
+
exif = image.getExifData()
|
82
|
+
|
83
|
+
# Display a few EXIF entries
|
84
|
+
puts "EXIF CameraOwnerName: " + exif.get_CameraOwnerName().to_s
|
85
|
+
puts "EXIF ApertureValue: " + exif.get_ApertureValue().to_s
|
86
|
+
puts "EXIF Orientation: " + exif.get_Orientation().to_s
|
87
|
+
puts "EXIF FocalLength: " + exif.get_FocalLength().to_s
|
88
|
+
puts "EXIF Compression: " + exif.get_Compression().to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module ResizeImage
|
3
|
+
def initialize()
|
4
|
+
# Simple Resizing
|
5
|
+
simple_image_resizing()
|
6
|
+
|
7
|
+
# Resizing with ResizeType Enumeration
|
8
|
+
resizing_with_resizetype_enumeration()
|
9
|
+
end
|
10
|
+
|
11
|
+
def simple_image_resizing()
|
12
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
13
|
+
|
14
|
+
# Load an existing image
|
15
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
16
|
+
|
17
|
+
# Cache data if not cached previously
|
18
|
+
if !image.isCached()
|
19
|
+
image.cacheData()
|
20
|
+
end
|
21
|
+
|
22
|
+
# Specify only width
|
23
|
+
new_width = image.getWidth() / 2
|
24
|
+
image.resizeWidthProportionally(new_width)
|
25
|
+
|
26
|
+
# Specify only height
|
27
|
+
new_height = image.getHeight() / 2
|
28
|
+
image.resizeHeightProportionally(new_height)
|
29
|
+
|
30
|
+
# Save the image to disk
|
31
|
+
image.save(data_dir + "simple_image_resizing.jpg")
|
32
|
+
|
33
|
+
# Display Status.
|
34
|
+
puts "Resized image successfully!"
|
35
|
+
end
|
36
|
+
|
37
|
+
def resizing_with_resizetype_enumeration()
|
38
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
39
|
+
|
40
|
+
# Load an existing image
|
41
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
42
|
+
|
43
|
+
# Cache data if not cached previously
|
44
|
+
if !image.isCached()
|
45
|
+
image.cacheData()
|
46
|
+
end
|
47
|
+
|
48
|
+
# Specify only width
|
49
|
+
new_width = image.getWidth() / 2
|
50
|
+
image.resizeWidthProportionally(new_width, Rjb::import('com.aspose.imaging.ResizeType').LanczosResample)
|
51
|
+
|
52
|
+
# Specify only height
|
53
|
+
new_height = image.getHeight() / 2
|
54
|
+
image.resizeHeightProportionally(new_height, Rjb::import('com.aspose.imaging.ResizeType').NearestNeighbourResample)
|
55
|
+
|
56
|
+
# Save the image to disk
|
57
|
+
image.save(data_dir + "resizing_with_resizetype_enumeration.jpg")
|
58
|
+
|
59
|
+
# Display Status.
|
60
|
+
puts "Resized image successfully!"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Asposeimagingjava
|
2
|
+
module RotateAndFlipImage
|
3
|
+
def initialize()
|
4
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
5
|
+
|
6
|
+
# Load an existing image (of type bmp) in an instance of Image class
|
7
|
+
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "test.jpg")
|
8
|
+
|
9
|
+
image.rotateFlip(Rjb::import('com.aspose.imaging.RotateFlipType').Rotate270FlipNone)
|
10
|
+
|
11
|
+
# Save the image to disk
|
12
|
+
image.save(data_dir + "RotateFlip.jpg")
|
13
|
+
|
14
|
+
# Display Status.
|
15
|
+
puts "RotateFlip image successfully!"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|