Convert Powerpoint to JPG

About PowerPoint to JPG Conversion

With Aspose.Slides API you can convert PowerPoint PPT or PPTX presentation to JPG image. It is also possible to convert PPT/PPTX to JPEG, PNG or SVG. With this features it’s easy to implement your own presentation viewer, create  the thumbnail for every slide. This may be useful if you want to protect presentation slides from copywriting, demonstrate presentation in read-only mode. Aspose.Slides allows to convert the whole presentation or a certain slide into image formats. 

todo:image_alt_text

Convert PowerPoint PPT/PPTX to JPG

Here are the steps to convert PPT/PPTX to JPG:

  1. Create an instance of Presentation type.
  2. Get the slide object of Slide type from Presentation.getSlides() collection.
  3. Create the thumbnail of each slide and then convert it into JPG. Slide.getImage(float scaleX, float scaleY) method is used to get a thumbnail of a slide, it returns Imagess object as a result. getImage method has to be called from the needed slide of Slide type, the scales of the resulting thumbnail are passed into the method.
  4. After you get the slide thumbnail, call [Image.save(String formatName, int imageFormat)](https://reference.aspose.com/slides/nodejs-java/aspose.slides/Image#save(String formatName, int imageFormat)) method from the thumbnail object. Pass the resulting file name and the image format into it. 
var pres = new aspose.slides.Presentation("PowerPoint-Presentation.pptx");
try {
    for (let i = 0; i < pres.getSlides().size(); i++) {
        let sld = pres.getSlides().get_Item(i);
        // Creates a full scale image
        var slideImage = sld.getImage(1.0, 1.0);
        // Saves the image to disk in JPEG format
        try {
            slideImage.save(java.callStaticMethodSync("java.lang.String", "format", "Slide_%d.jpg", sld.getSlideNumber()), aspose.slides.ImageFormat.Jpeg);
        } finally {
            if (slideImage != null) {
                slideImage.dispose();
            }
        }
    }
} finally {
    if (pres != null) {
        pres.dispose();
    }
}

Convert PowerPoint PPT/PPTX to JPG with Customized Dimensions

To change the dimension of the resulting thumbnail and JPG image, you can set the ScaleX and ScaleY values by passing them into the Slide.getImage(float scaleX, float scaleY) methods:

var pres = new aspose.slides.Presentation("PowerPoint-Presentation.pptx");
try {
    // Defines dimensions
    var desiredX = 1200;
    var desiredY = 800;
    // Gets scaled values of X and Y
    var ScaleX = 1.0 / pres.getSlideSize().getSize().getWidth() * desiredX;
    var ScaleY = 1.0 / pres.getSlideSize().getSize().getHeight() * desiredY;
    for (let i = 0; i < pres.getSlides().size(); i++) {
        let sld = pres.getSlides().get_Item(i);
        // Creates a full scale image
        var slideImage = sld.getImage(ScaleX, ScaleY);
        // Saves the image to disk in JPEG format
        try {
            slideImage.save(java.callStaticMethodSync("java.lang.String", "format", "Slide_%d.jpg", sld.getSlideNumber()), aspose.slides.ImageFormat.Jpeg);
        } finally {
            if (slideImage != null) {
                slideImage.dispose();
            }
        }
    }
} finally {
    if (pres != null) {
        pres.dispose();
    }
}

Render Comments when saving Presentation into Image

Aspose.Slides for Node.js via Java provides a facility that allows you to render comments in a presentation’s slides when you are converting those slides into images. This JavaScript code demonstrates the operation:

var pres = new aspose.slides.Presentation("presentation.pptx");
try {
    var notesOptions = new aspose.slides.NotesCommentsLayoutingOptions();
    notesOptions.setNotesPosition(aspose.slides.NotesPositions.BottomTruncated);
    var opts = new aspose.slides.RenderingOptions();
    opts.setSlidesLayoutOptions(notesOptions);
    for (let i = 0; i < pres.getSlides().size(); i++) {
        let sld = pres.getSlides().get_Item(i);
        var slideImage = sld.getImage(opts, java.newInstanceSync("java.awt.Dimension", 740, 960));
        try {
            slideImage.save(java.callStaticMethodSync("java.lang.String", "format", "Slide_%d.png", sld.getSlideNumber()));
        } finally {
            if (slideImage != null) {
                slideImage.dispose();
            }
        }
    }
} finally {
    if (pres != null) {
        pres.dispose();
    }
}

See also

See other options to convert PPT/PPTX into image like: