Created
March 29, 2016 23:45
-
-
Save rafops/6c51614fcd200bf09fea1d26dda3531a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file stub imagemagick calls on paperclip | |
class Paperclip::StubQueue | |
cattr_accessor :q | |
@@q=[] | |
end | |
module Paperclip | |
def self.run cmd, arguments = "", interpolation_values = {}, local_options = {} | |
case cmd | |
when 'file' | |
if interpolation_values[:file].match /.jpg$/ | |
"image/jpeg; charset=binary\n" | |
else | |
"application/octet-stream\n" | |
end | |
when 'convert' | |
size = 0 | |
size = arguments.match(/\d+x\d+/).to_s.split('x').first.to_i if size.zero? | |
size = arguments.match(/\d+>/).to_s.split('>').first.to_i if size.zero? | |
StubQueue.q << size if size > 0 | |
# binding.pry if size == 0 | |
super | |
when 'identify' | |
if interpolation_values[:file].match /.jpg\[\d\]$/ | |
"1x1,1" | |
else | |
if StubQueue.q.empty? | |
super | |
else | |
size = StubQueue.q.shift | |
"#{size}x#{size}," | |
end | |
end | |
else | |
# binding.pry | |
super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment