Class ImageConverter
Namespace: Aspose.Cells.LowCode
Assembly: Aspose.Cells.dll (25.7.0)
Converter for converting template file to images.
public class ImageConverter
{
private readonly IImageConversionService _conversionService;
public ImageConverter(IImageConversionService conversionService)
{
_conversionService = conversionService;
}
public byte[] ConvertImageToByteArray(string filePath, ImageFormat imageFormat)
{
using (var image = Image.FromFile(filePath))
{
return _conversionService.ConvertImageToByteArray(image, imageFormat);
}
}
}
Inheritance
Examples
ImageConverter.Process("template.xlsx", "res.png");
Methods
Process(string, string)
Converts template file to images.
public static void Process(
string templateFile,
string resultFile
)
{
}
Parameters
templateFile
string
The template file to be converted to images.
resultFile
string
The resultant file(name pattern) for generated images.
Remarks
The output files will be build from the specified result fileby appending sequence number of the sheet and split part.For example, if the specified output file is Image.png, then the generated imagefiles will be Image_0_0.png, Image_0_1.png, …, Image_1_0.png, …
Process(LowCodeLoadOptions, LowCodeSaveOptions)
Converts template file to images
public static void Process(
LowCodeLoadOptions loadOptions,
LowCodeSaveOptions saveOptions)
Parameters
loadOptions
LowCodeLoadOptions
Options for input and loading
saveOptions
LowCodeSaveOptions
Options for output and saving
Remarks
When converting to image of format that supports multiple pages(such as tiff),the specified Aspose.Cells.LowCode.LowCodeSaveOptions.OutputFileor Aspose.Cells.LowCode.LowCodeSaveOptions.OutputStream will be used directly for the resultant image.
For other types of image, if the save options has specified Stream as output,then all resultant images will be saved to the same Stream.Otherwise, the output files will be build from the specified output fileof the save options by appending sequence number of the sheet and split part.For example, if the specified output file is Image.png, then the generated imagefiles will be Image_0_0.png, Image_0_1.png, …, Image_1_0.png, …
Process(LowCodeLoadOptions, LowCodeSaveOptions, AbstractLowCodeSaveOptionsProvider)
Converts template file to images
public static void
Process(
LowCodeLoadOptions loadOptions,
LowCodeSaveOptions saveOptions,
AbstractLowCodeSaveOptionsProvider provider)
{
}
Parameters
loadOptions
LowCodeLoadOptions
Options for input and loading
saveOptions
LowCodeSaveOptions
Options for saving.Its output(Aspose.Cells.LowCode.LowCodeSaveOptions.OutputFile or Aspose.Cells.LowCode.LowCodeSaveOptions.OutputStream)takes no effect because all outputs will be specified by the “provider” parameter
provider
AbstractLowCodeSaveOptionsProvider
Provider of save options for saving the generated images