Inkscape.org
Beginners' Questions Different applications seem to handle SVG dimensions differently
  1. #1
    Guinea Fowl Guinea Fowl @guineafowl

    I batch-converted a ton of Microsoft Office clipart (.WMF) files into SVG's using InkScape, and noticed that the cropping of the images was off - the bottom and right ends of them were outside the boundaries. At first I thought that something went wrong with the conversion, but when I opened these files with InkScape, I saw that the boundaries seemed correct, no information was lost (same with the original WMF's). Exporting them as PNG's also yielded correct results.
    I then tried several applications, with the following results:

    • feh, geeqie, gThumb, GIMP, and thumbnails in Nemo file manager all display the cropped view
    • nomacs also defaults to the cropped view, but zooming out actually reveals the rest of the image
    • InkScape, ImageMagick's display utility, as well as both Chromium- and Firefox-based web browsers handle the images correctly

    My question basically is: why? I assume it has to do with the conversion, as other SVG images on my computer aren't treated this way, but I can't figure out the actual reason.

    I attached an example SVG file, its original WMF version, as well as a compilation of various correct and incorrect displays.

    Some technical details that I do not think are relevant here, but who knows:

    • I use Manjaro Linux that had been installed with Plasma desktop, but I ended up uninstalling most KDE stuff and switched to Cinnamon
    • Kernel: 5.10.178-1-MANJARO
    • InkScape version: 1.2.2-4
    • For the batch-conversion, I used a Python script that I wrote, that utilized the following command: "inkscape [filename.wmf] -o [filename.svg]" (but exporting via the GUI yields the same results)
    • I've attempted different conversion methods, but they all failed, as libwmf seems to be broken

     

    p.s.: admittedly, I'm new to the world of vector graphics, so this question might be extremely noobish and most likely not strictly InkScape-related, but since several hours of googling has failed me, I saw no other option than to ask here.

    Mc900056286
    Svgcrop
  2. #2
    Aero Aero @Aero◻️

    Try adding a viewBox to the SVG.
    viewBox="0 0 190.848 188.16"

  3. #3
    Guinea Fowl Guinea Fowl @guineafowl

    Thank you, that did indeed fix this image. Where did you get these dimension from though? Couldn't find either of those numbers in the file. I'd like to be able to automate this, because I'm working with almost sixty-thousand images.

    Also, I still don't understand why the exported image's boundaries can be different from those of the ones I can see in InkScape.

  4. #4
    Aero Aero @Aero◻️
    🏆

    The viewBox is in pixels (96 per inch), same as width and height (in pixels).
    Could be an old bug that never got fixed?

    Maybe take a look at https://sk1project.net/uc2/

    sK1 is converting your WMF with a viewBox.
     

  5. #5
    Guinea Fowl Guinea Fowl @guineafowl

    Thank you so much! Dividing by 25.4 and multiplying by 96 seems to do trick consistently! I added some XML-handling to my script, where I add the viewBox attribute with dimensions derived from the aforementioned calculation to the newly converted SVG, and it seems to be working. I still don't understand why the "width" and "height" attributes don't achieve what this viewBox does, but at least it's possible to circumvent the problem.

    I also tried that UniConvertor you recommended, and it fails with some error relating to the cairo library, which I didn't feel like investigating. But as I said, I managed to handle the viewBox thing myself, so that's neither here nor there - thanks anyway!

Inkscape Inkscape.org Inkscape Forum Beginners' Questions Different applications seem to handle SVG dimensions differently