Sha256: d8d1dadedd2fd1bbd362ff38d2fd4c81d842d3dba69e5b218de8556226c34807

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

Contents

require "numo/narray"
require "dnn/ext/image_io/image_io_ext"

module DNN
  module ImageIO
    private_class_method :_read
    private_class_method :_write_bmp
    private_class_method :_write_png
    private_class_method :_write_jpg

    def self.read(file_name)
      raise ImageIO::ReadError.new("#{file_name} is not found.") unless File.exist?(file_name)
      _read(file_name)
    end

    def self.write(file_name, nary, quality: 100)
      case file_name
      when /\.png$/
        _write_png(file_name, nary)
      when /\.bmp$/
        _write_bmp(file_name, nary)
      when /\.jpg$/
        _write_jpg(file_name, nary, quality)
      end
    end
  end

  class ImageIO::Error < StandardError; end

  class ImageIO::ReadError < ImageIO::Error; end

  class ImageIO::WriteError < ImageIO::Error; end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-dnn-0.1.6 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.5 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.4 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.3 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.2 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.1 lib/dnn/lib/image_io.rb
ruby-dnn-0.1.0 lib/dnn/lib/image_io.rb