Discussion:
Over zealous translators
(too old to reply)
Dan Pidcock
2004-02-09 11:03:13 UTC
Permalink
If there is a file type that a translator thinks it can handle but it
is not actually capable of handling properly what is the best way of
letting another translator handle it? Is forcing mime types the way
to do it?

This happens with Nikon raw camera files, which have a TIFF thumbnail
inside. The TIFFTranslator must see the TIFF information so decides
it can read the file. However I have a raw translator that can really
read the whole of the file but Identify() of my translator is never
called, even if I increase capability and quality to 1.0.

Thanks,

Dan
Jøhnny Fävòrítê (it means "genetic antagonism")
2004-02-09 16:04:41 UTC
Permalink
Post by Dan Pidcock
If there is a file type that a translator thinks it can handle but it
is not actually capable of handling properly what is the best way of
letting another translator handle it? Is forcing mime types the way
to do it?
This happens with Nikon raw camera files, which have a TIFF thumbnail
inside. The TIFFTranslator must see the TIFF information so decides
it can read the file. However I have a raw translator that can really
read the whole of the file but Identify() of my translator is never
called, even if I increase capability and quality to 1.0.
i'm not really sure how to fix that, but here's what i'd do as a general
approach to try to figure it out.

try writing a translator that definitely isn't going to collide with
anything else first. make up your own bogus image file format, you
don't even have to really "translate" it, just give yourself a clear
shot at the format so you're sure your Identify() will be called.
you'll learn a lot from the exercise, i bet. like maybe there's some
other reason it's not getting called.

after that, yeah, mucking with mime types might help. you could force
your nikon files to have an as-yet-unknown mime type, and declare your
translator as interpreting that type.

maybe somebody else will have a better answer than this. i've never
actually tried writing a translator.
Mark Hellegers
2004-02-09 20:31:55 UTC
Permalink
Post by Dan Pidcock
If there is a file type that a translator thinks it can handle but it
is not actually capable of handling properly what is the best way of
letting another translator handle it? Is forcing mime types the way
to do it?
This happens with Nikon raw camera files, which have a TIFF thumbnail
inside. The TIFFTranslator must see the TIFF information so decides
it can read the file. However I have a raw translator that can really
read the whole of the file but Identify() of my translator is never
called, even if I increase capability and quality to 1.0.
Well, a temporary solution is to move the tiff translator somewhere else. You
won't be able to read any tiff files while you are developing your translator,
but at least you're sure nothing is getting in the way.

I'm not sure why the tiff translator thinks it can read the file, but it
usually has something to do with the first few bytes of the file or the suffix.
If one of those make it look like it is a tiff file, the tiff translator will
pick it up.

Hope that helps,

Mark
Dan Pidcock
2004-02-10 12:18:25 UTC
Permalink
Post by Mark Hellegers
Post by Dan Pidcock
If there is a file type that a translator thinks it can handle but it
is not actually capable of handling properly what is the best way of
letting another translator handle it? Is forcing mime types the way
to do it?
Johnny & Mark: thanks for your replies. My problem is not with
testing my translator - I forced that by moving the TIFFTranslators.
I wanted to know if there was a correct way to override the translator
handling. What I have now done is use filetypes to set the mime type
of the NEF files which seems to be OK. I guess this is the only way
to do it 'properly'.
Post by Mark Hellegers
I'm not sure why the tiff translator thinks it can read the file, but it
usually has something to do with the first few bytes of the file or the suffix.
If one of those make it look like it is a tiff file, the tiff translator will
pick it up.
Yes the NEF files actually have a TIFF header and a TIFF thumbnail
followed by the actual raw image data.

Dan

Continue reading on narkive:
Loading...