Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ope=changepic does not replace SVG, only the preview-bitmap #16

Open
jorismak opened this issue Jun 10, 2021 · 4 comments
Open

ope=changepic does not replace SVG, only the preview-bitmap #16

jorismak opened this issue Jun 10, 2021 · 4 comments

Comments

@jorismak
Copy link

jorismak commented Jun 10, 2021

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:

            <p:pic>
                <p:nvPicPr>
                    <p:cNvPr id="5" name="Graphic 4" descr="[flag;ope=changepic;tagpos=inside;]">
                        <a:extLst>
                            <a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}">
                                <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{C57ABE97-03D1-4C1A-87CD-E9EAF41007A4}" />
                            </a:ext>
                        </a:extLst>
                    </p:cNvPr>
                    <p:cNvPicPr>
                        <a:picLocks noChangeAspect="1" />
                    </p:cNvPicPr>
                    <p:nvPr />
                </p:nvPicPr>
                <p:blipFill>
                    <a:blip r:embed="rId2">
                        <a:extLst>
                            <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                                <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
                            </a:ext>
                            <a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">
                                <asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId3" />
                            </a:ext>
                        </a:extLst>
                    </a:blip>
                    <a:stretch>
                        <a:fillRect />
                    </a:stretch>
                </p:blipFill>
                <p:spPr>
                    <a:xfrm>
                        <a:off x="1809750" y="571500" />
                        <a:ext cx="8572500" cy="5715000" />
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                        <a:avLst />
                    </a:prstGeom>
                </p:spPr>
            </p:pic>

And the output of that picture after OpenTBS:

            <p:pic>
                <p:nvPicPr>
                    <p:cNvPr id="5" name="Graphic 4" descr="">
                        <a:extLst>
                            <a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}">
                                <a16:creationId xmlns:a16="http://schemas.microsoft.com/office/drawing/2014/main" id="{C57ABE97-03D1-4C1A-87CD-E9EAF41007A4}" />
                            </a:ext>
                        </a:extLst>
                    </p:cNvPr>
                    <p:cNvPicPr>
                        <a:picLocks noChangeAspect="1" />
                    </p:cNvPicPr>
                    <p:nvPr />
                </p:nvPicPr>
                <p:blipFill>
                    <a:blip r:embed="opentbs1">
                        <a:extLst>
                            <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
                                <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
                            </a:ext>
                            <a:ext uri="{96DAC541-7B7A-43D3-8B79-37D633B846F1}">
                                <asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="rId3" />
                            </a:ext>
                        </a:extLst>
                    </a:blip>
                    <a:stretch>
                        <a:fillRect />
                    </a:stretch>
                </p:blipFill>
                <p:spPr>
                    <a:xfrm>
                        <a:off x="1809750" y="571500" />
                        <a:ext cx="8572500" cy="5715000" />
                    </a:xfrm>
                    <a:prstGeom prst="rect">
                        <a:avLst />
                    </a:prstGeom>
                </p:spPr>
            </p:pic>

You'll notice that OpenTBS replaced the first reference, on the a:blip tag (the r: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 to r:embed="opentbs1" , the edit actually works!

@rotdrop
Copy link

rotdrop commented Sep 15, 2021

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

@ghost
Copy link

ghost commented Sep 15, 2021

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.

@rotdrop
Copy link

rotdrop commented Sep 15, 2021

Yeah, the "replace png by svg" hack is of course likely to break things.

@rotdrop
Copy link

rotdrop commented Sep 16, 2021

#19 addresses SVG images for LibreOffice. I do not expect it to work for PP, but who knows ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants