Class ImageConverter
- Namespace
- Dynamicweb.Imaging.ImageHandling
- Assembly
- Dynamicweb.Core.dll
Applies transformations to images based on parameters
public class ImageConverter
- Inheritance
-
ImageConverter
- Inherited Members
Constructors
ImageConverter()
Creates new instance of this class.
public ImageConverter()
ImageConverter(string)
Creates new instance of this class.
public ImageConverter(string sourceFile)
Parameters
sourceFilestringThe virtual path to the image to be converted.
Properties
Parameters
Gets or sets the ConvertParameters object for this instance.
public ConvertParameters Parameters { get; set; }
Property Value
Methods
ColorModeFromString(string)
Colors the mode from string.
public static ColorMode ColorModeFromString(string mode)
Parameters
modestringThe color mode as string.
Returns
Convert(ConvertParameters)
Converts the image and returns the contents of the converted image.
public static byte[] Convert(ConvertParameters convertParameters)
Parameters
convertParametersConvertParametersThe conversion parameters.
Returns
- byte[]
The contents of the converted image.
Exceptions
- ConvertException
Thrown when unable to process the image file using the given parameters.
Convert(string, string, int)
Converts the image.
public static void Convert(string fromFile, string toFile, int width)
Parameters
fromFilestringThe virtual path to the source file.
toFilestringThe virtual path to the destination file.
widthintThe width of the image.
Convert(string, string, int, int)
Converts the image.
public static void Convert(string fromFile, string toFile, int width, int height)
Parameters
fromFilestringThe virtual path to the source file.
toFilestringThe virtual path to the destination file.
widthintThe width of the image.
heightintThe height of the image.
Convert(string, string, int, int, OutputFormat)
Converts the image.
public static void Convert(string fromFile, string toFile, int width, int height, OutputFormat format)
Parameters
fromFilestringThe virtual path to the source file.
toFilestringThe virtual path to the destination file.
widthintThe width of the image.
heightintThe height of the image.
formatOutputFormatThe format of the image.
Exceptions
- ConvertException
Thrown when toFile already exists or any of files destinations are not specified
ConvertToFile(string)
Converts the source image according to conversion parameters.
public void ConvertToFile(string filePath)
Parameters
filePathstringThe virtual path to the destination file.
Exceptions
- ConvertException
Thrown when file already exists
GetOutputFileName(ConvertParameters)
Gets the name of the output file.
public static string GetOutputFileName(ConvertParameters convertParameters)
Parameters
convertParametersConvertParametersThe convertParameters.
Returns
OutputFormatFromString(string)
Outputs the format from string.
public static OutputFormat OutputFormatFromString(string format)
Parameters
formatstringThe output format.
Returns
Resize(string, int)
Resizes the image.
public static void Resize(string fromFile, int width)
Parameters
Resize(string, int, int)
Resize the image.
public static void Resize(string fromFile, int width, int height)
Parameters
fromFilestringThe virtual path to the source file.
widthintThe width of the image.
heightintThe height of the image.
Resize(string, int, int, OutputFormat)
Resize the image.
public static void Resize(string fromFile, int width, int height, OutputFormat format)
Parameters
fromFilestringThe virtual path to the source file.
widthintThe width of the image.
heightintThe height of the image.
formatOutputFormatThe format of the image.
Exceptions
- ConvertException
Thrown when file cannot be found
StringFromColorMode(ColorMode)
Strings from color mode.
public static string StringFromColorMode(ColorMode mode)
Parameters
modeColorModeThe mode.
Returns
StringFromOutputFormat(OutputFormat)
Strings from output format.
public static string? StringFromOutputFormat(OutputFormat currentFormat)
Parameters
currentFormatOutputFormatThe format.