Can anyone guide how to generate image from input text. Image might have any extension doesn't matter.
Can you please specify a little more information? Does your question concern a programming language, e.g. Java?
I would suggest creating a PDF and then rendering that PDF so it can be saved as a image.
For Java I can suggest you:
Creating PDFs: http://itextpdf.com/
Rendering PDFs: https://pdf-renderer.dev.java.net/
use imagemagick for rendering text on images (on the server)
Since you are in C# you could also use the .Net classes for bitmap and font manipulation directly (with the classes like: System.Drawing.Bitmap and System.Drawing.Graphics)
Ok, assuming you want to draw a string on an image in C#, you are going to need to use the System.Drawing namespace here:
private Image DrawText(String text, Font font, Color textColor, Color backColor)
{
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(0, 0);
Graphics drawing = Graphics.FromImage(img);
//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);
//free up the dummy image and old graphics object
img.Dispose();
drawing.Dispose();
//create a new image of the right size
img = new Bitmap((int) textSize.Width, (int)textSize.Height);
drawing = Graphics.FromImage(img);
//paint the background
drawing.Clear(backColor);
//create a brush for the text
Brush textBrush = new SolidBrush(textColor);
drawing.DrawString(text, font, textBrush, 0, 0);
drawing.Save();
textBrush.Dispose();
drawing.Dispose();
return img;
}
This code will measure the string first, and then create an image of the correct size.
If you want to save the return of this function, just call the Save method of the returned image.