c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

main.rs (1848B)


      1 // Copyright 2022 Adobe. All rights reserved.
      2 // This file is licensed to you under the Apache License,
      3 // Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
      4 // or the MIT license (http://opensource.org/licenses/MIT),
      5 // at your option.
      6 
      7 // Unless required by applicable law or agreed to in writing,
      8 // this software is distributed on an "AS IS" BASIS, WITHOUT
      9 // WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
     10 // implied. See the LICENSE-MIT and LICENSE-APACHE files for the
     11 // specific language governing permissions and limitations under
     12 // each license.
     13 
     14 //! This generates a set of test images with a wide variety of configurations
     15 //! To run this, use the following command in a terminal
     16 //! cargo run --release --bin make_test_images
     17 mod compare_manifests;
     18 mod make_test_images;
     19 mod make_thumbnail;
     20 use anyhow::{Context, Result};
     21 
     22 fn main() -> Result<()> {
     23     let args: Vec<String> = std::env::args().collect();
     24     let config = if args.len() > 2 {
     25         make_test_images::Config {
     26             alg: "ps256".to_owned(),
     27             tsa_url: None,
     28             output_path: "target/images".to_owned(),
     29             default_ext: "jpg".to_owned(),
     30             author: None,
     31             recipes: Vec::new(),
     32             compare_folders: Some([args[1].clone(), args[2].clone()]),
     33         }
     34     } else {
     35         let path = if args.len() > 1 {
     36             args[1].as_ref()
     37         } else {
     38             "make_test_images/tests.json"
     39         };
     40         let buf = std::fs::read_to_string(path).context(format!("Reading {path}"))?;
     41         let config: make_test_images::Config =
     42             serde_json::from_str(&buf).context("Config file format error")?;
     43         config
     44     };
     45 
     46     // set RUST_LOG=debug to get detailed debug logging
     47     env_logger::init();
     48 
     49     make_test_images::MakeTestImages::new(config).run()?;
     50 
     51     Ok(())
     52 }