Function flac::metadata::get_picture [] [src]

pub fn get_picture(filename: &str, picture_type: Option<PictureType>, mime_type: Option<&str>, description: Option<&str>, max_width: Option<u32>, max_height: Option<u32>, max_depth: Option<u32>, max_colors: Option<u32>) -> Result<Picture>

Reads and returns a Picture metadata block of the given FLAC file.

There can be more than one Picture block in a file and this function takes optional, that being Option<T>, parameters that act as constraints to search within. The Picture with the largest area matching all constraints will be returned.

Putting None into any of the optional constraints conveys that you want any of that parameter. Otherwise it will try to look for the image that matches within the given constraints.

Failures

  • ErrorKind::NotFound is returned when the given filename isn't found, there is no Picture within the file, or no Picture that fits the given constraints.
  • ErrorKind::InvalidData is returned when the data within the file isn't valid FLAC data.

Examples

Handling errors might look something like this:

use flac::metadata;
use flac::metadata::PictureType;

let result = metadata::get_picture("path/to/file.flac",
                                   Some(PictureType::FileIcon),
                                   Some("image/gif"),
                                   None, None, None,
                                   None, None);

match result {
  Ok(picture) => {
    // Use the picture variable...
  }
  Err(error)  => println!("{}", error),
}

Or just ignore the errors:

use flac::metadata;
use flac::metadata::PictureType;

let picture = metadata::get_picture("path/to/file.flac",
                                    Some(PictureType::FileIcon),
                                    Some("image/gif"),
                                    None, None, None,
                                    None, None).unwrap();