Embedding the IPFS hash into an image

How can one create an image in such a way that its IPFS hash will be embedded into it?

If you hash the image after it is created, discover the hash, and then embed that hash into the image (in a way that can easily be copy/pasted for example) then the image with the hash will generate a new hash.

Does this mean that we need some sort of side-car files, like the sort produced with digital cameras? Or is there way to hash a container in such a way that its hash won’t change if its contents do?

This is a sort of IPNS problem. I don’t know the best way to do this these days.

I think this question needs more clarification…

So you want to create a sequential chain or a tree of images? If that’s the case:

The point of IPFS is that the hash references the data, so you’ll want to build a dag or blockchain that references the hash which references the data and the hash for the previous reference. That’s pretty much how everyone I know is doing it right now. You could also include a reference to the previous hash with your image, if you want people to actually retrieve all the images.

I personally use a system that abstracts all this onto an interface that resembles a Datastore, so if I wanna get all images of a certain category I can dag.get(’/category’) or dag.get(’/category/’+hash) for a specific reference (for pagination for example). Then I retrieve the referenced data.

You could also use the MFS, which works in a similar way and lets you reference your image by filename.

1 Like

If you want a hash that won’t change even if the image changes, then yes IPNS is all you need. IPNS uses a key so it’s secure and can’t be updated except by it’s creator.

However if you need to have a way to always prove “File X is my file I’m certifying for purpose Y with my private key Z”, then what you are talking about is a digital signature, but even in this case the digital signature would have to be stored outside the image, somewhere separate.

1 Like

Thanks, StationedInTheField! I think the MFS (Mutable File System) or IPNS is probably the best for what I have in mind. The idea is something like this:

Create a piece of digital Art.
Embed or watermark the file with an IPFS hash which will retrieve both the file and the self-referential hash.

For fun and to make it more confusing…

PaintingOfPipe.jpg
QmThisIsNotAPipe

At the online gallery I hang the digital painting, where people who admire it can claim it as their own by copy/pasting the hash within the painting.
They make this great painting available to others by pinning it.

1 Like

Great to see you again, wclayf! (If anybody hasn’t tried wclaf’s IPFS Quanta project yet, check it out here! https://quanta.wiki/ ). It reminds me I have an idea to use it.

Anyway, I think the IPNS method might be best in this case.

1 Like