I am unable to change text added to an image to red if the image is tiff.
201700001234_B_6.zip (39.4 KB)
Here is my code
try
{
if (File.Exists(file))
{
var testFile = newFile.Replace("jpeg", "tiff");
var newTestfile = testFile;
var newTiff = file.Replace("jpeg", "tiff");
using (var image = Image.Load(newTiff))
{
Graphics graphics = new Graphics(image);
float fontSize = 12;
Font font = new Font("Arial", fontSize, FontStyle.Bold);
StringFormat format = new StringFormat();
Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Color.Black);
if (rectsCount == 0)
{
graphics.DrawString(text, font, brush, (float)x, (float)y, format);
}
else
{
graphics.DrawString(text, font, brush, (float)x, (float)y - 17, format);
}
using (var stream = new MemoryStream())
{
image.Save(stream);
File.WriteAllBytes(newTestfile, stream.ToArray());
}
}
}
else
{
Debug.WriteLine("File does not exist");
}
}
catch (Exception e)
{
Serilog.Log.Error(e, $"There has been an exception {e.Message}");
}