Code: Select all
using (MagickImage image = new MagickImage(sourceImagePath))
{
var whiteColor = new MagickColor("#ffffff");
var blackColor = new MagickColor("#000000");
image.BackgroundColor = blackColor;
image.ColorAlpha(blackColor);
image.Format = MagickFormat.Jpg;
image.Quality = 80;
image.AddProfile(ColorProfile.USWebCoatedSWOP); // Add a CMYK profile if your image does not contain a color profile.
image.AddProfile(ColorProfile.SRGB); // Adding the second profile will transform the colorspace from CMYK to RGB
// This "if statement" was missing. This is now the complete code which I have used to generate the .jpg file.
if (newWidth < image.Width)
{
image.Resize(newWidth, 0);
}
image.Write(destinationImagePath);
}
https://ufile.io/qv3jt
https://ufile.io/zxyv4