This commit is contained in:
Louis Dalibard 2024-12-24 16:28:52 +01:00
parent ca28ac4982
commit 2742333c12

View File

@ -22,16 +22,18 @@ mainProcess (polarity,primaryScaleDark,primaryScaleLight, input, output) = do
setStdGen $ mkStdGen 0
image <- loadImage input
palette <- evolve (polarity, primaryScaleDark, primaryScaleLight, convertRGB8 image)
palette <- evolve (polarity, convertRGB8 image)
let outputTable = makeOutputTable $ V.map lab2rgb palette
writeFile output $ encode outputTable
putStrLn $ "Saved to " ++ output
parseArguments :: [String] -> Either String (String, String, String)
parseArguments [polarity, input, output] = Right (polarity, input, output)
parseArguments [_, _] = Left "Please specify an output file"
parseArguments [_] = Left "Please specify an image"
parseArguments :: [String] -> Either String (String, Float,Float,String, String)
parseArguments [polarity, primaryScaleDark, primaryScaleLight,input, output] = Right (polarity,primaryScaleDark, primaryScaleLight, input, output)
parseArguments [_, _,_,_] = Left "Please specify an output file"
parseArguments [_, _,_] = Left "Please specify an image"
parseArguments [_, _] = Left "Please specify a primary scaling factor for the light polarity"
parseArguments [_] = Left "Please specify a primary scaling factor for the dark polarity"
parseArguments [] = Left "Please specify a polarity: either, light or dark"
parseArguments _ = Left "Too many arguments"