In php.net you have examples of how to compress with the extension zip and bzip2.
In the previous bzip2 link, the example compresses a string. Then you can read the file as string. Follow example from php.net adapted to your situation:
<?php
$filename = "./testfile.bz2";
// open file for writing
$bz = bzopen($filename, "w");
// write string to file
//Aqui você coloca o caminho para o seu arquivo, para ser lido pelo file_get_contents
bzwrite($bz, file_get_contents('./team-member.jpg'));
// close file
bzclose($bz);
// open file for reading
$bz = bzopen($filename, "r");
// read 10 characters
echo bzread($bz, 10);
// output until end of the file (or the next 1024 char) and close it.
echo bzread($bz);
bzclose($bz);
?>
You can also zip using the first example, also from php.net.
Thanks bro! I searched php.net but couldn’t find :P
– Gustavo Dias