I want to write program with python which can get input from scanner and save as jpg. I don't have any idea how to start. please help.
In Windows, the module you will want to look into is called the Python TWAIN module, while in Linux (and I think Mac) you should look into pysane.
Now that I am digging into this it looks like there is a project called python-imagescanner that tries to wrap these two approaches into a common library,
From imagescanner's documentation
Getting access to a scanner device: from imagescanner import ImageScanner # instantiate the imagescanner obj iscanner = ImageScanner() # get all available devices scanners = iscanner.list_scanners() # choose one of the devices scanner = scanners[0] # scan your file (returns a PIL object) scanner.scan()