I'm working with a large number of historical image files and am playing around with extracting dominant colours, faces, etc. with Mathematica 10. Occasionally, however, I am running into files that just plain out break the language - i.e. even Import[file,"Elements"]
leads me to have to quit the kernel to get things going again.
Here's the workflow.
Often Import[file]
will return
Import::fmterr : Cannot import data as GIF format.>>
So far so good.
But if you run it again, the whole kernel comes crashing down. Even if I decide not to run it again, things become unstable and the program begins to hang. The same context happens with Import[file,"Elements"]
so I'm at a loss of how to debug it.
Is there any way to get Mathematica to skip these files - or any clue of what might be happening?
File here: https://www.dropbox.com/s/7x5qxlp6ybiqbxu/broken-image.gif
Screenshot of file in OS X preview:
In case it helps, here's the overall context of what I'm doing:
SetDirectory["/volumes/lacie/geocities-images/athens/"];
files = FileNames["*.*"];
hue = Reap[
Do[input = Import[files[[x]]];
Sow[If[Length[input] == 0, ImageMeasurements[input, "Mean"],
ImageMeasurements[input[[1]], "Mean"]]], {x, 1,
Length[files]}]];
This crashes when it hits the 'broken-image' GIF and needs to be restarted.
for a in *.gif;do echo $a && convert $a $a.jpg; done
- which converts the GIFs to JPGs and Mathematica imports them fine. But ideally there's be a native solution? Perhaps this question is far too specific.. :) $\endgroup$