Skip to content

Instantly share code, notes, and snippets.

View readyready15728's full-sized avatar
🍞
"Where are the toasters you promised us?"

readyready15728

🍞
"Where are the toasters you promised us?"
View GitHub Profile
@rb2k
rb2k / epub_compressor.rb
Created May 22, 2016 17:34
Quick hack to recompress epub files
def compress(file)
raise unless system("rm -rf tmp/")
raise unless system("unzip -q -o -d tmp/ '#{file}'")
raise unless system("imageOptim --directory tmp/ ")
raise unless system("pushd tmp/ && zip -q -9 -rX '#{file}' 'mimetype' '*' && popd")
end
def filesize(file)
'%.2f' % (File.size(file).to_f / 2**20)
end