emacs-eaf / emacs-eaf/eaf-image-viewer

svg 内嵌的本地图片无法显示

Open
#4 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Description

今天在尝试 https://github.com/misohena/el-easydraw 在 Emacs 上画 svg 文件。它支持 import 本地图片,然后继续画线等等操作。

我有个 `demo.edraw.svg`(后缀 edraw.svg 是 el-easydraw 约定的,但其实还是 svg)。

它的 text 内容:

```

```

可以看到其中 `xlink:href="/Users/c/Library/Mobile Documents/iCloud~com~appsonthemove~beorg/Documents/braindump/notes/static/STM32 入门/2024-03-07_01-11-54_screenshot.jpg` 就是内嵌的本地图片。

* 我期待 eaf-image-viewer 的正常表现如其他
在 Emacs org-mode 中,显示正常,在本地文件夹预览,显示正常,在 Chrome 浏览器,显示正常。

如下图所示:

![image](https://github.com/emacs-eaf/eaf-image-viewer/assets/161039954/ed4a10a6-799d-4cd9-938a-106c22106458)

* 故障现象

在 eaf-image-viewer 中,只能显示我画的线,内嵌的本体图片没有正常显示

如下图所示:

![image](https://github.com/emacs-eaf/eaf-image-viewer/assets/161039954/c151d195-011b-45b3-b657-eda3c51c8b87)

* 排查对比 eaf-image-viewer 和 Chrome elements 元素
如下图所示:

![截屏2024-03-15 02 45 29](https://github.com/emacs-eaf/eaf-image-viewer/assets/161039954/ae1f0c25-c0c8-4a94-b41c-cd77fcaeeb0d)

![截屏2024-03-15 02 43 25](https://github.com/emacs-eaf/eaf-image-viewer/assets/161039954/8962d1d9-8421-4c09-9da0-cddff4cfbcb3)

* 我的猜想

![截屏2024-03-15 02 43 45](https://github.com/emacs-eaf/eaf-image-viewer/assets/161039954/54e22a49-b29d-4902-9a3f-4f18e25891d4)

是不是因为在 eaf-image-viewer 中 Sources 只加载了要预览的 svg 自身资源,svg 内嵌的图片资源没有加载?

在 eaf-image-viewer 的 Python 代码中:

```
def load_image(self, url):
self.url = url
self.parent_dir = os.path.abspath(os.path.join(url, os.pardir))
self.image_name = os.path.basename(url)

load_image_js = "document.getElementById('image').setAttribute('src', '{0}?{1}');viewer.update();".format(
os.path.join("file://", self.url).replace("\\", "/"),
random.randint(1, 100000))

self.buffer_widget.eval_js(load_image_js)

```
对于 svg ,确实只是传入 svg 本身 url,对于 svg 内嵌的图片没有被加载。

这个不知道是不是原因?后续如何解决?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.