Hi! I do not know if it helps you, but processing binary data with MySQL or MariaDB server and Perl's DBI can be tricky due to limitation of MySQL protocol. Some details I wrote to the DBD::MariaDB documentation:
https://metacpan.org/pod/DBD::MariaDB#Working-with-binary-data