Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

Hoping someone can help. We're running PAC's SecureNet software here and i'm trying to tie in a webcam, so that when we take someone's photo, it is already inside the software. Using MS Server Management Studio I can see the photo field. The software currently saves the image as Base64.

 

For our own systems it would be really handy to have access to these images. So I've got a PHP script which can see the PAC database and extra the photo code. I can display this easily enough, although I barely understand it.

 

My problem comes when I try to save the file. It saves a typically 120kb jpg as a 900kb jpg. And it's a jpeg which Word can use but can't be opened in Photoshop?

 

We're about to hand out 300 photo IDs to our sixth form, so I'm trying to streamline this process as much as possible. Here's my code:

  
$data = "data:image/jpeg;base64,".base64_encode($temp_photo);
list($type, $data) = explode(';', $data);
list(, $data)      = explode(',', $data);
$data = base64_decode($data);

$success = file_put_contents($output_file, $data);

 

I've tried using imagecreatefromstring() but I can't seem to pass the correct data. Does anyone have any idea what I'm doing wrong?

Posted

Little bit rough but:

 

$img = imagecreatefromstring(base64_decode($data));  

if($img !== false)  
{
   imagejpg($img,$output_file);  
   imagedestroy($img);   
}

Posted

Thanks Geoff,

 

I've tried your variation and got no where. In the end, I changed the code to save the image as a bmp:

$data = "data:image/wbmp;base64,".base64_encode($temp_photo);

 

Which Photoshop at least allows for import. From there I'm just going to run an action to save the files as jpegs. Utterly annoying and bizarre, but at least it is a relatively efficient workflow.

 

Graham

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...