cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Create Image from binary file

Yoshihiko.N
14-Alexandrite

Create Image from binary file

Hi Developers,

I'm trying to create the following functions.

1. save image file to SQL as binary data.
2. pull binary data from SQL.

3. create Image contents from the binary data to display on mashup.

 

I'm struggling to create codes for part 3.


Could anyone help me for the part3?

 

 

YoshihikoN_1-1696221863880.png

 

 

ACCEPTED SOLUTION

Accepted Solutions
Velkumar
19-Tanzanite
(To:Yoshihiko.N)

Hi @Yoshihiko.N 

 

You are trying to convert base64/binary data again to base64 string

 

Output from LoadBinary can be directly viewed as an Image

let result = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

 

Velkumar_2-1696228622467.png

 

In your use case :

// Image binary string
let data = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

// Write service to store data in DB

// Query data from DB 
// For example : input dbString will be data from the DB
var result = dbString;

 

Velkumar_3-1696229301184.png

 

/VR

 

View solution in original post

3 REPLIES 3
Velkumar
19-Tanzanite
(To:Yoshihiko.N)

Hi @Yoshihiko.N 

 

Set the result output type to Image

Velkumar_0-1696224137845.png

More Information - 

Solved: Convert base64 code to image - PTC Community

 

/VR

 

 

 

Yoshihiko.N
14-Alexandrite
(To:Velkumar)

Hi 
Thank you for your quick response.
I tried but failed.

YoshihikoN_0-1696227226317.png

 

Velkumar
19-Tanzanite
(To:Yoshihiko.N)

Hi @Yoshihiko.N 

 

You are trying to convert base64/binary data again to base64 string

 

Output from LoadBinary can be directly viewed as an Image

let result = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

 

Velkumar_2-1696228622467.png

 

In your use case :

// Image binary string
let data = Things["SystemRepository"].LoadBinary({
	path: "/images.png" /* STRING */
});

// Write service to store data in DB

// Query data from DB 
// For example : input dbString will be data from the DB
var result = dbString;

 

Velkumar_3-1696229301184.png

 

/VR

 

Announcements


Top Tags