Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libvips使用時にPNG to JPEG変換処理が正常に動作していない問題を修正 #53

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/paperclip/img_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def convert_image_with_vips

if opaque?(image)
basename = File.basename(file.path, File.extname(file.path))
dst_name = basename << '.jpg'
dst_name = basename << '.jpeg'

dst = Paperclip::TempfileFactory.new.generate(dst_name)

new_vipsimage_from_file(src_path).write_to_file(File.expand_path(dst.path), **save_options)

if @file.size > dst.size
attachment.instance.file_file_name = "#{File.basename(attachment.instance.file_file_name, '.*')}.jpeg"
attachment.instance.file_content_type = 'image/jpeg'
return dst
end
Expand All @@ -39,7 +40,7 @@ def convert_image_with_imagemagick

if opaque == 'true'
basename = File.basename(file.path, File.extname(file.path))
dst_name = basename << '.jpg'
dst_name = basename << '.jpeg'

dst = Paperclip::TempfileFactory.new.generate(dst_name)

Expand All @@ -48,6 +49,7 @@ def convert_image_with_imagemagick
dst: File.expand_path(dst.path))

if @file.size > dst.size
attachment.instance.file_file_name = "#{File.basename(attachment.instance.file_file_name, '.*')}.jpeg"
attachment.instance.file_content_type = 'image/jpeg'
return dst
end
Expand Down
Loading