Solution 1 : For Windows 2000,2003,XP
1)Create a Python script and compile it.Script Code is given below:
import sys
import Image
import imageop
# open an image file you have in the working folder
im1 = Image.open(sys.argv[1])
str1=im1.mode
print str1
im2=im1.convert("1")
im2.save(sys.argv[1])
str2=im2.mode
print str2
2). Create abatch file and pass Image FileName as a paramter and get the desired result. [Batch File Contents are give n below]
@echo off
c:\python23\python.exe C:\PythonScript\Imaging.py %1
Pause
-- YOU CAN NOW EXECUTE THIS BATCH FILE ON COMMAND LINE AS WELL AS FROM YOUR CODE. --
Solution 2 : (For Windows 98,2000 and 2003 Not for Windows XP)[Less successful option]
1) For converting Colored BITMAP image to Black & White BMP. Just download Image Magic software from
ftp://ftp.fifi.org/pub/ImageMagick/binaries/ImageMagick-6.3.0-7-Q16-windows-static.exe
2)Install it and you will find one file 'Convert.exe'.Run this line from command line by passing valid parameters as shown below:
"C:\Program Files\ImageMagick-6.3.0-Q16\convert.exe" -colors 255,255,255 %1 %2
a) First part specifies the path of convert.exe.
b) '-colors 255,255,255' argument is to convert a Colored BMP to B&W BMP.
c) %1 - Name of file (e.g c:\test.BMP)
d) %2 - Name of same file (e.g c:\test.BMP)
Note : Before running Convert.exe make sure that your BMP file's Color attribute(MSPAINT->Image->Attributes)is set to Color.
Thursday, December 28, 2006
Subscribe to:
Post Comments (Atom)
1 comment:
Hi all,
A BMP document is a type of image file format used for computer and digital graphics. A file extension is a series of letters that appears after the title of a document. It is typically preceded by a period and used to communicate the type of encoding used to create the file. Thanks a lot!
Post a Comment