# Hexadecimal-\> file (jpg) / how to convert?

**URL:** <https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200>\
**Category:** Coding Questions\
**Created:** [September 25, 2019, 11:46am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200 "2019-09-25T11:46:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [September 25, 2019, 11:46am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/1 "2019-09-25T11:46:42Z")

</div>

Hexadecimal-\> file (jpg)  
Link: [Hex to file (binary) converter](https://tomeko.net/online_tools/hex_to_file.php?lang=en)

Good morning. I want to convert the HEX value into a jpg file,

> Pimage img;

I want to put a jpg file in the img variable and display it on the screen.

Does anyone know how to convert?

FILE LINK : [HEX\_CAMERA - Google Drive](https://drive.google.com/drive/folders/1rhQzGZZEryEzlxKUwgKbeSdSVcbO1lH5)

1. jpg file
2. jpg hex file

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 27, 2019, 1:37am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/2 "2019-09-27T01:37:26Z")

</div>

we had the question already the other way,  
have a picture and store its pix / color info in HEX text to a file.

so if you have a HEX text file and want read that in processing  
and construct a picture from it there is the need to know  
what the values ( and the file structure ) mean?

-a-

```auto
FFD8FFFE0024462679BB000000000000, 
000000000000000000F0004001080032, 

```

the file has a structure with lines and ,  
possibly that means nothing and can be ignored while reading?

-b- 6 char could be 3 byte numbers lets say of R G B value for one pix?

```auto
FFD8FF

```

as ASCII text to bytes **_[255]_ _[216]_ _[255]_**

```auto
pix[0] = color( 255,216,255);

```

-c- but to make a picture from that would still need a additional information  
what is the width of the picture in pix? like where the next line starts.

-d- you posted a picture with the dim. 320 \* 240  
-d1- is that the original you used to make the HEX text file from? and how you did that ?  
-d2- is that the dim info you want use to reconstruct it?

-e- you see, if that is a coding / decoding question  
that even without any encryption used,  
it is already difficult without add information.

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [September 27, 2019, 2:09am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/3 "2019-09-27T02:09:20Z")

</div>

@kll

Thank you for your interest.

Answer 1: Picture width: 320x240  
Answer 2: I received data from mcu through a serial camera.  
Answer 3: I know it is in jpg codec.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 27, 2019, 2:26am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/4 "2019-09-27T02:26:50Z")

</div>

processing can not decode jpg codec easily,  
so do the same as the

> [Hex to file (binary) converter](http://tomeko.net/online_tools/hex_to_file.php)

converter does,

- ignoring ‘,’ and lines
- take 2 char make one byte

and try to save it to a jpg file in binary.

> **[saveBytes() / Reference](https://processing.org/reference/saveBytes_.html)**
>
> As the opposite of loadBytes(), this function will write an entire array of bytes to a file. The data is saved in binary format. This file is saved to the sketch's folder, which is opened by se…

and reload that as a image

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [September 27, 2019, 2:43am UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/5 "2019-09-27T02:43:20Z")

</div>

@kll

thank you. Thanks to you.  
thank you very much.

![tt](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/26d6e9c240b094efac5b6121aaf7c50ae51c7a55.jpeg)

---

<div class="post-metadata">

**Author:** ![GWAK](https://avatars.discourse-cdn.com/v4/letter/g/13edae/32.png) [@GWAK](https://discourse.processing.org/u/GWAK)\
**Post date:** [November 10, 2019, 8:34pm UTC](https://discourse.processing.org/t/hexadecimal-file-jpg-how-to-convert/14200/6 "2019-11-10T20:34:25Z")

</div>

@kll

Thanks to you for finishing the project.

VIDEO :  
[https://serviceapi.nmv.naver.com/flash/convertIframeTag.nhn?vid=895ABC927F98438CEB16AED3A3ADBF9AEA7F&outKey=V1243470d17493faa3fde56e9be4b1ee33e3d1c9f79a830dc51b956e9be4b1ee33e3d&width=544&height=306](https://serviceapi.nmv.naver.com/flash/convertIframeTag.nhn?vid=895ABC927F98438CEB16AED3A3ADBF9AEA7F&outKey=V1243470d17493faa3fde56e9be4b1ee33e3d1c9f79a830dc51b956e9be4b1ee33e3d&width=544&height=306)

PICTURE :

 ![t1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8d2cb65576da948041c7c72ed8d581174cde42ae.jpeg) ![t2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7f926691259d9d74da222ed8003584e61d20fd8d.jpeg)

URL SITE :  
[https://blog.naver.com/my\_k\_s\_j](https://blog.naver.com/my_k_s_j)  
[https://blog.naver.com/happy32861](https://blog.naver.com/happy32861)
