15

I have an image like this:

<img src="data:image/jpeg;charset=utf-8;base64,/9j...">

When I right click on the image and choose 'save as', the save dialog comes up with "download.jpg" as the filename. I'd like to choose a different default filename. Adding a download tag on the img element doesn't seem to work. Is there some way to add a name to this?

I've seen this, but its about <a> tags: Is there any way to specify a suggested filename when using data: URI?

Community
  • 1
  • 1
B T
  • 57,525
  • 34
  • 189
  • 207
  • Possible duplicate of [How to control base64 images when user saves as](http://stackoverflow.com/questions/9549819/how-to-control-base64-images-when-user-saves-as) – Adnan Umer Aug 19 '16 at 08:15
  • 1
    http://stackoverflow.com/questions/39034022/can-you-set-filename-for-save-as-on-an-image-with-a-data-url – Maciej Sikora Aug 19 '16 at 08:22
  • 1
    @MaciejSikora now because of you I am in an infinite loop looking for some dupe... – Kaiido Aug 19 '16 at 08:32
  • 1
    I think it's a no-go... The closest I've got is this : http://plnkr.co/edit/biG96etB4CL2K3mtTMBW?p=preview Try from FF, in windowed mode, and then choose "View Image" in your context menu. Finally, look at the title of your page. *(yes all this just for that...)* – Kaiido Aug 19 '16 at 09:01
  • I think you're probably right Kaiido : / – B T Aug 19 '16 at 20:56
  • Possible duplicate of [File object to image with correct file name instead of src="blob..."](https://stackoverflow.com/questions/37726789/file-object-to-image-with-correct-file-name-instead-of-src-blob) – EECOLOR Jul 09 '18 at 23:45

1 Answers1

3

Maybe you can try something like this using caman.js. Here is a example how it works. I know that it's not exactly what you want but take a look. DEMO

You can also use the <a> tag to do that but it will download on click.

<a download="logo.png" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">Download transparent png</a>
Edison Biba
  • 4,384
  • 3
  • 17
  • 33