Class: Imagecache::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/imagecache/converter.rb

Instance Method Summary collapse

Instance Method Details

#_convert(assetpath, conversions) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/imagecache/converter.rb', line 17

def _convert(assetpath, conversions)
  source = (conversions.length > 1) ? url_writer.write(conversions[0, (conversions.size - 1)], assetpath) : assetpath
  destination = url_writer.write(conversions, assetpath)
  if filesystem.exists?(destination)
    data = filesystem.get(destination)
    return data
  elsif filesystem.exists?(source)
    data = filesystem.get(source)
    file = file(data)
     = identify.identify(file)
    newdata = process(file, , conversion)
    newurl = url_writer.write(conversions, assetpath)
    filesystem.set(newurl, converted.data)
    return newdata
  end
end

#convert(data, conversions) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/imagecache/converter.rb', line 6

def convert(data, conversions)
  (1..conversions.length).each do |i|
    data = _convert(assetpath, conversions)
  end
  file = file(data)
   = identify.identify(file)
  File.unlink(file.path)
  OpenStruct.new(data: data, content_type: .content_type)
end