Add extension to original file on reprocess

This commit is contained in:
Vasily Fedoseyev
2024-04-09 14:55:55 +03:00
parent d89e44ebbb
commit eb26524abe
2 changed files with 5 additions and 1 deletions

View File

@@ -314,7 +314,10 @@ module Paperclip
# thumbnails forcefully, by reobtaining the original file and going through
# the post-process again.
def reprocess!
new_original = Tempfile.new("paperclip-reprocess-#{instance.class.table_name}-#{instance.id}-")
new_original = Tempfile.new([
"paperclip-reprocess-#{instance.class.table_name}-#{instance.id}-",
File.extname(instance_read(:file_name))
])
new_original.binmode
old_original = to_file(:original) || raise("no original in store")
# по идее копирование нужно не всегда

View File

@@ -22,6 +22,7 @@ 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}"
when 'image/png', 'image/x-png'
"pngcrush -rem alla -q #{src_shell} #{dst_shell}"