It feels like some of the data is being cut off somewhere:
@exec('7za.exe" e -so "archive.zip" "img.jpg"', $out);
$out - is a array of bin data $data = implode( "" , $out ); imagecreatefromstring($data); // not working
if added "\r\n" to implode(): $data = implode( "\r\n" , $out ); imagecreatefromstring($data); // creates a distorted image. enter image description here
File is correct, and reading with other functions is normal, but i'm need to use a local 7za.exe, not built-in functions.
exec()
is only meant for programs that output text. Here you need to get binary content, so you should use passthru()
instead.
To capture the result, you will need to use output buffering:
ob_start();
passthru('7za.exe ...');
$data = ob_get_clean();
$im = imagecreatefromstring($data);