Get pixel dimensions
Add args to input width and height of the image
This commit is contained in:
@@ -1,8 +1,26 @@
|
||||
from pcbdevice.utils.path import path
|
||||
from pcbdevice.utils.plotimg import plotPath
|
||||
from pcbdevice.utils.FileUtils import FileUtils
|
||||
import argparse
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(prog = 'main.py')
|
||||
parser.add_argument('-i', required = True, help = 'PCB image path')
|
||||
parser.add_argument('-wi', required = True, type = int, help = 'Width of the PCB')
|
||||
parser.add_argument('-he', required = True, type = int, help = 'Height of the PCB')
|
||||
parser.add_argument('-u', required = False, help = 'PCB dimension unit')
|
||||
args = parser.parse_args()
|
||||
|
||||
matrix, height, width = FileUtils.pbmToMatrix(args.i)
|
||||
|
||||
if args.u:
|
||||
pxHeight, pxWidth = FileUtils.getPixelSize(height, width, args.he, args.wi, unit = args.u)
|
||||
else:
|
||||
pxHeight, pxWidth = FileUtils.getPixelSize(height, width, args.he, args.wi)
|
||||
|
||||
|
||||
print(pxHeight, pxWidth)
|
||||
|
||||
# Usage example
|
||||
|
||||
resourcesRawPath = 'tests/resources/raw/'
|
||||
@@ -10,6 +28,6 @@ if __name__ == "__main__":
|
||||
resourcesPathOutput = 'resources/pathoutput/'
|
||||
resourcesExpectedPath = 'tests/resources/expected/'
|
||||
|
||||
FileUtils.saveMatrixToFile(FileUtils.pbmToCsv(resourcesRawPath + 'test1ascii.pbm'), resourcesFormattedPath + 'test1.csv')
|
||||
#FileUtils.saveMatrixToFile(FileUtils.pbmToMatrix(resourcesRawPath + 'test1ascii.pbm'), resourcesFormattedPath + 'test1.csv')
|
||||
|
||||
plotPath(path(FileUtils.pbmToCsv(resourcesRawPath + 'test100x100.pbm'), 5))
|
||||
#plotPath(path(FileUtils.pbmToMatrix(resourcesRawPath + 'test100x100.pbm'), 5))
|
||||
Reference in New Issue
Block a user