0

I want to decode QR codes in my rails app. I am using Qrio gem which needs ChunkyPng gem to work. It is working fine when i write and run a ruby program using it. But, when i try using it with Rails it does not work.

This isthe error i get.

No such file or directory - chart.png

Extracted source (around line #5): 3 4 5 6 7 8

class PNGImageLoader
  def self.load(filename)
    image = ChunkyPNG::Image.from_file(filename)

    bits = image.pixels.map do |pixel|
      grayscale = ChunkyPNG::Color.to_grayscale(pixel)

1 Answers1

0

It appears that the file you're trying to load doesn't exist. It seems to be looking for chart.png in your root directory. Make sure you use a full path and it will probably work.

Jaap Haagmans
  • 6,232
  • 1
  • 25
  • 30
  • I am supposed to load an image of the qr code but it is not working. I tried loading it from the assets folder, public folder. It dosent work yet. – Anil Dukkipatty Jan 24 '14 at 15:10
  • Could you show us your code? If you using `Qrio::Qr.load(path_to_file)`, it should work. The above code still tells me the path to the file is wrong. – Jaap Haagmans Jan 27 '14 at 11:13
  • I was using paperclip to manage the uploads, while passing the file i used '@file.file.url', i should have used '@file.file.path' The path code worked like a charm. Thanks. – Anil Dukkipatty Jan 28 '14 at 14:16
  • No problem. I'm glad you've found the problem! – Jaap Haagmans Jan 28 '14 at 16:36