KrOverdulve / eidlib

Native Java e-ID library
MIT License
11 stars 5 forks source link

Help - to get the picture in PHP #5

Closed shamun closed 9 years ago

shamun commented 9 years ago

Using the SDK i get following field:

Hash picture: *P¿aÁ†?y2=....

How can i decode it now into PNG or JPEG? is the has picture is in JPEG? following did not worked.

    if(count($cresult) > 0) {
      $arr = explode("\n", $cresult[0]['card']);
      $encodedPhoto =str_replace("Hash picture: ", "", $arr[18]);
      //header('Content-Type: image/jpeg');
      echo "<img src='data:image/png;base64,{$encodedPhoto}' />";

    } 
KrOverdulve commented 9 years ago

Shamun,

The hash of the picture does not contain the actual picture data but is used for verification purposes. If you want a picture, you can look at the example in https://github.com/KeejOow/eidlib/blob/master/eidlibsamples/src/be/belgium/eid/samples/InformationRetrieval.java.

eID.getIDPhoto()

Returns an IDPhoto object with a number of methods to write the file, get the raw data, convert the file, and so on.

shamun commented 9 years ago

@KeejOow : Thank you. My situation is the picture has to be sent to a server (not the case writeToFile() method).

I checked eID.getIDPhoto() methods which has getImage(), getPhoto(), verifyHash(byte[] hash).

Now, Which method gives me RAW PNG or JPEG data? I have to save that data over GET or POST method to PHP server and then display it to a web-browser.

KrOverdulve commented 9 years ago

Dear,

eID.getIDPhoto().getPhoto() returns a byte array that you can send to the server.

Cheers, Kristof.

On Wed, May 27, 2015 at 9:30 AM, Shamun Toha notifications@github.com wrote:

@KeejOow https://github.com/KeejOow : Thank you. My situation is the picture has to be sent to a server (not the case writeToFile() method).

I checked eID.getIDPhoto() methods which has getImage(), getPhoto(), verifyHash(byte[] hash).

Now, Which method gives me RAW PNG or JPEG data? I have to save that data over GET or POST method to PHP server and then display it to a web-browser.

— Reply to this email directly or view it on GitHub https://github.com/KeejOow/eidlib/issues/5#issuecomment-105798607.

Met vriendelijke groeten, Kristof Overdulve.

shamun commented 9 years ago

OK - Many thanks.

shamun commented 9 years ago

Can you please check why i cant see picture? I tried following but i cant see the picture yet? i used eID.getIDPhoto().getPhoto() and got some value like [B@..... then i used that value but not showing any picture.

<?php
$byteArray = "[B@14a3da8";   //eID.getIDPhoto().getPhoto()  Java SDK returned this value
$byteArray = base64_encode($byteArray); // Try with encode or without
$img = "<img src= 'data:image/jpeg;base64, $byteArray' />";
echo ($img); // Should show the picture now in web browser but nothing is showing.
exit;
?>
KrOverdulve commented 9 years ago

Well .. cause a byte array is a binary structure and what you are posting is the object reference to the full object. It would be one hell of a compression algorithm if an image would be encoded as less than 20 bytes. You can perhaps compute a base64 encoding of the image in Java and then copy that into the PHP byte array.

Cheers, Kristof.

On Wed, May 27, 2015 at 10:00 AM, Shamun Toha notifications@github.com wrote:

Can you please check why i cant see picture? I tried following but i cant see the picture yet? i used eID.getIDPhoto().getPhoto() and got some value like [B@..... then i used that value but not showing any picture.

<?php $byteArray = "[B@14a3da8"; //eID.getIDPhoto().getPhoto() Java SDK returned this value $byteArray = base64_encode($byteArray); // Try with encode or without $img = ""; echo ($img); // Should show the picture now in web browser but nothing is showing. exit; ?>

— Reply to this email directly or view it on GitHub https://github.com/KeejOow/eidlib/issues/5#issuecomment-105809259.

Met vriendelijke groeten, Kristof Overdulve.