From dc27a2054def9872bed7992cad4d45b7de5b44d3 Mon Sep 17 00:00:00 2001 From: Valentyn Lukianets Date: Mon, 22 Apr 2024 18:08:53 +0300 Subject: [PATCH 1/2] Using Modern API in public examples --- .../chart_marker_options_on_data_point.py | 4 ++-- examples/src/charts/get_chart_image.py | 4 ++-- examples/src/charts/set_marker_options.py | 4 ++-- examples/src/rendering_printing/__init__.py | 2 -- .../src/rendering_printing/render_comments.py | 18 ------------------ .../src/rendering_printing/render_options.py | 13 ++++++------- .../src/rendering_printing/rendering_3d.py | 2 +- .../add_relative_scale_height_picture_frame.py | 5 ++--- .../add_stretch_offset_for_image_fill.py | 2 +- .../shapes/create_bounds_shape_thumbnail.py | 7 +++---- .../shapes/create_scaling_factor_thumbnail.py | 4 ++-- examples/src/shapes/create_shape_thumbnail.py | 4 ++-- .../create_smart_art_child_note_thumbnail.py | 4 ++-- examples/src/shapes/fill_shapes_picture.py | 2 +- .../src/shapes/picture_frame_formatting.py | 2 +- examples/src/shapes/sketched_shapes.py | 4 ++-- .../stretch_offset_left_for_picture_frame.py | 2 +- ...titute_picture_title_of_ole_object_frame.py | 2 +- .../background/set_image_as_background.py | 2 +- .../slides/thumbnail/thumbnail_from_slide.py | 4 ++-- .../thumbnail/thumbnail_from_slide_in_notes.py | 4 ++-- .../thumbnail_with_user_defined_dimensions.py | 4 ++-- .../smart_arts/bullet_fill_format_example.py | 2 +- .../src/tables/add_image_inside_table_cell.py | 2 +- .../add_image_inside_table_cell_and_crop.py | 2 +- examples/src/text/default_fonts_example.py | 4 +--- examples/src/text/keep_text_flat.py | 6 ++---- examples/src/text/manage_embedded_fonts.py | 8 ++++---- .../manage_paragraph_picture_bullets_in_ppt.py | 5 ++--- .../src/text/rendering_with_fallback_font.py | 3 +-- .../src/text/rule_based_fonts_replacement.py | 7 +++---- 31 files changed, 54 insertions(+), 84 deletions(-) delete mode 100644 examples/src/rendering_printing/render_comments.py diff --git a/examples/src/charts/chart_marker_options_on_data_point.py b/examples/src/charts/chart_marker_options_on_data_point.py index e4a5fca..eb9db2b 100644 --- a/examples/src/charts/chart_marker_options_on_data_point.py +++ b/examples/src/charts/chart_marker_options_on_data_point.py @@ -22,11 +22,11 @@ def charts_marker_options_on_data_point(global_opts): chart.chart_data.series.add(fact.get_cell(default_worksheet_index, 1, 1, "Series 1"), chart.type) # Set the picture - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") imgx1 = pres.images.add_image(img) # Set the picture - img2 = drawing.Bitmap(global_opts.data_dir + "image2.jpg") + img2 = slides.Images.from_file(global_opts.data_dir + "image2.jpg") imgx2 = pres.images.add_image(img2) # Take first chart series diff --git a/examples/src/charts/get_chart_image.py b/examples/src/charts/get_chart_image.py index a2bc5ee..802b398 100644 --- a/examples/src/charts/get_chart_image.py +++ b/examples/src/charts/get_chart_image.py @@ -5,5 +5,5 @@ def charts_get_chart_image(global_opts): with slides.Presentation() as pres: chart = pres.slides[0].shapes.add_chart(slides.charts.ChartType.CLUSTERED_COLUMN, 50, 50, 600, 400) - img = chart.get_thumbnail() - img.save(global_opts.out_dir + "charts_get_chart_image_out.png", drawing.imaging.ImageFormat.png) + img = chart.get_image() + img.save(global_opts.out_dir + "charts_get_chart_image_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/charts/set_marker_options.py b/examples/src/charts/set_marker_options.py index 01a54aa..6fdbd6a 100644 --- a/examples/src/charts/set_marker_options.py +++ b/examples/src/charts/set_marker_options.py @@ -23,11 +23,11 @@ def charts_set_marker_options(global_opts): chart.chart_data.series.add(fact.get_cell(default_worksheet_index, 1, 1, "Series 1"), chart.type) # Set the picture - image1 = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + image1 = slides.Images.from_file(global_opts.data_dir + "image1.jpg") imgx1 = presentation.images.add_image(image1) # Set the picture - image2 = drawing.Bitmap(global_opts.data_dir + "image2.jpg") + image2 = slides.Images.from_file(global_opts.data_dir + "image2.jpg") imgx2 = presentation.images.add_image(image2) # Take first chart series diff --git a/examples/src/rendering_printing/__init__.py b/examples/src/rendering_printing/__init__.py index e5103e8..1cbcaf3 100644 --- a/examples/src/rendering_printing/__init__.py +++ b/examples/src/rendering_printing/__init__.py @@ -1,4 +1,3 @@ -from .render_comments import rendering_comments from .render_options import rendering_options from .rendering_3d import rendering_3d from .rendering_emoji import rendering_emoji @@ -7,7 +6,6 @@ def run_rendering_printing_examples(global_opts): - rendering_comments(global_opts) rendering_options(global_opts) rendering_3d(global_opts) rendering_emoji(global_opts) diff --git a/examples/src/rendering_printing/render_comments.py b/examples/src/rendering_printing/render_comments.py deleted file mode 100644 index 7d7704a..0000000 --- a/examples/src/rendering_printing/render_comments.py +++ /dev/null @@ -1,18 +0,0 @@ -import aspose.slides as slides -import aspose.pydrawing as drawing - - -def rendering_comments(global_opts): - with slides.Presentation(global_opts.data_dir + "rendering_comments.pptx") as pres: - bmp = drawing.Bitmap(740, 960) - - render_options = slides.export.RenderingOptions() - render_options.notes_comments_layouting.comments_area_color = drawing.Color.red - render_options.notes_comments_layouting.comments_area_width = 200 - render_options.notes_comments_layouting.comments_position = slides.export.CommentsPositions.RIGHT - render_options.notes_comments_layouting.notes_position = slides.export.NotesPositions.BOTTOM_TRUNCATED - - with drawing.Graphics.from_image(bmp) as graphics: - pres.slides[0].render_to_graphics(render_options, graphics) - - bmp.save(global_opts.out_dir + "rendering_comments_out.png", drawing.imaging.ImageFormat.png) diff --git a/examples/src/rendering_printing/render_options.py b/examples/src/rendering_printing/render_options.py index d62b0dc..b429061 100644 --- a/examples/src/rendering_printing/render_options.py +++ b/examples/src/rendering_printing/render_options.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def rendering_options(global_opts): @@ -7,14 +6,14 @@ def rendering_options(global_opts): rendering_opts = slides.export.RenderingOptions() rendering_opts.notes_comments_layouting.notes_position = slides.export.NotesPositions.BOTTOM_TRUNCATED - pres.slides[0].get_thumbnail(rendering_opts, 4 / 3, 4 / 3).save( - global_opts.out_dir + "rendering_options-Original.png", drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(rendering_opts, 4 / 3, 4 / 3).save( + global_opts.out_dir + "rendering_options-Original.png", slides.ImageFormat.PNG) rendering_opts.notes_comments_layouting.notes_position = slides.export.NotesPositions.NONE rendering_opts.default_regular_font = "Arial Black" - pres.slides[0].get_thumbnail(rendering_opts, 4 / 3, 4 / 3).save( - global_opts.out_dir + "rendering_options-ArialBlackDefault.png", drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(rendering_opts, 4 / 3, 4 / 3).save( + global_opts.out_dir + "rendering_options-ArialBlackDefault.png", slides.ImageFormat.PNG) rendering_opts.default_regular_font = "Arial Narrow" - pres.slides[0].get_thumbnail(rendering_opts, 4 / 3, 4 / 3).save( - global_opts.out_dir + "rendering_options-ArialNarrowDefault.png", drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(rendering_opts, 4 / 3, 4 / 3).save( + global_opts.out_dir + "rendering_options-ArialNarrowDefault.png", slides.ImageFormat.PNG) diff --git a/examples/src/rendering_printing/rendering_3d.py b/examples/src/rendering_printing/rendering_3d.py index ca74958..0011048 100644 --- a/examples/src/rendering_printing/rendering_3d.py +++ b/examples/src/rendering_printing/rendering_3d.py @@ -16,5 +16,5 @@ def rendering_3d(global_opts): shape.three_d_format.extrusion_height = 100 shape.three_d_format.extrusion_color.color = drawing.Color.blue - pres.slides[0].get_thumbnail(2, 2).save(global_opts.out_dir + "sample_3d.png") + pres.slides[0].get_image(2, 2).save(global_opts.out_dir + "sample_3d.png") pres.save(global_opts.out_dir + "rendering_3d_out.pptx", slides.export.SaveFormat.PPTX) diff --git a/examples/src/shapes/add_relative_scale_height_picture_frame.py b/examples/src/shapes/add_relative_scale_height_picture_frame.py index 865f892..35671fb 100644 --- a/examples/src/shapes/add_relative_scale_height_picture_frame.py +++ b/examples/src/shapes/add_relative_scale_height_picture_frame.py @@ -1,12 +1,11 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def add_relative_scale_height_picture_frame(global_opts): # Instantiate presentation object with slides.Presentation() as presentation: # Load Image to be added in presentation image collection - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") image = presentation.images.add_image(img) # Add picture frame to slide diff --git a/examples/src/shapes/add_stretch_offset_for_image_fill.py b/examples/src/shapes/add_stretch_offset_for_image_fill.py index dce0c10..efaf849 100644 --- a/examples/src/shapes/add_stretch_offset_for_image_fill.py +++ b/examples/src/shapes/add_stretch_offset_for_image_fill.py @@ -9,7 +9,7 @@ def add_stretch_offset_for_image_fill(global_opts): slide = pres.slides[0] # Instantiate the Image class - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") imgx = pres.images.add_image(img) # Add Picture Frame with height and width equivalent of Picture diff --git a/examples/src/shapes/create_bounds_shape_thumbnail.py b/examples/src/shapes/create_bounds_shape_thumbnail.py index 4550019..1c9514c 100644 --- a/examples/src/shapes/create_bounds_shape_thumbnail.py +++ b/examples/src/shapes/create_bounds_shape_thumbnail.py @@ -1,11 +1,10 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def create_bounds_shape_thumbnail(global_opts): # Instantiate a Presentation class that represents the presentation file with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as presentation: # Create a Appearance bound shape image - with presentation.slides[0].shapes[0].get_thumbnail(slides.ShapeThumbnailBounds.APPEARANCE, 1, 1) as bitmap: + with presentation.slides[0].shapes[0].get_image(slides.ShapeThumbnailBounds.APPEARANCE, 1, 1) as image: # Save the image to disk in PNG format - bitmap.save(global_opts.out_dir + "shapes_get_thumbnail_bound_shape_out.png", drawing.imaging.ImageFormat.png) + image.save(global_opts.out_dir + "shapes_get_image_bound_shape_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/shapes/create_scaling_factor_thumbnail.py b/examples/src/shapes/create_scaling_factor_thumbnail.py index 4e533a9..b546c08 100644 --- a/examples/src/shapes/create_scaling_factor_thumbnail.py +++ b/examples/src/shapes/create_scaling_factor_thumbnail.py @@ -6,7 +6,7 @@ def create_scaling_factor_thumbnail(global_opts): # Instantiate a Presentation class that represents the presentation file with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as p: # Create a full scale image - with p.slides[0].shapes[0].get_thumbnail(slides.ShapeThumbnailBounds.SHAPE, 2, 2) as bitmap: + with p.slides[0].shapes[0].get_image(slides.ShapeThumbnailBounds.SHAPE, 2, 2) as bitmap: # Save the image to disk in PNG format bitmap.save(global_opts.out_dir + "shapes_create_scaling_thumbnail_out.png", - drawing.imaging.ImageFormat.png) + slides.ImageFormat.PNG) diff --git a/examples/src/shapes/create_shape_thumbnail.py b/examples/src/shapes/create_shape_thumbnail.py index a4b1999..bcf7807 100644 --- a/examples/src/shapes/create_shape_thumbnail.py +++ b/examples/src/shapes/create_shape_thumbnail.py @@ -6,6 +6,6 @@ def create_shape_thumbnail(global_opts): # Instantiate a Presentation class that represents the presentation file with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as presentation: # Create a full scale image - with presentation.slides[0].shapes[0].get_thumbnail() as bitmap: + with presentation.slides[0].shapes[0].get_image() as bitmap: # Save the image to disk in PNG format - bitmap.save(global_opts.out_dir + "shapes_get_shape_thumbnail_out.png", drawing.imaging.ImageFormat.png) + bitmap.save(global_opts.out_dir + "shapes_get_shape_thumbnail_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/shapes/create_smart_art_child_note_thumbnail.py b/examples/src/shapes/create_smart_art_child_note_thumbnail.py index 63b446f..b629a3d 100644 --- a/examples/src/shapes/create_smart_art_child_note_thumbnail.py +++ b/examples/src/shapes/create_smart_art_child_note_thumbnail.py @@ -12,7 +12,7 @@ def create_smart_art_child_note_thumbnail(global_opts): node = smart.nodes[1] # Get thumbnail - bmp = node.shapes[0].get_thumbnail() + bmp = node.shapes[0].get_image() # Save thumbnail - bmp.save(global_opts.out_dir + "shapes_create_smartart_thumbnail_out.jpeg", drawing.imaging.ImageFormat.jpeg) + bmp.save(global_opts.out_dir + "shapes_create_smartart_thumbnail_out.jpeg", slides.ImageFormat.JPEG) diff --git a/examples/src/shapes/fill_shapes_picture.py b/examples/src/shapes/fill_shapes_picture.py index 21c7553..5c1e676 100644 --- a/examples/src/shapes/fill_shapes_picture.py +++ b/examples/src/shapes/fill_shapes_picture.py @@ -18,7 +18,7 @@ def fill_shapes_picture(global_opts): shape.fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.TILE # Set the picture - img = drawing.Bitmap(global_opts.data_dir + "image2.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image2.jpg") imgx = pres.images.add_image(img) shape.fill_format.picture_fill_format.picture.image = imgx diff --git a/examples/src/shapes/picture_frame_formatting.py b/examples/src/shapes/picture_frame_formatting.py index fdc88af..e391ae0 100644 --- a/examples/src/shapes/picture_frame_formatting.py +++ b/examples/src/shapes/picture_frame_formatting.py @@ -9,7 +9,7 @@ def picture_frame_formatting(global_opts): slide = pres.slides[0] # Instantiate the Image class - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") imgx = pres.images.add_image(img) # Add Picture Frame with height and width equivalent of Picture diff --git a/examples/src/shapes/sketched_shapes.py b/examples/src/shapes/sketched_shapes.py index ee1b6c9..183635a 100644 --- a/examples/src/shapes/sketched_shapes.py +++ b/examples/src/shapes/sketched_shapes.py @@ -14,6 +14,6 @@ def sketched_shapes(global_opts): # Transform shape to sketch of a freehand style shape.line_format.sketch_format.sketch_type = slides.LineSketchType.SCRIBBLE - pres.slides[0].get_thumbnail(4 / 3, 4 / 3).save(global_opts.out_dir + "shapes_sketch_format_out.png", - drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(4 / 3, 4 / 3).save(global_opts.out_dir + "shapes_sketch_format_out.png", + slides.ImageFormat.PNG) pres.save(global_opts.out_dir + "shapes_sketch_format_out.pptx", slides.export.SaveFormat.PPTX) diff --git a/examples/src/shapes/stretch_offset_left_for_picture_frame.py b/examples/src/shapes/stretch_offset_left_for_picture_frame.py index 88da282..12b86ad 100644 --- a/examples/src/shapes/stretch_offset_left_for_picture_frame.py +++ b/examples/src/shapes/stretch_offset_left_for_picture_frame.py @@ -9,7 +9,7 @@ def stretch_offset_left_for_picture_frame(global_opts): slide = pres.slides[0] # Instantiate the Image class - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") imgx = pres.images.add_image(img) # Add an AutoShape of Rectangle type diff --git a/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py b/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py index 316c3a4..5414f1f 100644 --- a/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py +++ b/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py @@ -16,7 +16,7 @@ def substitute_picture_title_of_ole_object_frame(global_opts): oof.is_object_icon = True # Add image object - image = pres.images.add_image(drawing.Bitmap(global_opts.data_dir + "image1.jpg")) + image = pres.images.add_image(slides.Images.from_file(global_opts.data_dir + "image1.jpg")) oof.substitute_picture_format.picture.image = image # Set caption to OLE icon diff --git a/examples/src/slides/background/set_image_as_background.py b/examples/src/slides/background/set_image_as_background.py index 6a8247b..f32cd4d 100644 --- a/examples/src/slides/background/set_image_as_background.py +++ b/examples/src/slides/background/set_image_as_background.py @@ -11,7 +11,7 @@ def set_image_as_background(global_opts): pres.slides[0].background.fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.STRETCH # Set the picture - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") # Add image to presentation's images collection imgx = pres.images.add_image(img) diff --git a/examples/src/slides/thumbnail/thumbnail_from_slide.py b/examples/src/slides/thumbnail/thumbnail_from_slide.py index 3efd058..e3baa0a 100644 --- a/examples/src/slides/thumbnail/thumbnail_from_slide.py +++ b/examples/src/slides/thumbnail/thumbnail_from_slide.py @@ -9,7 +9,7 @@ def thumbnail_from_slide(global_opts): slide = pres.slides[0] # Create a full scale image - bmp = slide.get_thumbnail(1, 1) + bmp = slide.get_image(1, 1) # Save the image to disk in JPEG format - bmp.save(global_opts.out_dir + "thumbnail_from_slide_out.jpg", drawing.imaging.ImageFormat.jpeg) + bmp.save(global_opts.out_dir + "thumbnail_from_slide_out.jpg", slides.ImageFormat.JPEG) diff --git a/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py b/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py index 3d84d8f..d5a6ebf 100644 --- a/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py +++ b/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py @@ -17,6 +17,6 @@ def thumbnail_from_slide_in_notes(global_opts): scale_y = (1.0 / pres.slide_size.size.height) * desired_y # Create a full scale image - bmp = slide.get_thumbnail(scale_x, scale_y) + bmp = slide.get_image(scale_x, scale_y) # Save the image to disk in JPEG format - bmp.save(global_opts.out_dir + "thumbnail_get_from_notes_out.jpg", drawing.imaging.ImageFormat.jpeg) + bmp.save(global_opts.out_dir + "thumbnail_get_from_notes_out.jpg", slides.ImageFormat.JPEG) diff --git a/examples/src/slides/thumbnail/thumbnail_with_user_defined_dimensions.py b/examples/src/slides/thumbnail/thumbnail_with_user_defined_dimensions.py index 10703d9..ecc8c4f 100644 --- a/examples/src/slides/thumbnail/thumbnail_with_user_defined_dimensions.py +++ b/examples/src/slides/thumbnail/thumbnail_with_user_defined_dimensions.py @@ -17,7 +17,7 @@ def thumbnail_with_user_defined_dimensions(global_opts): scale_y = (1.0 / pres.slide_size.size.height) * desired_y # Create a full scale image - bmp = slide.get_thumbnail(scale_x, scale_y) + bmp = slide.get_image(scale_x, scale_y) # Save the image to disk in JPEG format - bmp.save(global_opts.out_dir + "thumbnail_user_defined_dimensions_out.jpg", drawing.imaging.ImageFormat.jpeg) + bmp.save(global_opts.out_dir + "thumbnail_user_defined_dimensions_out.jpg", slides.ImageFormat.JPEG) diff --git a/examples/src/smart_arts/bullet_fill_format_example.py b/examples/src/smart_arts/bullet_fill_format_example.py index a572319..cb33d53 100644 --- a/examples/src/smart_arts/bullet_fill_format_example.py +++ b/examples/src/smart_arts/bullet_fill_format_example.py @@ -8,7 +8,7 @@ def bullet_fill_format_example(global_opts): node = smart.all_nodes[0] if node.bullet_fill_format is not None: - img = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") image = presentation.images.add_image(img) node.bullet_fill_format.fill_type = slides.FillType.PICTURE node.bullet_fill_format.picture_fill_format.picture.image = image diff --git a/examples/src/tables/add_image_inside_table_cell.py b/examples/src/tables/add_image_inside_table_cell.py index 614e8f6..d6a3d7c 100644 --- a/examples/src/tables/add_image_inside_table_cell.py +++ b/examples/src/tables/add_image_inside_table_cell.py @@ -16,7 +16,7 @@ def add_image_inside_table_cell(global_opts): tbl = slide.shapes.add_table(50, 50, dbl_cols, dbl_rows) # Creating a Image object to hold the image file - image = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + image = slides.Images.from_file(global_opts.data_dir + "image1.jpg") # Create an object using the bitmap object imgx1 = presentation.images.add_image(image) diff --git a/examples/src/tables/add_image_inside_table_cell_and_crop.py b/examples/src/tables/add_image_inside_table_cell_and_crop.py index e647f18..1a7f3ab 100644 --- a/examples/src/tables/add_image_inside_table_cell_and_crop.py +++ b/examples/src/tables/add_image_inside_table_cell_and_crop.py @@ -16,7 +16,7 @@ def add_image_inside_table_cell_and_crop(global_opts): tbl = slide.shapes.add_table(50, 50, dbl_cols, dbl_rows) # Creating a Image object to hold the image file - image = drawing.Bitmap(global_opts.data_dir + "image1.jpg") + image = slides.Images.from_file(global_opts.data_dir + "image1.jpg") # Create an object using the bitmap object imgx1 = presentation.images.add_image(image) diff --git a/examples/src/text/default_fonts_example.py b/examples/src/text/default_fonts_example.py index 6a8e07b..aa0d90e 100644 --- a/examples/src/text/default_fonts_example.py +++ b/examples/src/text/default_fonts_example.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def default_fonts_example(global_opts): @@ -12,8 +11,7 @@ def default_fonts_example(global_opts): # Load the presentation with slides.Presentation(global_opts.data_dir + "text_default_fonts.pptx", load_options) as pptx: # Generate slide thumbnail - pptx.slides[0].get_thumbnail(1, 1).save(global_opts.out_dir + "text_default_fonts_out.png", - drawing.imaging.ImageFormat.png) + pptx.slides[0].get_image(1, 1).save(global_opts.out_dir + "text_default_fonts_out.png", slides.ImageFormat.PNG) # Generate PDF pptx.save(global_opts.out_dir + "text_default_fonts_out.pdf", slides.export.SaveFormat.PDF) diff --git a/examples/src/text/keep_text_flat.py b/examples/src/text/keep_text_flat.py index c37c7bd..8de7a74 100644 --- a/examples/src/text/keep_text_flat.py +++ b/examples/src/text/keep_text_flat.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def keep_text_flat(global_opts): @@ -10,5 +9,4 @@ def keep_text_flat(global_opts): shape1.text_frame.text_frame_format.keep_text_flat = False shape2.text_frame.text_frame_format.keep_text_flat = True - pres.slides[0].get_thumbnail(4 / 3, 4 / 3).save(global_opts.out_dir + "text_keep_text_flat_out.png", - drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(4 / 3, 4 / 3).save(global_opts.out_dir + "text_keep_text_flat_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/text/manage_embedded_fonts.py b/examples/src/text/manage_embedded_fonts.py index 4d700f5..8a1cf94 100644 --- a/examples/src/text/manage_embedded_fonts.py +++ b/examples/src/text/manage_embedded_fonts.py @@ -6,8 +6,8 @@ def manage_embedded_fonts(global_opts): # Instantiate a Presentation object that represents a presentation file with slides.Presentation(global_opts.data_dir + "text_embedded_fonts.pptx") as presentation: # render a slide that contains a text frame that uses embedded "FunSized" - presentation.slides[0].get_thumbnail(drawing.Size(960, 720)).save( - global_opts.out_dir + "text_embedded_fonts_1_out.png", drawing.imaging.ImageFormat.png) + presentation.slides[0].get_image(drawing.Size(960, 720)).save( + global_opts.out_dir + "text_embedded_fonts_1_out.png", slides.ImageFormat.PNG) fonts_manager = presentation.fonts_manager @@ -21,8 +21,8 @@ def manage_embedded_fonts(global_opts): fonts_manager.remove_embedded_font(calibri_font) # render the presentation removed "Calibri" font is replaced to an existing one - presentation.slides[0].get_thumbnail(drawing.Size(960, 720)).save( - global_opts.out_dir + "text_embedded_fonts_2_out.png", drawing.imaging.ImageFormat.png) + presentation.slides[0].get_image(drawing.Size(960, 720)).save( + global_opts.out_dir + "text_embedded_fonts_2_out.png", slides.ImageFormat.PNG) # save the presentation without embedded "Calibri" font presentation.save(global_opts.out_dir + "text_embedded_fonts_out.ppt", slides.export.SaveFormat.PPT) diff --git a/examples/src/text/manage_paragraph_picture_bullets_in_ppt.py b/examples/src/text/manage_paragraph_picture_bullets_in_ppt.py index da2d797..4cf5821 100644 --- a/examples/src/text/manage_paragraph_picture_bullets_in_ppt.py +++ b/examples/src/text/manage_paragraph_picture_bullets_in_ppt.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def manage_paragraph_picture_bullets_in_ppt(global_opts): @@ -8,7 +7,7 @@ def manage_paragraph_picture_bullets_in_ppt(global_opts): slide = presentation.slides[0] # Instantiate the image for bullets - image = drawing.Bitmap(global_opts.data_dir + "bullets.png") + image = slides.Images.from_file(global_opts.data_dir + "bullets.png") ippx_image = presentation.images.add_image(image) # Adding and accessing Autoshape diff --git a/examples/src/text/rendering_with_fallback_font.py b/examples/src/text/rendering_with_fallback_font.py index 0bdd767..acf53fe 100644 --- a/examples/src/text/rendering_with_fallback_font.py +++ b/examples/src/text/rendering_with_fallback_font.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def rendering_with_fallback_font(global_opts): @@ -26,4 +25,4 @@ def rendering_with_fallback_font(global_opts): pres.fonts_manager.font_fall_back_rules_collection = rules_list # Rendering of thumbnail with using of initialized rules collection and saving to PNG - pres.slides[0].get_thumbnail(1, 1).save(global_opts.out_dir + "text_font_fall_back_out.png", drawing.imaging.ImageFormat.png) + pres.slides[0].get_image(1, 1).save(global_opts.out_dir + "text_font_fall_back_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/text/rule_based_fonts_replacement.py b/examples/src/text/rule_based_fonts_replacement.py index c0e39ee..38c9001 100644 --- a/examples/src/text/rule_based_fonts_replacement.py +++ b/examples/src/text/rule_based_fonts_replacement.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def rule_based_fonts_replacement(global_opts): @@ -22,7 +21,7 @@ def rule_based_fonts_replacement(global_opts): presentation.fonts_manager.font_subst_rule_list = font_subst_rule_collection # Arial font will be used instead of SomeRareFont when inaccessible - bmp = presentation.slides[0].get_thumbnail(1, 1) + bmp = presentation.slides[0].get_image(1, 1) # Save the image to disk in JPEG format - bmp.save(global_opts.out_dir + "text_rule_based_font_replacement_out.jpg", drawing.imaging.ImageFormat.jpeg) + bmp.save(global_opts.out_dir + "text_rule_based_font_replacement_out.jpg", slides.ImageFormat.JPEG) From 14e0323da6555c47f3473824564455619f58c333 Mon Sep 17 00:00:00 2001 From: Valentyn Lukianets Date: Mon, 22 Apr 2024 18:40:53 +0300 Subject: [PATCH 2/2] Using Modern API in public examples pt 2 --- .../src/charts/chart_marker_options_on_data_point.py | 1 - examples/src/charts/get_chart_image.py | 1 - examples/src/charts/set_marker_options.py | 3 +-- examples/src/shapes/add_stretch_offset_for_image_fill.py | 1 - examples/src/shapes/create_scaling_factor_thumbnail.py | 9 ++++----- examples/src/shapes/create_shape_thumbnail.py | 7 +++---- .../src/shapes/create_smart_art_child_note_thumbnail.py | 7 +++---- examples/src/shapes/fill_shapes_picture.py | 1 - examples/src/shapes/sketched_shapes.py | 1 - .../src/shapes/stretch_offset_left_for_picture_frame.py | 3 +-- .../substitute_picture_title_of_ole_object_frame.py | 6 +++--- .../src/slides/background/set_image_as_background.py | 1 - examples/src/slides/thumbnail/thumbnail_from_slide.py | 1 - .../slides/thumbnail/thumbnail_from_slide_in_notes.py | 1 - examples/src/smart_arts/bullet_fill_format_example.py | 6 +++--- .../src/tables/add_image_inside_table_cell_and_crop.py | 3 +-- 16 files changed, 19 insertions(+), 33 deletions(-) diff --git a/examples/src/charts/chart_marker_options_on_data_point.py b/examples/src/charts/chart_marker_options_on_data_point.py index eb9db2b..691b397 100644 --- a/examples/src/charts/chart_marker_options_on_data_point.py +++ b/examples/src/charts/chart_marker_options_on_data_point.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def charts_marker_options_on_data_point(global_opts): diff --git a/examples/src/charts/get_chart_image.py b/examples/src/charts/get_chart_image.py index 802b398..03062ac 100644 --- a/examples/src/charts/get_chart_image.py +++ b/examples/src/charts/get_chart_image.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def charts_get_chart_image(global_opts): diff --git a/examples/src/charts/set_marker_options.py b/examples/src/charts/set_marker_options.py index 6fdbd6a..ee3cb72 100644 --- a/examples/src/charts/set_marker_options.py +++ b/examples/src/charts/set_marker_options.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def charts_set_marker_options(global_opts): diff --git a/examples/src/shapes/add_stretch_offset_for_image_fill.py b/examples/src/shapes/add_stretch_offset_for_image_fill.py index efaf849..14bf9c8 100644 --- a/examples/src/shapes/add_stretch_offset_for_image_fill.py +++ b/examples/src/shapes/add_stretch_offset_for_image_fill.py @@ -1,4 +1,3 @@ -import aspose.pydrawing as drawing import aspose.slides as slides diff --git a/examples/src/shapes/create_scaling_factor_thumbnail.py b/examples/src/shapes/create_scaling_factor_thumbnail.py index b546c08..eddaaaa 100644 --- a/examples/src/shapes/create_scaling_factor_thumbnail.py +++ b/examples/src/shapes/create_scaling_factor_thumbnail.py @@ -1,12 +1,11 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def create_scaling_factor_thumbnail(global_opts): # Instantiate a Presentation class that represents the presentation file - with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as p: + with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as pres: # Create a full scale image - with p.slides[0].shapes[0].get_image(slides.ShapeThumbnailBounds.SHAPE, 2, 2) as bitmap: + with pres.slides[0].shapes[0].get_image(slides.ShapeThumbnailBounds.SHAPE, 2, 2) as image: # Save the image to disk in PNG format - bitmap.save(global_opts.out_dir + "shapes_create_scaling_thumbnail_out.png", + image.save(global_opts.out_dir + "shapes_create_scaling_thumbnail_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/shapes/create_shape_thumbnail.py b/examples/src/shapes/create_shape_thumbnail.py index bcf7807..bebade5 100644 --- a/examples/src/shapes/create_shape_thumbnail.py +++ b/examples/src/shapes/create_shape_thumbnail.py @@ -1,11 +1,10 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def create_shape_thumbnail(global_opts): # Instantiate a Presentation class that represents the presentation file with slides.Presentation(global_opts.data_dir + "welcome-to-powerpoint.pptx") as presentation: # Create a full scale image - with presentation.slides[0].shapes[0].get_image() as bitmap: + with presentation.slides[0].shapes[0].get_image() as image: # Save the image to disk in PNG format - bitmap.save(global_opts.out_dir + "shapes_get_shape_thumbnail_out.png", slides.ImageFormat.PNG) + image.save(global_opts.out_dir + "shapes_get_shape_thumbnail_out.png", slides.ImageFormat.PNG) diff --git a/examples/src/shapes/create_smart_art_child_note_thumbnail.py b/examples/src/shapes/create_smart_art_child_note_thumbnail.py index b629a3d..03e34e2 100644 --- a/examples/src/shapes/create_smart_art_child_note_thumbnail.py +++ b/examples/src/shapes/create_smart_art_child_note_thumbnail.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def create_smart_art_child_note_thumbnail(global_opts): @@ -12,7 +11,7 @@ def create_smart_art_child_note_thumbnail(global_opts): node = smart.nodes[1] # Get thumbnail - bmp = node.shapes[0].get_image() + image = node.shapes[0].get_image() # Save thumbnail - bmp.save(global_opts.out_dir + "shapes_create_smartart_thumbnail_out.jpeg", slides.ImageFormat.JPEG) + image.save(global_opts.out_dir + "shapes_create_smartart_thumbnail_out.jpeg", slides.ImageFormat.JPEG) diff --git a/examples/src/shapes/fill_shapes_picture.py b/examples/src/shapes/fill_shapes_picture.py index 5c1e676..add4e20 100644 --- a/examples/src/shapes/fill_shapes_picture.py +++ b/examples/src/shapes/fill_shapes_picture.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def fill_shapes_picture(global_opts): diff --git a/examples/src/shapes/sketched_shapes.py b/examples/src/shapes/sketched_shapes.py index 183635a..d16bf1e 100644 --- a/examples/src/shapes/sketched_shapes.py +++ b/examples/src/shapes/sketched_shapes.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def sketched_shapes(global_opts): diff --git a/examples/src/shapes/stretch_offset_left_for_picture_frame.py b/examples/src/shapes/stretch_offset_left_for_picture_frame.py index 12b86ad..09384a0 100644 --- a/examples/src/shapes/stretch_offset_left_for_picture_frame.py +++ b/examples/src/shapes/stretch_offset_left_for_picture_frame.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def stretch_offset_left_for_picture_frame(global_opts): diff --git a/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py b/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py index 5414f1f..7ebdfed 100644 --- a/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py +++ b/examples/src/shapes/substitute_picture_title_of_ole_object_frame.py @@ -1,5 +1,4 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def substitute_picture_title_of_ole_object_frame(global_opts): @@ -16,8 +15,9 @@ def substitute_picture_title_of_ole_object_frame(global_opts): oof.is_object_icon = True # Add image object - image = pres.images.add_image(slides.Images.from_file(global_opts.data_dir + "image1.jpg")) - oof.substitute_picture_format.picture.image = image + img = slides.Images.from_file(global_opts.data_dir + "image1.jpg") + imgx = pres.images.add_image(img) + oof.substitute_picture_format.picture.image = imgx # Set caption to OLE icon oof.substitute_picture_title = "Caption example" diff --git a/examples/src/slides/background/set_image_as_background.py b/examples/src/slides/background/set_image_as_background.py index f32cd4d..06c9a88 100644 --- a/examples/src/slides/background/set_image_as_background.py +++ b/examples/src/slides/background/set_image_as_background.py @@ -1,4 +1,3 @@ -import aspose.pydrawing as drawing import aspose.slides as slides diff --git a/examples/src/slides/thumbnail/thumbnail_from_slide.py b/examples/src/slides/thumbnail/thumbnail_from_slide.py index e3baa0a..c53e694 100644 --- a/examples/src/slides/thumbnail/thumbnail_from_slide.py +++ b/examples/src/slides/thumbnail/thumbnail_from_slide.py @@ -1,4 +1,3 @@ -import aspose.pydrawing as drawing import aspose.slides as slides diff --git a/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py b/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py index d5a6ebf..0fae35b 100644 --- a/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py +++ b/examples/src/slides/thumbnail/thumbnail_from_slide_in_notes.py @@ -1,4 +1,3 @@ -import aspose.pydrawing as drawing import aspose.slides as slides diff --git a/examples/src/smart_arts/bullet_fill_format_example.py b/examples/src/smart_arts/bullet_fill_format_example.py index cb33d53..d81a157 100644 --- a/examples/src/smart_arts/bullet_fill_format_example.py +++ b/examples/src/smart_arts/bullet_fill_format_example.py @@ -1,10 +1,10 @@ import aspose.slides as slides -import aspose.pydrawing as drawing def bullet_fill_format_example(global_opts): with slides.Presentation() as presentation: - smart = presentation.slides[0].shapes.add_smart_art(10, 10, 500, 400, slides.smartart.SmartArtLayoutType.VERTICAL_PICTURE_LIST) + smart = presentation.slides[0].shapes.add_smart_art(10, 10, 500, 400, + slides.smartart.SmartArtLayoutType.VERTICAL_PICTURE_LIST) node = smart.all_nodes[0] if node.bullet_fill_format is not None: @@ -14,4 +14,4 @@ def bullet_fill_format_example(global_opts): node.bullet_fill_format.picture_fill_format.picture.image = image node.bullet_fill_format.picture_fill_format.picture_fill_mode = slides.PictureFillMode.STRETCH - presentation.save(global_opts.out_dir +"smart_art_bullet_fill_format_out.pptx", slides.export.SaveFormat.PPTX) + presentation.save(global_opts.out_dir + "smart_art_bullet_fill_format_out.pptx", slides.export.SaveFormat.PPTX) diff --git a/examples/src/tables/add_image_inside_table_cell_and_crop.py b/examples/src/tables/add_image_inside_table_cell_and_crop.py index 1a7f3ab..1719e15 100644 --- a/examples/src/tables/add_image_inside_table_cell_and_crop.py +++ b/examples/src/tables/add_image_inside_table_cell_and_crop.py @@ -1,5 +1,4 @@ -import aspose.pydrawing as drawing -import aspose.slides as slides +import aspose.slides as slides def add_image_inside_table_cell_and_crop(global_opts):