The punishments prescribed by this chapter can be inflicted only upon a legal conviction in a court having jurisdiction.

R.L.1910, § 2090.