GroupDocsGists
10/24/2017 - 5:11 PM

RenderToImageWebpFromStreamToFile.cs

// For complete examples and data files, please go to https://github.com/atirtahir/groupdocs_conversion_updated
// Instantiating the conversion handler from custom common class
ConversionHandler conversionHandler = Common.getConversionHandler(); ;

// Convert and save converted image file.
// Returns paths to the converted image file.
var saveOptions = new ImageSaveOptions
ConvertFileType = ImageSaveOptions.ImageFileType.Webp,
    WebpOptions =
    {
        Lossless = true
    }

// read input document as a stream
FileStream fileStream = new FileStream(Path.Combine(Common.storagePath, Common.inputGUIDFile), FileMode.Open, FileAccess.Read);

var convertedDocumentStream = conversionHandler.Convert(fileStream, new ImageSaveOptions { });
MemoryStream targetStream = new MemoryStream();
convertedDocumentStream.Save(targetStream);

fileStream.Close();