file crop: add type check, fix a bug