Always calculate a valid 3D scale factor, never set the 3D scale factor to -1 because this causes errors when a floating-point file is changed to an integer format file.