CompressImages

Compress.CompressImages method

Reduces the resolution of pictures in the presentation and deletes their cropped areas, similar to PowerPoint’s “Compress Pictures” applied to all pictures. Pictures on slides, layout slides and master slides are processed, including pictures inside group shapes and picture fills of shapes.

public static void CompressImages(IPresentation presentation, PicturesCompression resolution)
ParameterTypeDescription
presentationIPresentationThe presentation to process.
resolutionPicturesCompressionTarget resolution relative to the size at which each picture is displayed. DocumentResolution leaves pictures unchanged.

Exceptions

exceptioncondition
ArgumentNullExceptionpresentation is null.

Remarks

Pictures already at or below the target resolution are left unchanged; pictures are never upscaled.

Not processed: slide backgrounds, table cell fills, charts, SmartArt, GIF images (to preserve animation), SVG and metafile (EMF/WMF) images.

Cropped areas are removed permanently and cannot be restored in PowerPoint.

Examples

using (Presentation pres = new Presentation("pres.pptx"))
{
    CompressImages(pres, PicturesCompression.Dpi150);
    
    pres.Save("pres-out.pptx", SaveFormat.Pptx);
}

See Also