Converting SVG to Base64 produce different result on local and on server

Viewed 66

I have a function that produces QR code as SVG from a URL and then I convert it to Base64 using Rmagick.

def generate_qr(url)
    barcode = Barby::QrCode.new(url, level: :q, size: 10)
    qr_output = barcode.to_svg({ xdim: 10 })
    'data:image/png;base64,' + Base64.strict_encode64(convert_svg_to_png(qr_output))
end
def convert_svg_to_png(str)
    img = Magick::Image.from_blob(str) {
      self.format = 'SVG'
      self.background_color = 'transparent'
    }
    #from_blob returns an array of images. in our case there is only one
    img[0].to_blob {
      self.format = 'PNG'
    }
end

on my computer this produces this result: enter image description here

But on the server it produces this result:

enter image description here

I have no idea why can this be. It is exactly the same code...

0 Answers
Related