Convert Method Returns PNG Images in Smaller Dimension

Is there a way I can return my pptx slides in their original dimensions? When I export a slide in Power Point, dimensions are 960x720. When they’re recieved from conversion(api) they’re 720x540.

Thanks

@chrisaern,
Welcome to our community! Thank you for your inquiry.

Could you please share a code example that reproduces the problem you described?

Well it’s not a problem. I was just wondering if there was an option to specify the dimensions of the outputted zipped png’s.

From the docs I saw I could use the options parameter to specify width and height, but not for pptx conversion, right?

@chrisaern,
Could you please specify the Aspose Slides API you are using?

Node JS:
const api = require(“asposeslidescloud”);
const slidesApi = new api.SlidesApi(“id”, “secret”);

// In some Express route using multer to upload to local diskStorage :point_down:

try {
const zipped = await slidesApi.convert(fs.createReadStream(./public/uploads/${req.file.filename}), “png”)
fs.writeFile(./public/downloads/${req.file.filename}.zip, zipped.body, (err) => {
if (err) throw err;
console.log(‘File downloaded’)
});
} catch(err) {
console.log(err)
}

The zipped file in public/downloads contains the png’s in a smaller dimension than if I were to export the slides in Power Point itself as png. I tried using the option parameter in convert method to specify height and width, no luck.

@chrisaern,
I added a ticket with ID SLIDESCLOUD-1352 in our issue tracking system. Our developers will consider your requirements. We will reply to you as soon as possible.

@chrisaern,
Our developers investigated the issue. Unfortunately, we don’t currently have the size option for the convert method. We will do our best to add such options ASAP.

For now, you can use the following solutions.

1. Convert slide by slide:

try {
    const slide_count = 3;
    for (var i = 1; i <= slide_count; i++) {
        const png = await slidesApi.downloadSlideOnline(fs.createReadStream("MySlides.pptx"), i, api.SlideExportFormat.Png, 960, 720);
        fs.writeFile("MySlides" + i + ".png", png.body, (err) => {
            if (err) throw err;
            console.log("Slide #" + i + " downloaded");
        });
    }
} catch(err) {
  console.log(err);
}

This should work, but you should consider the following:

  • it would significantly increase traffic because the presentation would be uploaded repeatedly for each slide
  • it implies you know the number of slides in advance
  • you are in charge of preserving the aspect ratio for the slide

2. Upload your file to storage and set slide size, then download the file from the storage:

try {
    //uploadFile & setSlideProperties need to be done once for each presentation
    await slidesApi.uploadFile("MySlides.pptx", fs.createReadStream("MySlides.pptx"));

    const slideProperties = new api.SlideProperties();
    slideProperties.width = 960;
    slideProperties.height = 720;
    await slidesApi.setSlideProperties("MySlides.pptx", slideProperties);

    const zipped = await slidesApi.downloadPresentation("MySlides.pptx", api.ExportFormat.Png);
    fs.writeFile("MySlides.zip", zipped.body, (err) => {
        if (err) throw err;
        console.log("File downloaded");
    });
} catch(err) {
  console.log(err);
}
1 Like

@Andrey_Potapov

Thanks for your quick response. I can live with the reduced dimensions for now. Appreciate the suggested solutions.

:+1: :+1: