Class: Alula::Magick
Instance Attribute Summary
Attributes inherited from Processor
#attachments, #item, #options, #site
Instance Method Summary
collapse
#process, #sizes
Methods inherited from Processor
#asset_path, available?, #initialize, mimetype, #process, process?
Instance Method Details
#cleanup ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/alula/processors/magick.rb', line 32
def cleanup
super
@info = nil
@image = nil
@exif = nil
end
|
#exif ⇒ Object
50
51
52
|
# File 'lib/alula/processors/magick.rb', line 50
def exif
@exif ||= MiniExiftool.new self.item.filepath
end
|
#image ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/alula/processors/magick.rb', line 54
def image
@image ||= begin
image = ::Magick::Image.read(self.item.filepath).first
unless self.options[:no_rotate]
case image.orientation.to_i
when 2
image.flop!
when 3
image.rotate!(180)
when 4
image.flip!
when 5
image.transpose!
when 6
image.rotate!(90)
when 7
image.transverse!
when 8
image.rotate!(270)
end
image
end
end
end
|
#info ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/alula/processors/magick.rb', line 40
def info
@info ||= begin
info = ::Magick::Image.ping(self.item.filepath).first
Hashie::Mash.new({
width: info.columns,
height: info.rows,
})
end
end
|
#resize_image(opts) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/alula/processors/magick.rb', line 11
def resize_image(opts)
output = opts.delete(:output)
width, height = opts.delete(:size)
resized = self.image.resize_to_fit(width, height)
resized.interlace = ::Magick::PlaneInterlace
tags = Hash[*(self.site.config.attachments["image"]["keep_tags"].collect{|t| [t, self.exif[t]]}).flatten]
resized.strip!
resized.write(output)
exif = MiniExiftool.new output
tags.each {|key, value| exif[key] = value }
exif.save
end
|