It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

convert jpg image to byte

Moderator: Malcolm

convert jpg image to byte

Postby john_zakaria on Tue Mar 08, 2011 2:21 pm

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.
john_zakaria
50+ Club
 
Posts: 60
Joined: Sun Feb 08, 2009 7:29 am

Re: convert jpg image to byte

Postby john_zakaria on Tue Mar 08, 2011 2:49 pm

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]
<?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.';
}
?>


[/PHP
john_zakaria
50+ Club
 
Posts: 60
Joined: Sun Feb 08, 2009 7:29 am


Who is online

Users browsing this forum: No registered users and 0 guests