$file_extension =
strtolower( pathinfo( $this->file, PATHINFO_EXTENSION
) );
if ( 'pdf' ===
$file_extension ) { $pdf_loaded =
$this->
pdf_load_source();
if ( is_wp_error( $pdf_loaded ) ) { return $pdf_loaded;
} } else { if ( wp_is_stream( $this->file
) ) { // Due to reports of issues with streams with `Imagick::readImageFile()`, uses `Imagick::readImageBlob()` instead.
$this->image->
readImageBlob( file_get_contents( $this->file
),
$this->file
);
} else { $this->image->
readImage( $this->file
);
} } if ( !
$this->image->
valid() ) { return new WP_Error( 'invalid_image',
__( 'File is not an image.'
),
$this->file
);
} // Select the first frame to handle animated images properly.
if ( is_callable( array
( $this->image, 'setIteratorIndex'
) ) ) {