extract uninterlace_png method

This commit is contained in:
Christophe Robillard 2023-09-19 15:37:28 +02:00 committed by krichtof
parent 6abd0f8db0
commit 46edaed6bc
2 changed files with 18 additions and 11 deletions

View file

@ -0,0 +1,14 @@
module UninterlacePngConcern
extend ActiveSupport::Concern
private
def uninterlace_png(uploaded_file)
if uploaded_file&.content_type == 'image/png'
chunky_img = ChunkyPNG::Image.from_io(uploaded_file.to_io)
chunky_img.save(uploaded_file.tempfile.to_path, interlace: false)
uploaded_file.tempfile.reopen(uploaded_file.tempfile.to_path, 'rb')
end
uploaded_file
end
end