Adding big junks of custom data to jpg image file












3















I wonder if there is an obvious and elegant way to add additional data to a jpeg while keeping it readable for standard image viewers. More precisely I would like to embed a picture of the backside of a (scanned) photo into it. Old photos often have personal messages written on the back, may it be the date or some notes. Sure you could use EXIF and add some text, but an actuall image of the back is more preferable.
Sure I could also save 2 files xyz.jpg and xyz_back.jpg, or arrange both images side by side, always visible in one picture, but that's not what I'm looking for.
It is possible and has been done, like on Samsung Note 2 and 3 you can add handwritten notes to the photos you've taken as a image. Or some smartphones allow to embed voice recordings to the image files while preserving the readability of those files on other devices.










share|improve this question



























    3















    I wonder if there is an obvious and elegant way to add additional data to a jpeg while keeping it readable for standard image viewers. More precisely I would like to embed a picture of the backside of a (scanned) photo into it. Old photos often have personal messages written on the back, may it be the date or some notes. Sure you could use EXIF and add some text, but an actuall image of the back is more preferable.
    Sure I could also save 2 files xyz.jpg and xyz_back.jpg, or arrange both images side by side, always visible in one picture, but that's not what I'm looking for.
    It is possible and has been done, like on Samsung Note 2 and 3 you can add handwritten notes to the photos you've taken as a image. Or some smartphones allow to embed voice recordings to the image files while preserving the readability of those files on other devices.










    share|improve this question

























      3












      3








      3








      I wonder if there is an obvious and elegant way to add additional data to a jpeg while keeping it readable for standard image viewers. More precisely I would like to embed a picture of the backside of a (scanned) photo into it. Old photos often have personal messages written on the back, may it be the date or some notes. Sure you could use EXIF and add some text, but an actuall image of the back is more preferable.
      Sure I could also save 2 files xyz.jpg and xyz_back.jpg, or arrange both images side by side, always visible in one picture, but that's not what I'm looking for.
      It is possible and has been done, like on Samsung Note 2 and 3 you can add handwritten notes to the photos you've taken as a image. Or some smartphones allow to embed voice recordings to the image files while preserving the readability of those files on other devices.










      share|improve this question














      I wonder if there is an obvious and elegant way to add additional data to a jpeg while keeping it readable for standard image viewers. More precisely I would like to embed a picture of the backside of a (scanned) photo into it. Old photos often have personal messages written on the back, may it be the date or some notes. Sure you could use EXIF and add some text, but an actuall image of the back is more preferable.
      Sure I could also save 2 files xyz.jpg and xyz_back.jpg, or arrange both images side by side, always visible in one picture, but that's not what I'm looking for.
      It is possible and has been done, like on Samsung Note 2 and 3 you can add handwritten notes to the photos you've taken as a image. Or some smartphones allow to embed voice recordings to the image files while preserving the readability of those files on other devices.







      jpeg exif file-format






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 '15 at 12:23









      Angry CoderAngry Coder

      429




      429
























          2 Answers
          2






          active

          oldest

          votes


















          2














          An interesting question. There are file formats that support multiple images per file (multipage TIFF comes to mind) but JPEG doesn't support this natively.



          One feature of the JPEG file format is the concept of APP segments. These are regions of the JPEG file that can contain arbitrary information (as a sequence of bytes). Exif is actually stored in one of these segments, and is identified by a preamble.



          Take a look at this page: http://www.sno.phy.queensu.ca/~phil/exiftool/#JPEG



          You'll see many segments there that start with APP such as APP0 (which can store JFIF data), APP1 (which can contain Exif) and so forth.



          There's nothing stopping you storing data in one of these segments. Conformant JPEG readers will ignore this unrecognised data, but you could write software to store/retrieve data from within there. It's even possible to embed another JPEG file within such a segment! There's no precedent I know for doing this however.



          Another option would be to include the second image as the thumbnail of the first. Normally thumbnails are very small, but you could store a second image as the thumbnail of the first. Some software might replace or remove this though.



          In general I think using two files and a naming convention would be the simplest and least confusing, but you do have options.






          share|improve this answer
























          • re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

            – quetzalcoatl
            May 14 '18 at 13:32













          • Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

            – Drew Noakes
            May 15 '18 at 11:47



















          2














          There are two ways you can do this.



          1) Use and Application Marker (APP0–APPF)—the preferred method



          2) Use a Comment Marker (COM)



          If you use an APPn marker:



          1) Do not make it the first APPn in the file. Every known JPEG file format expects some kind of format specific APPn marker right after the SOI marker. Make sure that your marker is not there.



          2) Place a unique application identifier (null terminated string) at the start of the data (something done by convention).



          All kinds of applications store additional data this way.



          One issue is that the length field is only 16-bits (Big Endian format). If you have a lot of data, you will have to split it across multiple markers.



          If you use a COM marker, make sure it comes after the first APPn marker in the file. However, I would discourage using a COM marker for something like this as it might choke applications that try to display the contents.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33609044%2fadding-big-junks-of-custom-data-to-jpg-image-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            An interesting question. There are file formats that support multiple images per file (multipage TIFF comes to mind) but JPEG doesn't support this natively.



            One feature of the JPEG file format is the concept of APP segments. These are regions of the JPEG file that can contain arbitrary information (as a sequence of bytes). Exif is actually stored in one of these segments, and is identified by a preamble.



            Take a look at this page: http://www.sno.phy.queensu.ca/~phil/exiftool/#JPEG



            You'll see many segments there that start with APP such as APP0 (which can store JFIF data), APP1 (which can contain Exif) and so forth.



            There's nothing stopping you storing data in one of these segments. Conformant JPEG readers will ignore this unrecognised data, but you could write software to store/retrieve data from within there. It's even possible to embed another JPEG file within such a segment! There's no precedent I know for doing this however.



            Another option would be to include the second image as the thumbnail of the first. Normally thumbnails are very small, but you could store a second image as the thumbnail of the first. Some software might replace or remove this though.



            In general I think using two files and a naming convention would be the simplest and least confusing, but you do have options.






            share|improve this answer
























            • re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

              – quetzalcoatl
              May 14 '18 at 13:32













            • Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

              – Drew Noakes
              May 15 '18 at 11:47
















            2














            An interesting question. There are file formats that support multiple images per file (multipage TIFF comes to mind) but JPEG doesn't support this natively.



            One feature of the JPEG file format is the concept of APP segments. These are regions of the JPEG file that can contain arbitrary information (as a sequence of bytes). Exif is actually stored in one of these segments, and is identified by a preamble.



            Take a look at this page: http://www.sno.phy.queensu.ca/~phil/exiftool/#JPEG



            You'll see many segments there that start with APP such as APP0 (which can store JFIF data), APP1 (which can contain Exif) and so forth.



            There's nothing stopping you storing data in one of these segments. Conformant JPEG readers will ignore this unrecognised data, but you could write software to store/retrieve data from within there. It's even possible to embed another JPEG file within such a segment! There's no precedent I know for doing this however.



            Another option would be to include the second image as the thumbnail of the first. Normally thumbnails are very small, but you could store a second image as the thumbnail of the first. Some software might replace or remove this though.



            In general I think using two files and a naming convention would be the simplest and least confusing, but you do have options.






            share|improve this answer
























            • re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

              – quetzalcoatl
              May 14 '18 at 13:32













            • Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

              – Drew Noakes
              May 15 '18 at 11:47














            2












            2








            2







            An interesting question. There are file formats that support multiple images per file (multipage TIFF comes to mind) but JPEG doesn't support this natively.



            One feature of the JPEG file format is the concept of APP segments. These are regions of the JPEG file that can contain arbitrary information (as a sequence of bytes). Exif is actually stored in one of these segments, and is identified by a preamble.



            Take a look at this page: http://www.sno.phy.queensu.ca/~phil/exiftool/#JPEG



            You'll see many segments there that start with APP such as APP0 (which can store JFIF data), APP1 (which can contain Exif) and so forth.



            There's nothing stopping you storing data in one of these segments. Conformant JPEG readers will ignore this unrecognised data, but you could write software to store/retrieve data from within there. It's even possible to embed another JPEG file within such a segment! There's no precedent I know for doing this however.



            Another option would be to include the second image as the thumbnail of the first. Normally thumbnails are very small, but you could store a second image as the thumbnail of the first. Some software might replace or remove this though.



            In general I think using two files and a naming convention would be the simplest and least confusing, but you do have options.






            share|improve this answer













            An interesting question. There are file formats that support multiple images per file (multipage TIFF comes to mind) but JPEG doesn't support this natively.



            One feature of the JPEG file format is the concept of APP segments. These are regions of the JPEG file that can contain arbitrary information (as a sequence of bytes). Exif is actually stored in one of these segments, and is identified by a preamble.



            Take a look at this page: http://www.sno.phy.queensu.ca/~phil/exiftool/#JPEG



            You'll see many segments there that start with APP such as APP0 (which can store JFIF data), APP1 (which can contain Exif) and so forth.



            There's nothing stopping you storing data in one of these segments. Conformant JPEG readers will ignore this unrecognised data, but you could write software to store/retrieve data from within there. It's even possible to embed another JPEG file within such a segment! There's no precedent I know for doing this however.



            Another option would be to include the second image as the thumbnail of the first. Normally thumbnails are very small, but you could store a second image as the thumbnail of the first. Some software might replace or remove this though.



            In general I think using two files and a naming convention would be the simplest and least confusing, but you do have options.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 '15 at 12:56









            Drew NoakesDrew Noakes

            189k118529621




            189k118529621













            • re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

              – quetzalcoatl
              May 14 '18 at 13:32













            • Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

              – Drew Noakes
              May 15 '18 at 11:47



















            • re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

              – quetzalcoatl
              May 14 '18 at 13:32













            • Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

              – Drew Noakes
              May 15 '18 at 11:47

















            re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

            – quetzalcoatl
            May 14 '18 at 13:32







            re "no precedent" - FLIR cameras like E6 do it for some time already. E6 has 2 sensors, one normal camera, one infrared, and they trigger them both at once and emit a single JPG. In that JPG you have the infrared image by default, but from extra JPG sections you can extract the normal digital photo of the scene, some black-white stencil-like thing, and more.

            – quetzalcoatl
            May 14 '18 at 13:32















            Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

            – Drew Noakes
            May 15 '18 at 11:47





            Interesting. There's a Google camera app that includes a depth map image in a similar fashion. It's stored in XMP: developers.google.com/depthmap-metadata

            – Drew Noakes
            May 15 '18 at 11:47













            2














            There are two ways you can do this.



            1) Use and Application Marker (APP0–APPF)—the preferred method



            2) Use a Comment Marker (COM)



            If you use an APPn marker:



            1) Do not make it the first APPn in the file. Every known JPEG file format expects some kind of format specific APPn marker right after the SOI marker. Make sure that your marker is not there.



            2) Place a unique application identifier (null terminated string) at the start of the data (something done by convention).



            All kinds of applications store additional data this way.



            One issue is that the length field is only 16-bits (Big Endian format). If you have a lot of data, you will have to split it across multiple markers.



            If you use a COM marker, make sure it comes after the first APPn marker in the file. However, I would discourage using a COM marker for something like this as it might choke applications that try to display the contents.






            share|improve this answer




























              2














              There are two ways you can do this.



              1) Use and Application Marker (APP0–APPF)—the preferred method



              2) Use a Comment Marker (COM)



              If you use an APPn marker:



              1) Do not make it the first APPn in the file. Every known JPEG file format expects some kind of format specific APPn marker right after the SOI marker. Make sure that your marker is not there.



              2) Place a unique application identifier (null terminated string) at the start of the data (something done by convention).



              All kinds of applications store additional data this way.



              One issue is that the length field is only 16-bits (Big Endian format). If you have a lot of data, you will have to split it across multiple markers.



              If you use a COM marker, make sure it comes after the first APPn marker in the file. However, I would discourage using a COM marker for something like this as it might choke applications that try to display the contents.






              share|improve this answer


























                2












                2








                2







                There are two ways you can do this.



                1) Use and Application Marker (APP0–APPF)—the preferred method



                2) Use a Comment Marker (COM)



                If you use an APPn marker:



                1) Do not make it the first APPn in the file. Every known JPEG file format expects some kind of format specific APPn marker right after the SOI marker. Make sure that your marker is not there.



                2) Place a unique application identifier (null terminated string) at the start of the data (something done by convention).



                All kinds of applications store additional data this way.



                One issue is that the length field is only 16-bits (Big Endian format). If you have a lot of data, you will have to split it across multiple markers.



                If you use a COM marker, make sure it comes after the first APPn marker in the file. However, I would discourage using a COM marker for something like this as it might choke applications that try to display the contents.






                share|improve this answer













                There are two ways you can do this.



                1) Use and Application Marker (APP0–APPF)—the preferred method



                2) Use a Comment Marker (COM)



                If you use an APPn marker:



                1) Do not make it the first APPn in the file. Every known JPEG file format expects some kind of format specific APPn marker right after the SOI marker. Make sure that your marker is not there.



                2) Place a unique application identifier (null terminated string) at the start of the data (something done by convention).



                All kinds of applications store additional data this way.



                One issue is that the length field is only 16-bits (Big Endian format). If you have a lot of data, you will have to split it across multiple markers.



                If you use a COM marker, make sure it comes after the first APPn marker in the file. However, I would discourage using a COM marker for something like this as it might choke applications that try to display the contents.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 10 '15 at 0:33









                user3344003user3344003

                14.8k31639




                14.8k31639






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f33609044%2fadding-big-junks-of-custom-data-to-jpg-image-file%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    'app-layout' is not a known element: how to share Component with different Modules

                    android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

                    SQL update select statement