class Image

Constants

EDITABLE
IGNORE
IGNORE_COLUMNS

Public Instance Methods

create_png() click to toggle source
# File app/models/image.rb, line 64
def create_png
  file = "app/assets/images/dbimage-#{id}.png"
  return if File.exist?(file) and File.ctime(file) > updated_at

  w, h = thumbnail_width, thumbnail_height
  if w <= 0 or h <= 0
    w = h = 64
    data = Array.new(w*h*4, 0.0)
  else
    data = thumbnail.unpack('C*').map { |x| x / 255.0 }
  end

  if data.size >= w * h * 4
    data = data[0..w*h*4-1]
  end


  img = Magick::Image.constitute( w, h, 'BGRA', data )
  img.format = 'PNG'
  img.write(file)
end
to_label() click to toggle source
# File app/models/image.rb, line 86
def to_label
  "#{directory}/#{filename}"
end