How can I change http:// linked images in Inkscape 0.92 to embedded ones?

有些话、适合烂在心里 提交于 2021-01-28 08:08:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!