|
|
4.2. Determining Image Properties For the automated presentation building it is sometimes necessary to establish the image properties from under Python code. The following utility performs the necessary image checking. Utility Petronode.CheckImage.exe. Returns to Python an image property: X, Y, file size o number of pixels. Command line application: Check_Image.exe input_file /key     input_file - file to process; one of the following keys is mandatory:     /X - image Width /Y - image Height /S - image file size (bytes) /P - image size (pixels) The following Python script evokes the Clip_Image.exe (can be used inside or outside Techlog) # # Example 10 - checking the image properties # import os import subprocess # # location of Petronode install folder # cBatchProcessorFolder = "C:\\Program Files\\Petronode" # # gets image properties # def Get_Image_Property ( workfolder, input, property="Y"):     Params = [os.path.join( cBatchProcessorFolder, "Petronode.CheckImage.exe")]     Params += [ os.path.join( workfolder, input)]     Params += [ "/" + property.upper()]     return subprocess.call( Params) label = "The file is " label += str( Get_Image_Property( ".", "Test.png", "X")) + "x" label += str( Get_Image_Property( ".", "Test.png", "Y")) + " pixels, " label += str( Get_Image_Property( ".", "Test.png", "S")) + " bytes." print (label) The source image is like this:
The example replies: The file is 200x300 pixels, 2442 bytes. |
|