use cmx::profile::DisplayProfile;
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let input = std::env::args().nth(1).ok_or_else(|| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"usage: set_intent <input-icc-file>",
)
})?;
let in_profile = DisplayProfile::read(&input)?;
let out_profile =
in_profile.with_rendering_intent(cmx::tag::RenderingIntent::RelativeColorimetric);
println!("{out_profile}");
let input_path = std::path::Path::new(&input);
let stem = input_path
.file_stem()
.unwrap_or_else(|| std::ffi::OsStr::new("output"));
let ext = input_path
.extension()
.and_then(|e| e.to_str())
.unwrap_or("icc");
let out_path =
input_path.with_file_name(format!("{}-relative.{}", stem.to_string_lossy(), ext));
let out_path = out_path.to_string_lossy().into_owned();
out_profile.write(&out_path)
}