|
|
file --mime /dev/null >/dev/null 2>/dev/null | file --mime /dev/null >/dev/null 2>/dev/null |
if [ $? -eq 0 ]; then | if [ $? -eq 0 ]; then |
# Now that we know the --mime option exists, use it. | # Now that we know the --mime option exists, use it. |
mimeType=`file --mime "$1" | cut -d: -f2-` |
mimeType=`file --mime "$1" | cut -d: -f2- | cut -c2-` |
else | else |
# file --mime failed; we don't know why, but we assume it's because it | # file --mime failed; we don't know why, but we assume it's because it |
# is a traditional 'file' program that doesn't have a --mime option. | # is a traditional 'file' program that doesn't have a --mime option. |
|
|
case "$1" in | case "$1" in |
| |
image/jpeg ) | image/jpeg ) |
type = "jfif" |
type="jfif" |
;; | ;; |
image/gif ) | image/gif ) |
type = "gif" |
type="gif" |
;; | ;; |
image/tiff ) | image/tiff ) |
type = "tiff" |
type="tiff" |
;; | ;; |
image/bmp ) | image/bmp ) |
type = "bmp" |
type="bmp" |
;; | ;; |
image/png ) | image/png ) |
type = "png" |
type="png" |
;; | ;; |
image/x-portable-bitmap | image/x-portable-pixmap | \ | image/x-portable-bitmap | image/x-portable-pixmap | \ |
image/x-portable-greymap) | image/x-portable-greymap) |
type = "pnm" |
type="pnm" |
;; | ;; |
image/x-xpm ) | image/x-xpm ) |
type = "xpm" |
type="xpm" |
;; | ;; |
* ) | * ) |
filetype=unknown | filetype=unknown |
|
|
| |
setMimeType "$file" | setMimeType "$file" |
| |
typeDescription=`file "$file" | cut -d: -f2-` |
typeDescription=`file "$file" | cut -d: -f2- | cut -c2` |
| |
determineType "$file" "$mimeType" "$typeDescription" "$fileExtension" | determineType "$file" "$mimeType" "$typeDescription" "$fileExtension" |
| |