Private void Button1_Click (Object Sender, System.Eventargs E)
{
IF (file1.postedfile.filename! = NULL)
{
String namestr = path.GetFileName (file1.postedfile.filename); // Extract file name
File1.postedFile.saveas (Server.Mappath (".") @ "/" Namestr);
Image2.visible = true;
Image2.imageURL = Server.mappath (".") @ "/" Namestr;
System.drawing.Image Image, AnewImage;
Image = system.drawing.Image.fromstream (file1.postedfile.inputstream);
Decimal width = image.width;
Decimal heiGHT = image.height;
Int newwidth, newheight;
IF (Width> Height)
{
NEWWIDTH = 150;
NEWHEIGHT = (INT) (Height / Width * 150);
}
Else
{
NEWHEIGHT = 150;
NEWWIDTH = (int) (Width / Height * 150);
}
ANEWIMAGE = Image.getthumbnailImage (NewWidth, Newheight, Null, INTPTR.ZERO);
Bitmap Output = New Bitmap (AnewImage);
Graphics g = graphics.fromImage (output);
g.drawstring (TextBox1.Text.trim (), New Font ("Courier New", 9), New Solidbrush (Color.Red), 60, 60); // Write copyright information and text format and location
Output.save (Server.mAppath (".") @ "/ s _" namestr, system.drawing.imaging.imageformat.jpeg);
Image1.visible = true;
Image1.imageURL = Server.mappath (".") @ "/ S _" namestr;
}
}