Lazarus 0.9.27 beta here
As far as I can see, it seems something related to layer size. When loading a new image, TImageLayer.Resize is called, but NewWidth and NewHeight are 0, so you get an error in the fillchar call.

Just an advice: when debugging a project in Lazarus, it is useful to activate code checks (Project->Compiler options->Code->Checks[-Ci, -Cr, -Co, -Ct, -CR]) and debug infos (Project->Compiler options->Linking->Debugging[-g, -gl]), that in your project are disabled. With debug infos you can step over your code, so it is easier to debug