Page 1 of 1

Saving image in zzzsys_file

Unread postPosted: Sun Jun 13, 2021 4:15 pm
by slobodan
I tried in php to dynamically change the image of nubuilder's image object. It goes so fine until image transformation for storing into zzz sys_file.sfi_json. I expected that base64_encode and json_encode will do the job, but without success. Have you any suggestion, how to transform image file and store it in zzzzsys_file table? In attached example for testing I used qr table instead zzzzsys_file.

Re: Saving image in zzzsys_file

Unread postPosted: Sun Jun 13, 2021 4:41 pm
by kev1n
I think you need json_encode(), try something like this (untested)

Code: Select all
$arr = array("file"=>base64_encode($binary),
              "name"=>basename($image_name),
              "size"=>$filesize,
              "type"=>"image/png");
             
$json = json_encode($arr);
$sqlStr = "UPDATE qr set file = '$json' WHERE  id = 1";

Re: Saving image in zzzsys_file

Unread postPosted: Thu Jun 17, 2021 1:55 pm
by kev1n
Hi,

Did you manage to transform and save your png?

Re: Saving image in zzzsys_file

Unread postPosted: Mon Jun 28, 2021 8:27 pm
by slobodan
I tried to dynamically manipulate nubuilder image object, to show QR Code with current parameters.
For QR code generation I used qrcode.js, javascript library from GitHub Pages. It shows QR code on form, something like this:
<img style="display: block;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAACwUlEQVR4nO2VQXLkMAwD5/.......+AbIkwWQX1aPAhHMlIN0fTkeJ3oDBCD1MCsFEIBEe8tA3JoOxdVYaabPdR4wQAACkM290vetvFzT06FPz93wDBCAAAQgfwXIFyOtfcgN/hb5AAAAAElFTkSuQmCC">
Then I extracted src from qrcode._oDrawing._elImage.src and converted it with nuBase64encode() function to qistr, which was crucial for success. Then maked jstr = '{"file":"' + qistr + '","name":"filename.png","size":267,"type":"image/png"}' as value for update sfi_json field in zzzzsys_file table.

Re: Saving image in zzzsys_file

Unread postPosted: Mon Jun 28, 2021 8:41 pm
by slobodan
Forget to mention, all that were needed, for showing QR code with current parameters in the report. Whereas nuReport use only nubuilder objects, without any outside help of php or javascript.