raw.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package imagetype
  2. import (
  3. "strings"
  4. )
  5. var (
  6. // .RAW file extension list, they may mimic to .TIFF
  7. rawExtensions = map[string]bool{
  8. ".3fr": true,
  9. ".adng": true,
  10. ".arw": true,
  11. ".cap": true,
  12. ".cr2": true,
  13. ".cr3": true,
  14. ".crw": true,
  15. ".data": true,
  16. ".dcr": true,
  17. ".dng": true,
  18. ".eip": true,
  19. ".erf": true,
  20. ".fff": true,
  21. ".gpr": true,
  22. ".iiq": true,
  23. ".k25": true,
  24. ".kdc": true,
  25. ".mef": true,
  26. ".moc": true,
  27. ".mos": true,
  28. ".mdc": true,
  29. ".mrw": true,
  30. ".nef": true,
  31. ".nrw": true,
  32. ".orf": true,
  33. ".ori": true,
  34. ".pef": true,
  35. ".ppm": true,
  36. ".proraw": true,
  37. ".raf": true,
  38. ".raw": true,
  39. ".rw2": true,
  40. ".rwl": true,
  41. ".sr2": true,
  42. ".srf": true,
  43. ".srw": true,
  44. ".x3f": true,
  45. }
  46. // RAW image MIME types (in case extension is missing)
  47. rawMimeTypes = map[string]bool{
  48. "image/x-hasselblad-3fr": true,
  49. "image/x-adobe-dng": true,
  50. "image/x-sony-arw": true,
  51. "image/x-phaseone-cap": true,
  52. "image/x-canon-cr2": true,
  53. "image/x-canon-cr3": true,
  54. "image/x-canon-crw": true,
  55. "image/x-kodak-dcr": true,
  56. "image/x-epson-erf": true,
  57. "image/x-hasselblad-fff": true,
  58. "image/x-gopro-gpr": true,
  59. "image/x-phaseone-iiq": true,
  60. "image/x-kodak-k25": true,
  61. "image/x-kodak-kdc": true,
  62. "image/x-mamiya-mef": true,
  63. "image/x-leaf-mos": true,
  64. "image/x-minolta-mrw": true,
  65. "image/x-nikon-nef": true,
  66. "image/x-nikon-nrw": true,
  67. "image/x-olympus-orf": true,
  68. "image/x-sony-ori": true,
  69. "image/x-pentax-pef": true,
  70. "image/x-apple-proraw": true,
  71. "image/x-fuji-raf": true,
  72. "image/x-raw": true,
  73. "image/x-panasonic-rw2": true,
  74. "image/x-leica-rwl": true,
  75. "image/x-sony-sr2": true,
  76. "image/x-sony-srf": true,
  77. "image/x-samsung-srw": true,
  78. "image/x-sigma-x3f": true,
  79. }
  80. )
  81. // IsRawExtOrMime checks if the given content type or extension belongs to a RAW image format
  82. func IsRawExtOrMime(ct, ext string) bool {
  83. return rawExtensions[strings.ToLower(ext)] || rawMimeTypes[ct]
  84. }