问题
I'm using Inkscape 0.92 for OS X from the official download page (https://inkscape.org/en/release/0.92.2/mac-os-x/), but I can't seem to get it to load images that have been included using http, for instance, an SVG like this
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="950" height="717">
<image width="120" height="120" preserveAspectRatio="none"
xlink:href="https://media.inkscape.org/media/cms_page_media/328/Inkscape_Logo2.png"/>
</svg>
I would like to change these images to embedded ones, but when I try Extensions->Images->Embed Images, I get
No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image. Sorry we could not locate /media/cms_page_media/328/Inkscape_Logo2.png
Which implies to me that Inkscape cannot deal with http:// urls (i.e. get images from the internet)
Is there any way to enable this?
回答1:
Here's a perl script which should do an inline-replace of linked jpg files in an svg with an embedded base64 encoded version:
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
use MIME::Base64;
our $^I=''; # see perlvar(1)
while(<>){
s|(xlink:href=)(["'])(https?:[\w/.]+\.jpg)\g2|$1.$2."data:image/jpg;base64,".encode_base64(get($3), "").$2|eg; #embed jpgs
print;
}
来源:https://stackoverflow.com/questions/46472054/how-can-i-change-http-linked-images-in-inkscape-0-92-to-embedded-ones