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

Include support for SVG embedded base64 images in pre-compiled binaries #601

Closed
dynamite-ready opened this issue Oct 13, 2016 · 6 comments
Closed
Milestone

Comments

@dynamite-ready
Copy link

I've just upgraded to version 0.16.1 on OSX, as I was keen to test out the smart cropping functionality.

To do so, I had to uninstall the version of VIPS I found here - http://www.vips.ecs.soton.ac.uk/index.php?title=Build_on_OS_X - The installation now works, but unfortunately embedded Base64 images in .svg files will not render on output to .png (and on output to .jpeg, the area containing the Base64 image renders a black square).

Interestingly, before upgrading, and while I had the Homebrew build of VIPS installed, Base64 images did work...

Any ideas as to what might have changed, and how I can fix it to render Base64 images in .svg's again?

@dynamite-ready
Copy link
Author

dynamite-ready commented Oct 13, 2016

For the record, when installing Sharp v0.16.1 with VIPS already installed, I receive the following error:

gyp: Call to 'PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.11:$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --libs vips-cpp' returned exit status 1 while in binding.gyp. while trying to load binding.gyp

An issue which might in part be related to this one - #588

@lovell
Copy link
Owner

lovell commented Oct 13, 2016

Hello. do you happen to have a copy of what the command brew info vips said about the version of vips (and its dependencies) installed before you removed it?

My best guess would be that you were using an installation of vips with *magick as a dependency. If so, this library might have been used to decode the SVG format instead of the now-preferred librsvg.

Are you able to provide the SVG at fault, or at least a similar example that fails in a similar manner?

@dynamite-ready
Copy link
Author

dynamite-ready commented Oct 14, 2016

Here's an example of the SVG I'm using. As you can see, it's pretty simple, so I suspect this is an OSX installation problem which might well be related to - #602 - as well as - #588

On Windows, the conversion process works, though I do suspect a problem with embeddded JPG's:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.1"
   id="svg2"
   viewBox="0 0 220 210"
   height="210"
   width="220">
  <defs
     id="defs4" />
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     transform="translate(0,-842.36216)"
     id="layer1">
    <image
       width="219.89999"
       height="165"
       preserveAspectRatio="none"
       id="edit-image"
       x="0"
       y="843.07648"
       xlink:href="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAACXBIWXMAAAsTAAALEwEAmpwYAAABAElEQVR4nO3RQQ0AIBDAsAP/nuGNAvZoFSzZOjNnyNi/A3gZEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIjCExhsQYEmNIzAXsTALGT7m3PwAAAABJRU5ErkJggg==" />
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;letter-spacing:-1.52999997px;word-spacing:0px;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       x="9.5872231"
       y="1036.1429"
       id="text4157"><tspan
         id="edit-title"
         x="9.5872231"
         y="1036.1429"
         style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;font-family:'.Al Bayan PUA';-inkscape-font-specification:'.Al Bayan PUA';fill:#4d4d4d">Hello</tspan></text>
    <flowRoot
       style="fill:black;stroke:none;stroke-opacity:1;stroke-width:1px;stroke-linejoin:miter;stroke-linecap:butt;fill-opacity:1;font-family:sans-serif;font-style:normal;font-weight:normal;font-size:40px;line-height:125%;letter-spacing:0px;word-spacing:0px"
       id="flowRoot3344"
       xml:space="preserve"><flowRegion
         id="flowRegion3346"><rect
           y="14.285714"
           x="11.428572"
           height="196.42857"
           width="352.14285"
           id="rect3348" /></flowRegion><flowPara
         id="flowPara3350"></flowPara></flowRoot>  </g>
</svg>

@dynamite-ready
Copy link
Author

As for the output of brew info vips, tbf, I did have the full fat version installed at one point, but have since uninstalled *magick, and the output is as follows:

Dependencies
Build: pkg-config ✔
Required: fontconfig ✔, gettext ✔, glib ✔
Recommended: libpng ✔, jpeg ✔, orc ✔, libgsf ✔, libtiff ✔, fftw ✔, little-cms2 ✔, pango ✔, libexif ✔, gobject-introspection ✔, pygobject3 ✔, python ✔, poppler ✔, librsvg ✔, giflib ✔
Optional: openslide ✔, imagemagick ✘, graphicsmagick ✘, openexr ✔, cfitsio ✔, webp ✔, python3 ✘, libmatio ✔, mozjpeg ✘, jpeg-turbo ✔

@dynamite-ready dynamite-ready changed the title SVG to PNG - Embedded Base64 images do not render SVG to PNG - Embedded Base64 images do not render on OSX Oct 14, 2016
@lovell
Copy link
Owner

lovell commented Oct 14, 2016

Thank you. I also found a good example of embedded base64 PNG and JPEG images in the W3C's test suite - see https://dev.w3.org/SVG/profiles/1.2T/test/svg/struct-image-04-t.svg

As you've discovered, using a custom installation of libvips with *magick support works. There's a security gotcha here as *magick will probably go and fetch remote URLs, local files and all sorts of other things, so make sure you trust the image sources. librsvg is much more conservative in this regard.

For embedded images to work, librsvg has to be compiled with support for gdk-pixbuf, which has to be compiled with support for whichever image formats are required.

For OS X, my best guess is the pre-compiled OS X tarball is missing the gdk-pixbuf loaders.

For Linux, the pre-compiled binaries currently exclude JPEG and PNG.

I'll look at including/enabling these for the next major release.

@lovell lovell changed the title SVG to PNG - Embedded Base64 images do not render on OSX Include support for SVG embedded base64 images in pre-compiled binaries Oct 14, 2016
@lovell lovell added this to the v0.17.0 milestone Oct 14, 2016
@lovell
Copy link
Owner

lovell commented Dec 11, 2016

v0.17.0 now available with pre-compiled binaries that include everything required for embedded base64 images in SVG files.

@lovell lovell closed this as completed Dec 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants