Any person who wilfully transports or confines or causes to be transported or confined any domestic animal or animals in a manner, posture or confinement that will jeopardize the safety of the animal or the public shall be guilty of a misdemeanor. And whenever any such person shall be taken into custody or be subject to arrest pursuant to a valid warrant therefor by any officer or authorized person, such officer or person may take charge of the animal or animals; and any necessary expense thereof shall be a lien thereon to be paid before the animal or animals may be recovered; and if the expense is not paid, it may be recovered from the owner of the animal or the person guilty.