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 ");
String 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 to be watermarked
Simage = System. Drawing. Image. FromFile (simagefile );
Upimage = System. Drawing. Image. FromStream (upimgfile); // uploaded Image
Width = upimage. Width;
Height = upimage. Height;
If (width> height)
{
Newwidth = 200;
Newheight = (int) (double) height/(double) 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 );