Hi, I have .net 5 proyect and I am ussing spire office 9.2.
I am trying to resize and image, using the code below:
var placeHolder = document.FindStringInLine("{CompanyLogo}", false, false).FirstOrDefault();
var pictureContainer = placeHolder.GetAsOneRange().OwnerParagraph;
pictureContainer.Replace(new Regex("{CompanyLogo}"), "");
if (!string.IsNullOrEmpty((company.Logo ?? "").Trim()))
{
var bytes = await _fileStorage.FileToArray(company.Logo.Trim());
if (bytes.Length > 0)
{
var picture = pictureContainer.AppendPicture(bytes);
_logger.LogWarning($"{picture}");
picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
picture.HorizontalAlignment = ShapeHorizontalAlignment.Center;
_logger.LogWarning($"{picture.Width} - {picture.Height}");
//Scale picture to fit 200 width
if (picture.Width > 200)
{
//picture.Height = 200 * 100 / picture.Width;
//picture.Width = 200 * 100 / picture.Width;
picture.SetScale(200 * 100 / picture.Width, 200 * 100 / picture.Width);
//picture.WidthScale = 200 * 100 / picture.Width;
//picture.HeightScale = picture.WidthScale;
}
_logger.LogWarning($"{picture.Width} - {picture.Height}");
}
}
I upload the image I am using in the attached file.
The problem is: when I try the code on my local computer (Windows), the image resize is done fine,
but when I try to resize the image on a Ubuntu server, the image resize doesn't happen.
Does, because the width of the image and the height of the image it get is 0.