mirror of
https://github.com/kemko/paperclip.git
synced 2026-01-01 16:05:40 +03:00
Fix optimizer temporary file
This commit is contained in:
@@ -22,8 +22,9 @@ module Paperclip
|
||||
dst_shell = dst_file.path.shellescape
|
||||
cmd = case real_content_type
|
||||
when 'image/jpeg', 'image/jpg', 'image/pjpeg'
|
||||
# TODO: --stdout > #{dst_shell}
|
||||
"cp #{src_shell} #{dst_shell} && jpegoptim --all-progressive -q --strip-com --strip-exif --strip-iptc -- #{dst_shell}"
|
||||
# NB: --stdout не работает, там бывают пустые файлы если оно решило ничего не делать
|
||||
# нельзя `cp`, надо чтобы открытый файл указывал куда надо, поэтому `cat>`
|
||||
"cat #{src_shell} > #{dst_file} && jpegoptim --all-progressive -q --strip-com --strip-exif --strip-iptc --stdout -- #{dst_shell}"
|
||||
when 'image/png', 'image/x-png'
|
||||
"pngcrush -rem alla -q #{src_shell} #{dst_shell}"
|
||||
when 'image/gif'
|
||||
@@ -32,6 +33,7 @@ module Paperclip
|
||||
return
|
||||
end
|
||||
run_and_verify!(cmd)
|
||||
dst_file.tap(&:flush).tap(&:rewind)
|
||||
dst_file
|
||||
rescue StandardError => e
|
||||
dst_file.close!
|
||||
|
||||
Reference in New Issue
Block a user