Asp.net is an example of how to generate a thumbnail and add a watermark to the original image.
This document describes how to use asp.net to generate thumbnails and add watermarks to original images. We will share this with you for your reference. The details are as follows:
Using System. IO; using System. drawing. imaging; private void button#serverclick (object sender, System. eventArgs e) {Graphics g = null; System. drawing. image upimage = null; System. drawing. image thumimg = null; System. drawing. image simage = null; Bitmap outputfile = null; try {string extension = Path. getExtension (File1.PostedFile. fileName ). toUpper (); string filename = DateTime. now. toString ("yyyyMMddhhmmss"); s Tring smallpath = Server. mapPath (". ") +"/smallimg/"; string bigpath = Server. mapPath (". ") +"/bigimg/"; int width, height, newwidth, newheight; System. drawing. image. getThumbnailImageAbort callb = new System. drawing. image. getThumbnailImageAbort (ThumbnailCallback); if (! Directory. Exists (smallpath) Directory. CreateDirectory (smallpath); if (! Directory. exists (bigpath) Directory. createDirectory (bigpath); Stream upimgfile = File1.PostedFile. inputStream; string simagefile = Server. mapPath ("a8logo.jpg"); // The file simage = System. drawing. image. fromFile (simagefile); upimage = System. drawing. image. fromStream (upimgfile); // The uploaded image width = upimage. width; height = upimage. height; if (width> height) {newwidth = 200; newheight = (int) (double) height/(doub Le) width * (double) newwidth);} else {newheight = 200; newwidth = (int) (double) width/(double) height * (double) newheight );} thumimg = upimage. getThumbnailImage (newwidth, newheight, callb, IntPtr. zero); outputfile = new Bitmap (upimage); g = Graphics. fromImage (outputfile); g. drawImage (simage, new Rectangle (upimage. width-simage.Width, upimage. height-simage.Height, upimage. width, upimage. height), 0, 0, upimage. width, Upimage. height, GraphicsUnit. pixel); string newpath = bigpath + filename + extension; // original graph path string thumpath = smallpath + filename + extension; // thumbnail path outputfile. save (newpath); thumimg. save (thumpath); outputfile. dispose ();} catch (Exception ex) {throw ex;} finally {if (g! = Null) g. Dispose (); if (thumimg! = Null) thumimg. Dispose (); if (upimage! = Null) upimage. Dispose (); if (simage! = Null) simage. Dispose () ;}} public bool ThumbnailCallback () {return false ;}