Browse Source

AnyImageImporter: recognize TIFF files by magic.

pull/461/head
Vladimír Vondruš 6 years ago
parent
commit
fb1452eca6
  1. 6
      doc/changelog.dox
  2. 5
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
  3. 4
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
  4. 1
      src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp
  5. 1
      src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt
  6. BIN
      src/MagnumPlugins/AnyImageImporter/Test/image.tiff

6
doc/changelog.dox

@ -44,6 +44,12 @@ See also:
- Added @ref Math::fmod() (see [mosra/magnum#454](https://github.com/mosra/magnum/pull/454))
@subsection changelog-latest-changes Changes and improvements
@subsubsection changelog-latest-changes-trade Trade library
- Recognizing TIFF file header magic in @ref Trade::AnyImageImporter "AnyImageImporter"
@subsection changelog-latest-buildsystem Build system
- Fixed compilation of the @ref GL library on macOS with ANGLE --- new code

5
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

@ -165,6 +165,11 @@ void AnyImageImporter::doOpenData(Containers::ArrayView<const char> data) {
/* https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header */
else if(Utility::String::viewBeginsWith(data, "\x89PNG\x0d\x0a\x1a\x0a"))
plugin = "PngImporter";
/* http://paulbourke.net/dataformats/tiff/,
http://paulbourke.net/dataformats/tiff/tiff_summary.pdf */
else if(Utility::String::viewBeginsWith(data, "II\x2a\x00") ||
Utility::String::viewBeginsWith(data, "MM\x00\x2a"))
plugin = "TiffImporter";
/* https://github.com/file/file/blob/d04de269e0b06ccd0a7d1bf4974fed1d75be7d9e/magic/Magdir/images#L18-L22
TGAs are a complete guesswork, so try after everything else fails. */
else if([data]() {

4
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h

@ -88,8 +88,8 @@ tries to open the file with it. Supported formats:
- Adobe Photoshop (`*.psd`), loaded with any plugin that provides `PsdImporter`
- Silicon Graphics (`*.sgi`, `*.bw`, `*.rgb`, `*.rgba`), loaded with any
plugin that provides `SgiImporter`
- Tagged Image File Format (`*.tif`, `*.tiff`), loaded with any plugin that
provides `TiffImporter`
- Tagged Image File Format (`*.tif`, `*.tiff` or data with corresponding
signature), loaded with any plugin that provides `TiffImporter`
- Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst` or data with
corresponding signature), loaded with @ref TgaImporter or any other plugin
that provides it

1
src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp

@ -92,6 +92,7 @@ constexpr struct {
{"GIF", "image.gif", nullptr, "GifImporter"},
{"PSD", "image.psd", nullptr, "PsdImporter"},
{"TIFF", "image.tiff", nullptr, "TiffImporter"},
{"TIFF data", "image.tiff", fileCallback, "TiffImporter"},
{"Basis", "rgb.basis", nullptr, "BasisImporter"}
/* Not testing everything, just the most important ones */
};

1
src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt

@ -53,6 +53,7 @@ corrade_add_test(AnyImageImporterTest AnyImageImporterTest.cpp
FILES
gray.jpg
image.exr
image.tiff
pngs.ico
rgb.basis
rgb.hdr

BIN
src/MagnumPlugins/AnyImageImporter/Test/image.tiff

Binary file not shown.
Loading…
Cancel
Save