diff --git a/ManagerService/Controllers/ResourceController.cs b/ManagerService/Controllers/ResourceController.cs index f36303d..40e2087 100644 --- a/ManagerService/Controllers/ResourceController.cs +++ b/ManagerService/Controllers/ResourceController.cs @@ -242,8 +242,14 @@ namespace ManagerService.Controllers { file.CopyTo(ms); var fileBytes = ms.ToArray(); - if (resourceType == ResourceType.Image) { - fileBytes = ImageHelper.ResizeAndAddWatermark(fileBytes, MaxWidth, MaxHeight); + if (resourceType == ResourceType.Image) + { + bool isFort = instanceId == "633ee379d9405f32f166f047"; // If fort saint heribert, TODO add watermark in configuration and model + + if(isFort) // TODO We need to know for which purpose (mobile or tablet) + { + fileBytes = ImageHelper.ResizeAndAddWatermark(fileBytes, isFort, MaxWidth, MaxHeight); + } } stringResult = Convert.ToBase64String(fileBytes); } diff --git a/ManagerService/Helpers/ImageHelper.cs b/ManagerService/Helpers/ImageHelper.cs index 30c5508..2e71bbe 100644 --- a/ManagerService/Helpers/ImageHelper.cs +++ b/ManagerService/Helpers/ImageHelper.cs @@ -79,7 +79,7 @@ namespace ManagerService.Helpers return convertedToBytes; } - public static byte[] ResizeAndAddWatermark(Byte[] bytes, int maxWidth, int maxHeight) + public static byte[] ResizeAndAddWatermark(Byte[] bytes, bool watermark, int maxWidth, int maxHeight) { byte[] convertedToBytes; @@ -96,16 +96,19 @@ namespace ManagerService.Helpers currentImage = resizedImage; } - Font font = new Font("Arial", 25, FontStyle.Italic, GraphicsUnit.Pixel); - Color color = Color.DarkBlue; - Point point = new Point(currentImage.Width /2, (int)Math.Round(currentImage.Height - currentImage.Height * 0.1)); - SolidBrush brush = new SolidBrush(color); - using (Graphics graphics = Graphics.FromImage(currentImage)) + if(watermark) { - StringFormat stringFormat = new StringFormat(); - stringFormat.Alignment = StringAlignment.Center; - stringFormat.LineAlignment = StringAlignment.Center; - graphics.DrawString("fortsaintheribert.be", font, brush, point, stringFormat); + Font font = new Font("Arial", 25, FontStyle.Italic, GraphicsUnit.Pixel); + Color color = Color.DarkBlue; + Point point = new Point(currentImage.Width /2, (int)Math.Round(currentImage.Height - currentImage.Height * 0.1)); + SolidBrush brush = new SolidBrush(color); + using (Graphics graphics = Graphics.FromImage(currentImage)) + { + StringFormat stringFormat = new StringFormat(); + stringFormat.Alignment = StringAlignment.Center; + stringFormat.LineAlignment = StringAlignment.Center; + graphics.DrawString("fortsaintheribert.be", font, brush, point, stringFormat); + } } using (MemoryStream updatedImageMemorySteam = new MemoryStream())