Open jorismak opened 3 years ago
I have the same problem when trying to replace SVGs in Libreoffice. Apparantly, OpenTBS only replaces the first image it finds. However, Libreoffice stores the original SVG and a preview or rastered image. Replacing a PNG image by an SVG seems to work. However, the mime-type in the image-file is then wrongly set as image/png instead of image/svg+xml
What Powerpoint 365 does if you add a SVG, is to make a rasterized preview of that SVG and insert it as an image, and then it 'attaches' the SVG data to the image.
If an older Powerpoint version then reads the presentation, it sees the bitmap image and shows it fine, but if a Powerpoint version supporting SVG reads it, they know they can 'dive deeper' in the image to get the original SVG data.
OpenTBS replaces 'first image' it finds, which is the rasterized preview image. So if you replace a SVG with another SVG, what happens is that the preview rasterized image is changed with SVG data, and the original SVG data is still untouched in its place. So older Powerpoints show a broken image (they don't understand the SVG data that OpenTBS inserted) and newer Powerpoints will show no change, because they look at the original untouched SVG data that is there.
In the case of Libreoffice, it might show it as working, but it is clearly not 100% correct and the file will probably not render correctly in other programs.
Result is that OpenTBS can only really replace PNG images with other PNG images.
We ended up using the npm package svgexport
(based on puppeteer) to convert all SVGs to PNG, and then use those in the presentation.
Yeah, the "replace png by svg" hack is of course likely to break things.
No clue, if this is the right place to mention issues, but here goes.
If I make an empty powerpoint, and I insert an image with SVG file as source, Powerpoint creates a bitmap-preview of that SVG and gives both resources for the same picture.
OpenTBS then replaces the 'main' image (the bitmap preview), but not the 'svg extra data'. When opening the presentation, you'll see the original SVG file because that data is untouched and used by office.
Original image in the input-powerpoint:
And the output of that picture after OpenTBS:
You'll notice that OpenTBS replaced the first reference, on the
a:blip
tag (ther:embed
property is changed to the new picture).But inside that tag, there is a
asvg:svgBlip
tag which still points to the same resource as before (r:embed="rId3"
). If I edit that file to change the 2nd reference also tor:embed="opentbs1"
, the edit actually works!