Module: ZBar::JPEG

Defined in:
lib/zbar/jpeg.rb

Overview

zbar-0.10 has a problem handling certain JPEGs:

This is a problem in the underlying C library. It is fixed in zbar’s source control repository, but an updated package has not yet been released.

If this affects you, ask whoever compiled your libzbar to apply this patch: gist.github.com/willglynn/5659946

Class Method Summary collapse

Class Method Details

.available?Boolean

Is JPEG support available?

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/zbar/jpeg.rb', line 13

def self.available?
  if @available.nil?
    @available = image_works?(WorkingBits)
  end
  
  @available
end

.bugged?Boolean

Is JPEG support bugged? See github.com/willglynn/ruby-zbar/issues/2 for details.

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/zbar/jpeg.rb', line 23

def self.bugged?
  if @bugged.nil?
    @bugged = available? && !image_works?(BuggedBits)
  end
  
  @bugged
end

.warn_once_if_buggedObject

:nodoc:



31
32
33
34
35
36
37
38
# File 'lib/zbar/jpeg.rb', line 31

def self.warn_once_if_bugged #:nodoc:
  @warn_attempted ||= begin
    if bugged?
      STDERR.print "Your libzbar has a JPEG bug. Some images will fail to process correctly.\nSee: https://github.com/willglynn/ruby-zbar/blob/master/lib/zbar/jpeg.rb\n"
    end
    true
  end
end