I'm using a plugin that returns a PNG encoded base64 string, I cannot change it, I must work with it, but what I really need is the tiff encoded value (base-64). Is there a way of doing this?
I tried to create a canvas, load the png base64 and then used toDataURL('image/tiff')
but after some research, I'd found that tiff is not supported as output of toDataURL()
.
Any suggestions?
As TIFF is not generally supported as target file-format in the browser, you will have to manually encode the TIFF file by building up the file-structure using typed arrays and in accordance with the file specifications (see Photoshop notes here). It's doable:
Update canvas-to-tiff can be used to save canvas as TIFF images (disclaimer: I'm the author).
To get an Data-URI using canvas-to-tiff you can simply do:
Although, I would recommend using toBlob(), or if you want to give the user a link, toObjectURL() (instead of toDataURL).
Demo using Data-URI
Demo using Object-URL