return $timestamp;
}
+ /**
+ * Guess the MIME type from the file contents alone
+ *
+ * @return string
+ */
+ public function getMimeType() {
+ return MimeMagic::singleton()->guessMimeType( $this->path, false );
+ }
+
/**
* Get an associative array containing information about
* a file with the given storage path.
# get the file extension
if ( $ext === true ) {
- $i = strrpos( $this->path, '.' );
- $ext = strtolower( $i ? substr( $this->path, $i + 1 ) : '' );
+ $ext = self::extensionFromPath( $this->path );
}
# mime type according to file contents
- $info['file-mime'] = $magic->guessMimeType( $this->path, false );
+ $info['file-mime'] = $this->getMimeType();
# logical mime type
$info['mime'] = $magic->improveTypeFromExtension( $info['file-mime'], $ext );
return $info;
}
+ /**
+ * Exract image size information
+ *
+ * @return Array
+ */
protected function extractImageSizeInfo( array $gis ) {
$info = array();
# NOTE: $gis[2] contains a code for the image type. This is no longer used.
return $hash;
}
+ /**
+ * Get the final file extension from a file system path
+ *
+ * @param $path string
+ * @returns string
+ */
+ public static function extensionFromPath( $path ) {
+ $i = strrpos( $path, '.' );
+ return strtolower( $i ? substr( $path, $i + 1 ) : '' );
+ }
+
/**
* Get an associative array containing information about a file in the local filesystem.
*
*
* @return array
*/
- static function getPropsFromPath( $path, $ext = true ) {
+ public static function getPropsFromPath( $path, $ext = true ) {
$fsFile = new self( $path );
return $fsFile->getProps( $ext );
}
*
* @return false|string False on failure
*/
- static function getSha1Base36FromPath( $path ) {
+ public static function getSha1Base36FromPath( $path ) {
$fsFile = new self( $path );
return $fsFile->getSha1Base36();
}