allow filenames with arbitrary suffixes

  • Illtud Daniel

    Illtud Daniel - 2013-10-30


    Currently getImageType just looks at the file suffix to determine tiff/jp2. We've got files in a respository, which renames datastreams to a format like: "llgc-id_3891196+access+access.0".

    We can patch the code, but that's not very sustainable.

    Two approaches that getImageType could use:

    • ImageMagick or similar to try and work out what type it is (probably expensive, new dependency)
    • File magic numbers
      first bytes of jpeg2000 are: '0000 000C 6A50 2020 0D0A 870A'
      first bytes of tiff are either : '49 49 2A 00' or '4D 4D 00 2A'

    Or there could be an override param that forces a particular type, regardless of filename?

    Any comments?

  • Ruven

    Ruven - 2013-10-31

    File magic numbers are I think the way to go here. Maybe there's some code we can hack out of the linux "file" utility to do this? Where did you get these first byte sequences from?

  • Illtud Daniel

    Illtud Daniel - 2013-11-04

    Sorry, that anonymous post was me, I didn't notice I wasn't logged in.

  • Illtud Daniel

    Illtud Daniel - 2013-11-04

    ...and of course, you won't get that anonymous post until somebody moderates it, so I'm apologising in advance...

  • Ruven

    Ruven - 2013-11-08

    OK, I'll take a look at this and see how best to integrate this into the server.

  • Ruven

    Ruven - 2014-07-19

    OK guys, I've just uploaded new code to github, which implements magic number signature format testing for image files. So, there are no longer any restrictions on how images are named!



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks