Module: Asposeslidesjava::Thumbnail
- Defined in:
- lib/asposeslidesjava/Slides/thumbnail.rb
Instance Method Summary collapse
-
#create_thumbnail ⇒ Object
Generating a Thumbnail from a Slide.
-
#create_thumbnail_custom_size ⇒ Object
Generating a Thumbnail from a Slide with User Defined Dimensions.
-
#create_thumbnail_in_notes_slides_view ⇒ Object
Generating a Thumbnail from a Slide in Notes Slides View.
-
#create_thumbnail_of_user_defined_window ⇒ Object
Generating a Thumbnail of User Defined Window from a Slide.
- #initialize ⇒ Object
Instance Method Details
#create_thumbnail ⇒ Object
Generating a Thumbnail from a Slide
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/asposeslidesjava/Slides/thumbnail.rb', line 18 def create_thumbnail() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx') # Access the first slide = pres.getSlides().get_Item(0) # Create a full scale image image = .getThumbnail() # Save the image to disk in JPEG format Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg")) puts "Created thumbnail, please check the output file." end |
#create_thumbnail_custom_size ⇒ Object
Generating a Thumbnail from a Slide with User Defined Dimensions
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/asposeslidesjava/Slides/thumbnail.rb', line 37 def create_thumbnail_custom_size() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx') # Access the first slide = pres.getSlides().get_Item(0) # User defined dimension desired_x = 1200 desired_y = 800 # Getting scaled value of X and Y scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y # Create a full scale image image = .getThumbnail(scale_x, scale_y) # Save the image to disk in JPEG format Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg")) puts "Created thumbnail with custom size, please check the output file." end |
#create_thumbnail_in_notes_slides_view ⇒ Object
Generating a Thumbnail from a Slide in Notes Slides View
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/asposeslidesjava/Slides/thumbnail.rb', line 64 def () data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx') # Access the first slide = pres.getSlides().get_Item(0) # User defined dimension desired_x = 1200 desired_y = 800 # Getting scaled value of X and Y scale_x = (1.0 / pres.getSlideSize().getSize().getWidth()) * desired_x scale_y = (1.0 / pres.getSlideSize().getSize().getHeight()) * desired_y # Create a full scale image image = .getNotesSlide().getThumbnail(scale_x, scale_y) # Save the image to disk in JPEG format Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg")) puts "Created thumbnail in notes slides view, please check the output file." end |
#create_thumbnail_of_user_defined_window ⇒ Object
Generating a Thumbnail of User Defined Window from a Slide
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/asposeslidesjava/Slides/thumbnail.rb', line 91 def create_thumbnail_of_user_defined_window() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/' # Instantiate Presentation class that represents the presentation file pres = Rjb::import('com.aspose.slides.Presentation').new(data_dir + 'demo.pptx') # Access the first slide = pres.getSlides().get_Item(0) # Create a full scale image image = .getThumbnail(1,1) # Getting the image of desired window inside generated slide thumnbnail # BufferedImage window = image.getSubimage(windowX, windowY, windowsWidth, windowHeight); window_image = image.getSubimage(100, 100, 200, 200) # Save the image to disk in JPEG format Rjb::import('javax.imageio.ImageIO').write(image, "jpeg", Rjb::import('java.io.File').new(data_dir + "ContentBG_tnail.jpg")) puts "Created thumbnail of user defined window, please check the output file." end |
#initialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/asposeslidesjava/Slides/thumbnail.rb', line 3 def initialize() # Generating a Thumbnail from a Slide create_thumbnail() # Generating a Thumbnail from a Slide with User Defined Dimensions create_thumbnail_custom_size() # Generating a Thumbnail from a Slide in Notes Slides View () # Generating a Thumbnail of User Defined Window from a Slide create_thumbnail_of_user_defined_window() end |