Open Bug 1235179 Opened 10 years ago Updated 2 years ago

Add ability to save inline/embedded SVG as an image

Categories

(Firefox :: Menus, enhancement)

43 Branch
enhancement

Tracking

()

People

(Reporter: ipatrol6010, Unassigned)

References

(Depends on 2 open bugs, Blocks 1 open bug, )

Details

(7 keywords)

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0 Build ID: 20151216175450 Steps to reproduce: It seems that Firefox cannot save SVG which exists as an embedded document as a separate image. I first discovered this by going to http://www.spatialillusions.com/unitgenerator.html and trying to save the large blue icon. Actual results: The browser does not show anything in the context menu to save the image. Add-ons like DownThemAll don't help either. The only way to extract it is to go into the web console, select the SVG document, copy it, and paste it into a text editor and save as an SVG file. Expected results: It should be trivial for the browser to determine that there is an SVG image underneath the cursor, and offer a "Save Image As..." in the same vein as "View Background Image". Even if the image is dynamically generated by scripts, the browser should simply save the DOM as it is at the time of the save action. Possibly related bugs: Bug 64074 Bug 875715 Bug 999934 Bug 348755
Severity: normal → enhancement
Component: Untriaged → File Handling
Depends on: 348755
OS: Unspecified → All
Hardware: Unspecified → All
Whiteboard: [ie-parity]
Component: File Handling → Menus
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 64074
Has STR: --- → yes
Blocks: 875715
See Also: → 999934, 348755
Whiteboard: [ie-parity] → [parity-ie]
Depends on: 335963
Mass bug change to replace various 'parity' whiteboard flags with the new canonical keywords. (See bug 1443764 comment 13.)
Keywords: parity-ie
Whiteboard: [parity-ie]
Severity: normal → S3
Duplicate of this bug: 1769247
Duplicate of this bug: 1866376

:longsonr in your comment on bug 1866376 you say that an SVG when taken from inline HTML would need to be converted. I just attempted this and it seems to produce valid XML:

var e = document.querySelector('svg');
var s = new XMLSerializer();
var t = s.serializeToString(e);

The result seems pretty good, even in cases where there are HTML-y tweaks, like removing the xmlns and dropping a </g> or two. In light of that, I don't know how to reason about what else would be required to make progress on an implementation. It seems like our XMLSerializer is capable of handling a bunch of the identified problems already.

That leaves be wondering. Is this bug is hard or is it just that no one has paid it any real attention?

Flags: needinfo?(longsonr)

Well if anybody had worked on it there would be a patch in this bug.

Other considerations...

What are you going to do about remote references e.g.

<use ref="external.svg#id"/> or <rect fill="url(external.svg#id)"/> etc.

What about CSS? Are you going to copy all the page stylesheets or only the bits that the SVG fragment uses?

Flags: needinfo?(longsonr)

Perfect, thanks. Yes, the potential for external references escaped me, both with <use> and with CSS. A reference to another file is maybe manageable (in that this problem exists for saving from <img src="....svg">), but those that refer to other parts of the HTML document need to be considered.

I've started on an extension for this, which can be iterated upon.

the source of images cannot have external references (or if it does they are ignored). Images must be self contained.

You need to log in before you can comment on or make changes to this bug.