Le fichier Rust de l'exemple « Le profil ICC embarqué ».
Le profil ICC que la bibliothèque embarque dans un fichier PDF/A.
Rust
35 lignes
À quoi sert cet exemple
Cette entrée est un fichier à télécharger, pas une page à regarder. Un fichier destiné à l'archivage est obligé de contenir un profil de couleur décrivant l'appareil pour lequel ses couleurs ont été choisies, et la réponse habituelle consiste à livrer celui de quelqu'un d'autre : une centaine de kilooctets ou plus, avec une licence attachée, recopiés dans chacun de vos documents.
Ce que montre cet exemple
Un profil sRVB complet bâti par la bibliothèque, non livré avec elle.
Le profil que reçoit tout fichier PDF/A quand on n'en indique aucun.
Un téléchargement plutôt qu'une page : examinez-le avec un logiciel spécialisé. Seule la bibliothèque l'écrit, et aucune requête au serveur ne renvoie ce fichier.
//! Writes the ICC profile the library embeds in a PDF/A file.//!//! Our own tests can only say the bytes look right to us. Whether they are an//! ICC profile — and whether that profile is really sRGB rather than something//! wearing its name — is a question for a colour engine, which is what//! `scripts/check_icc_profile.py` uses this for.//!//! Usage: `cargo run --example write_icc -- tmp/srgb.icc`usestd::env;usestd::fs;usestd::path::Path;#[path = "shared/failure.rs"]modfailure;fnmain()->std::process::ExitCode{failure::reported(run())}fnrun()->Result<(),Box<dynstd::error::Error>>{letout=env::args().nth(1).unwrap_or_else(||"tmp/srgb.icc".to_owned());letprofile=hqf_pdf::color::icc::srgb();ifletSome(parent)=Path::new(&out).parent(){fs::create_dir_all(parent)?;}fs::write(&out,&profile)?;println!("wrote {out}: {} bytes",profile.len());Ok(())}