hello everyone…
please i want to know how i can convert my *.jpg image into bytes ??
i am searching online and i did not get any module or example that can solve this problem.
hello everyone…
please i want to know how i can convert my *.jpg image into bytes ??
i am searching online and i did not get any module or example that can solve this problem.
<?php
$array = array();
foreach(str_split(file_get_contents('image.jpg')) as $byte){
array_push($array, ord($byte));
}
in the following example there is a text that is converted to image all that i need is to make the opposite.
i have an image and i want to get the string like the variable $data
<?php
$data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
. 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
. 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
. '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data = base64_decode($data);
$im = imagecreatefromstring($data);
if ($im !== false) {
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
else {
echo 'An error occurred.';
}
?>