mateosss / matter

Customizable GRUB theme inspired by Material Design
Boost Software License 1.0
865 stars 50 forks source link

KeyError: 'width' line 54, in inkscape_convert_svg2png #76

Closed jasil2215P closed 1 year ago

jasil2215P commented 1 year ago

Hi, I am facing an error like this:

Traceback (most recent call last):
  File "./matter.py", line 876, in <module>
    do_install()
  File "./matter.py", line 543, in do_install
    prepare_source_dir()
  File "./matter.py", line 386, in prepare_source_dir
    convert_icon_svg2png(icon)
  File "./matter.py", line 248, in convert_icon_svg2png
    exit_code = converter(color, src_path, dst_path, whisper=whisper)
  File "/home/jaza/Documents/Hacking/matter/svg2png.py", line 54, in inkscape_convert_svg2png
    int_ignore_units(root.attrib["width"]),
KeyError: 'width'

And here is the command I run: sudo ./matter.py -i ubuntu folder _ _ _ _ _ _ microsoft-windows I am just trying to change my GRUB theme using matter and I think all the dependency have been installed properly.

Thank you for your advice and solutions!

heyzec commented 1 year ago

Which Linux distribution are you using, and what version is your inkscape?

jasil2215P commented 1 year ago

I am using Ubuntu 18.04

inkscape --version
Inkscape 0.92.3 (2405546, 2018-03-11)

And both grub-mkconfig and grub-mkfont are installed:

grub-mkconfig (GRUB) 2.02-2ubuntu8.23
jaza@ubuntu:~$ grub-mkfont --version
grub-mkfont (GRUB) 2.02-2ubuntu8.23
jasil2215P commented 1 year ago
jaza@ubuntu:~/Documents/Hacking/matter$ sudo ./matter.py -i ubuntu folder _ _ _ _ _ _ microsoft-windows
[I] Begin Matter install
[I] Build theme from user preferences
[I] Convert icons
Traceback (most recent call last):
  File "./matter.py", line 876, in <module>
    do_install()
  File "./matter.py", line 543, in do_install
    prepare_source_dir()
  File "./matter.py", line 386, in prepare_source_dir
    convert_icon_svg2png(icon)
  File "./matter.py", line 248, in convert_icon_svg2png
    exit_code = converter(color, src_path, dst_path, whisper=whisper)
  File "/home/jaza/Documents/Hacking/matter/svg2png.py", line 54, in inkscape_convert_svg2png
    int_ignore_units(root.attrib["width"]),
KeyError: 'width'

This is the complete output

heyzec commented 1 year ago

I finally managed to reproduce it. It seems like the site where the icons are downloaded from have changed the format of their SVGs.

It used to be

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="mdi-ubuntu" width="24" height="24" viewBox="0 0 24 24"><path ... />
</svg>

Now it is

<svg xmlns="http://www.w3.org/2000/svg" id="mdi-ubuntu" viewBox="0 0 24 24"><path ... />
</svg>

The width and height attributes have been removed. We need to calculate them from the viewBox property instead.

jasil2215P commented 1 year ago

Thank you everyone for helping me out :)