Thanks a lot! This looks much better. I have made one alteration.
This code still uses the width style property but when set to zero it does not.
Change this:
$out .= '<img src="'.nggallery::get_thumbnail_url($image->pid).'" style="width:'.$options[$number]['width'].'px;height:'.$options[$number]['height'].'px;" title="'.$image->alttext.'" alt="'.$image->alttext.'" />';
to this:
$zerowidth = ($options[$number]['width']=='0') ? '' : 'width:'.$options[$number]['width'].'px;';
$out .= '<img src="'.nggallery::get_thumbnail_url($image->pid).'" style="'.$zerowidth.'height:'.$options[$number]['height'].'px;" title="'.$image->alttext.'" alt="'.$image->alttext.'" />';