Not sure of the line number because it used to be line 66.
But this error is usually caused by not having a defined Image library program in the ubb control panel.
There are several placed to declare either GD2 or imagemagick.
What version UBB are you using?
Has this been working before or is this the first attempt to use the gallery?