On the application of the owner and on satisfactory proof of his ownership of the property, after reasonable notice and opportunity to be heard has been given to the person from whom custody of the property was taken and any other person as required by the magistrate, the magistrate before whom the complaint is laid, or who examines the charge against the person accused of stealing or embezzling it, shall order it to be delivered, without prejudice to the state, to the owner, on his paying the necessary expenses incurred in its preservation, to be certified by the magistrate. The order entitles the owner to demand and receive the property.