message: Make ImageFormat::from_extension take an &OsStr
diff: #![allow(clippy::too_many_arguments)]
  use std::convert::TryFrom;
  +use std::ffi::OsStr;
  use std::io;
  use std::io::Read;
  use std::ops::{Deref, DerefMut};
  @@ -66,8 +67,11 @@ pub enum ImageFormat {
  impl ImageFormat {
  /// Return the image format specified by a path's file extension.
  - pub fn from_extension(ext: &str) -> Option<Self> {
  - let ext = ext.to_ascii_lowercase();
  + #[inline]
  + pub fn from_extension<S>(ext: S) -> Option<Self> where S: AsRef<OsStr> {
  + // thin wrapper function to strip generics
  + fn inner(ext: &OsStr) -> Option<ImageFormat> {
  + let ext = ext.to_str()?.to_ascii_lowercase();
  Some(match ext.as_str() {
  "jpg" | "jpeg" => ImageFormat::Jpeg,
  @@ -86,6 +90,9 @@ impl ImageFormat {
  })
  }
  + inner(ext.as_ref())
  + }
  +
  /// Return the image format specified by the path's file extension.
  #[inline]
  pub fn from_path<P>(path: P) -> ImageResult<Self> where P : AsRef<Path> {
  @@ -93,7 +100,6 @@ impl ImageFormat {
  fn inner(path: &Path) -> ImageResult<ImageFormat> {
  let exact_ext = path.extension();
  exact_ext
  - .and_then(|s| s.to_str())
  .and_then(|ext| ImageFormat::from_extension(ext))
  .ok_or_else(|| {
  let format_hint = match exact_ext {
  