-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In RHEL8+ ImageMagick is no longer provided due to being hard to maintain and prone to security issues. That's why we implement an image processor based on the `libgd` backed `local-fastimage_resize` gem for logo processing instead of the Paperclip's default ImageMagick based processor `Paperclip::Thumbnail`. We remove support for uploading GIF profile logos in the process. Logo is used when generating invoices. But prawn only supports JPEGs and PNGs. With ImageMagick we could specify target format for the `:invoice` style to be `png` regardless of source image format. `local-fastimage_resize` only resizes between same formats though. Provided very low adoption of GIF logos, it is not worth implementing such support for `local-fastimage_resize` although it shouldn't be too hard if need arise. Note: existing attachments don't need to be processed because the `:invoice` style will already be PNG. Make sure NOT to manually re-process all attachments though. Anyway no need to. fixes THREESCALE-8579
- Loading branch information
1 parent
89f60bd
commit 1fc4cfe
Showing
12 changed files
with
126 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Paperclip | ||
class GDImageProcessor < Processor | ||
def make | ||
original_geometry = Geometry.new(*FastImage.size(file)) | ||
computed_geometry = original_geometry.resize_to(target_geometry_str) | ||
file.rewind | ||
original_geometry.to_s[/\d+x\d+/] == computed_geometry.to_s[/\d+x\d+/] ? temp_copy(file) : FastImage.resize(file, computed_geometry.width, computed_geometry.height) | ||
end | ||
|
||
private | ||
|
||
def target_geometry_str | ||
options.fetch(:geometry) | ||
end | ||
|
||
def temp_copy(uploaded_file) | ||
file = Tempfile.new(["copy", File.extname(uploaded_file.path)]) | ||
File.copy_stream(uploaded_file, file) | ||
uploaded_file.rewind | ||
file.rewind | ||
file | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters