Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Watermark (string imageUrl)
- {
- Stopwatch watch = new Stopwatch ();
- watch.Start ();
- Console.WriteLine ("Starting process");
- string BASE = Directory.GetCurrentDirectory () + "/Images/";
- WebClient client = new WebClient ();
- byte[] data = client.DownloadData (imageUrl);
- Console.WriteLine ("Elapsed: " + watch.ElapsedMilliseconds);
- using (Image image = Image.FromStream (new MemoryStream (data)))
- using (Image watermark = Image.FromFile (BASE + "watermark.png"))
- using (Graphics graphics = Graphics.FromImage (image))
- using (Brush brush = new TextureBrush (watermark)) {
- int x = (image.Width - watermark.Width)/2;
- int y = (image.Height - watermark.Height)/2;
- graphics.FillRectangle(brush, new Rectangle(new Point(x, y), watermark.Size));
- image.Save(BASE + "norma_watermarked.jpg");
- }
- watch.Stop ();
- Console.WriteLine ("Process ended: " + watch.ElapsedMilliseconds);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement