Skip to main content
deleted 14 characters in body
Source Link
rhermans
  • 37.7k
  • 4
  • 64
  • 156

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIFEXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" ->  RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

EDIT

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

storeInImage[img_Image, data_] := Image[img, MetaInformation -> {"Exif" -> {"UserComment" ->  ToCharacterCode[Compress[data]]}} ] extractFromImage[img_Image] := Uncompress[ FromCharacterCode@ Association[Nest[Values, Options[img, MetaInformation], 2]][[ "UserComment"]]] storeInImage[Import["ExampleData/lena.tif"], ExampleData[{"Text", "ToBeOrNotToBe"}]] 

Mathematica graphics

extractFromImage[%]

To be, or not to be,--that is the question:-- Whether 'tis nobler in
the mind [...]

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" ->  RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

storeInImage[img_Image, data_] := Image[img, MetaInformation -> {"Exif" -> {"UserComment" ->  ToCharacterCode[Compress[data]]}} ] extractFromImage[img_Image] := Uncompress[ FromCharacterCode@ Association[Nest[Values, Options[img, MetaInformation], 2]][[ "UserComment"]]] storeInImage[Import["ExampleData/lena.tif"], ExampleData[{"Text", "ToBeOrNotToBe"}]] 

Mathematica graphics

extractFromImage[%]

To be, or not to be,--that is the question:-- Whether 'tis nobler in
the mind [...]

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

EDIT

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

storeInImage[img_Image, data_] := Image[img, MetaInformation -> {"Exif" -> {"UserComment" -> ToCharacterCode[Compress[data]]}} ] extractFromImage[img_Image] := Uncompress[ FromCharacterCode@ Association[Nest[Values, Options[img, MetaInformation], 2]][[ "UserComment"]]] storeInImage[Import["ExampleData/lena.tif"], ExampleData[{"Text", "ToBeOrNotToBe"}]] 

Mathematica graphics

extractFromImage[%]

To be, or not to be,--that is the question:-- Whether 'tis nobler in
the mind [...]

added 631 characters in body
Source Link
rhermans
  • 37.7k
  • 4
  • 64
  • 156

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

storeInImage[img_Image, data_] := Image[img, MetaInformation -> {"Exif" -> {"UserComment" -> ToCharacterCode[Compress[data]]}} ] extractFromImage[img_Image] := Uncompress[ FromCharacterCode@ Association[Nest[Values, Options[img, MetaInformation], 2]][[ "UserComment"]]] storeInImage[Import["ExampleData/lena.tif"], ExampleData[{"Text", "ToBeOrNotToBe"}]] 

Mathematica graphics

extractFromImage[%]

To be, or not to be,--that is the question:-- Whether 'tis nobler in
the mind [...]

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

storeInImage[img_Image, data_] := Image[img, MetaInformation -> {"Exif" -> {"UserComment" -> ToCharacterCode[Compress[data]]}} ] extractFromImage[img_Image] := Uncompress[ FromCharacterCode@ Association[Nest[Values, Options[img, MetaInformation], 2]][[ "UserComment"]]] storeInImage[Import["ExampleData/lena.tif"], ExampleData[{"Text", "ToBeOrNotToBe"}]] 

Mathematica graphics

extractFromImage[%]

To be, or not to be,--that is the question:-- Whether 'tis nobler in
the mind [...]

added 71 characters in body
Source Link
rhermans
  • 37.7k
  • 4
  • 64
  • 156

What I can see is that you need to include metadata in an accepted format for images, for instance EXIFEXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

What I can see is that you need to include metadata in an accepted format for images, for instance EXIF.

img = Image[Rasterize[x], MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", "Make" -> "camera brand", "Model" -> "xxx"}}] Export["test2.jpg", img] Import["test2.jpg", "ImageWithExif"] Options[%, MetaInformation] 
{MetaInformation -> {"Exif" -> {"ImageDescription" -> "An example", 
 "Make" -> "camera brand", "Model" -> "xxx"}}} 

The fields that EXIF accepts are limited, but there is a field called UserComment of arbitrary length and format.

Your example code does not work, so I will do a minimum working example with random data

Export[ "testimage.jpg" , Image[ Import["ExampleData/lena.tif"] , MetaInformation -> {"Exif" -> {"UserComment" -> RandomInteger[255, 1024 1024]}} ]] 

To recover:

Options[Import["testimage.jpg", "ImageWithExif"], MetaInformation] 

You could encode anything you want as a list of integers, for instance using Compress and ToCharacterCode

added 757 characters in body
Source Link
rhermans
  • 37.7k
  • 4
  • 64
  • 156
Loading
Source Link
rhermans
  • 37.7k
  • 4
  • 64
  • 156
Loading