Class IrekiaThumbnail
In: lib/irekia_thumbnail.rb
Parent: Object

Methods

make  

Public Class methods

[Source]

    # File lib/irekia_thumbnail.rb, line 2
 2:   def self.make(photo, geometry, size)
 3:     begin
 4:       dirname, filename = Pathname.new(photo).split
 5:       # I'll do it with Paperclip to harness the "90x90#" geometry syntax
 6:       temp_file = Paperclip::Thumbnail.make(File.open(photo), geometry)
 7:       FileUtils.mkdir_p("#{dirname}/#{size}/") unless File.directory?("#{dirname}/#{size}/")
 8:       thumbnail_file = "#{dirname}/#{size}/#{filename}"
 9:       FileUtils.mv(temp_file.path, thumbnail_file) 
10:       FileUtils.chmod 0666, thumbnail_file
11:       temp_file.close    
12:     rescue => err
13:       raise IrekiaThumbnailError, "There was an error generating thumbnail of size #{size} for #{photo}: #{err}"
14:     end
15:   end

[Validate]