14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/paperclip-optimizer/processor.rb', line 14
def make
src_path = File.expand_path(@file.path)
if optimizer_options[:verbose]
Paperclip.logger.info "optimizing #{src_path} with settings: #{optimizer_options.inspect}"
old_stderr = $stderr
$stderr = ::PaperclipOptimizer::StdErrCapture.new(Paperclip.logger)
end
begin
image_optim = ImageOptim.new(optimizer_options)
compressed_file_path = image_optim.optimize_image(src_path)
ensure
$stderr = old_stderr if optimizer_options[:verbose]
end
if compressed_file_path && File.exist?(compressed_file_path)
return File.open(compressed_file_path)
else
return @file
end
end
|