Add watermark and shrink images only if fort
This commit is contained in:
parent
63654bdcf9
commit
52d5467b85
@ -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);
|
||||
}
|
||||
|
||||
@ -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,6 +96,8 @@ namespace ManagerService.Helpers
|
||||
currentImage = resizedImage;
|
||||
}
|
||||
|
||||
if(watermark)
|
||||
{
|
||||
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));
|
||||
@ -107,6 +109,7 @@ namespace ManagerService.Helpers
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
graphics.DrawString("fortsaintheribert.be", font, brush, point, stringFormat);
|
||||
}
|
||||
}
|
||||
|
||||
using (MemoryStream updatedImageMemorySteam = new MemoryStream())
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user