using admin functions on frontend

Put the following line before using the function.

require_once( ABSPATH . '/wp-admin/includes/image.php' );