/// Quantize a set of input images, and writes the output.
Quantize a set of input images, and writes the output.
Quantize a set of input images and writes the output .
pub fn quantize<'a, 'b, I, O>(
    input_paths: I,
    output_paths: O,
    colortype: ColorType,
    num_colors: u32,
    verbose: bool,
) -> Result<(), ImageError>
where
    I: Iterator<Item = &'a Path>,
    O: Iterator<Item = &'b Path>,
{
    let images = open_images(input_paths)?;
    let quantization_map =
        quantization_map_from_images_and_color_type(&images, colortype, num_colors, verbose);
    let mut color_combinations = ::std::collections::HashSet::new();
    for color_combination in quantization_map.values() {
        color_combinations.insert(color_combination);
    }
    if verbose {
        println!(
            "{} color combinations in output images",
            color_combinations.len()
        );
    }
    let ordered_color_combinations = order_color_combinations(color_combinations);
    let indexed_quantization_map =
        index_quantization_map(&quantization_map, &ordered_color_combinations);
    let width = images[0].width();
    let height = images[0].height();
    let indexed_image_data = calculate_indexes(images, indexed_quantization_map);
    let (rgb_palettes, alpha_palettes) = calculate_palettes(ordered_color_combinations);
    write_pngs(
        output_paths,
        indexed_image_data,
        rgb_palettes,
        alpha_palettes,
        width,
        height
    )?;
    Ok(())
}
pub fn quantize < ' a , ' b , I , O > ( input_paths : I , output_paths : O , colortype : ColorType , num_colors : u32 , verbose : bool , ) -> Result < ( ) , ImageError > where I : Iterator < Item = & ' a Path > , O : Iterator < Item = & ' b Path > , { let images = open_images ( input_paths ) ? ; let quantization_map = quantization_map_from_images_and_color_type ( & images , colortype , num_colors , verbose ) ; let mut color_combinations = :: std :: collections :: HashSet :: new ( ) ; for color_combination in quantization_map . values ( ) { color_combinations . insert ( color_combination ) ; } if verbose { println ! ( " " color_combinations len ( ) ) ; } let ordered_color_combinations = order_color_combinations ( color_combinations ) ; let indexed_quantization_map = index_quantization_map ( & quantization_map , & ordered_color_combinations ) ; let width = images [ 0 ] . width ( ) ; let height = images [ 0 ] . height ( ) ; let indexed_image_data = calculate_indexes ( images , indexed_quantization_map ) ; let ( rgb_palettes , alpha_palettes ) = calculate_palettes ( ordered_color_combinations ) ; write_pngs ( output_paths , indexed_image_data , rgb_palettes , alpha_palettes , width , height ) ? ; Ok ( ( ) ) }
Quantize a set of input images, and writes the output.
Quantize a set of input images and writes the output .
input_paths
I
output_paths
O
colortype
ColorType
num_colors
u32
verbose
bool