-
Notifications
You must be signed in to change notification settings - Fork 74
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
use libgd instead of ImageMagick #3065
Conversation
34048fe
to
1fc4cfe
Compare
test/integration/provider/admin/account/logos_controller_test.rb
Outdated
Show resolved
Hide resolved
test/integration/provider/admin/account/logos_controller_test.rb
Outdated
Show resolved
Hide resolved
f8f8615
to
db71c05
Compare
db71c05
to
d6a3fed
Compare
d6a3fed
to
ee446c2
Compare
There is also a conflict in |
ee446c2
to
a42a2fe
Compare
task :regenerate_jpeg_invoice_logo => :environment do | ||
Profile.where(logo_content_type: "image/jpeg").find_each do |profile| | ||
begin | ||
profile.logo.reprocess!(:invoice) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we are affected by this bug: thoughtbot/paperclip#2637
I have tested this successfully though, so not sure if this may cause any issues. But this is to be aware of for SaaS migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be fine. Since we are not running an external process like it was done by ImageMagic, I think in case of a trouble, the process will just fail. Also if target style only is truncated, that shouldn't be an issue.
But I will add as a precaution to backup the S3 bucket beforehand. Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to test this by editing gems/paperclip-6.1.0/lib/paperclip/storage/s3.rb
and making sure an empty local file is being generated when copying the file locally.
The bug is present - paperclip overwrites the target image with an empty file.
But we have nothing to worry because:
- it only overwrites the styles being reprocessed, this means that original logo will not be affected
- because the
invoice
style will be missing anyway, overwriting it with a zero byte file will not matter (no data will be lost)
What we have to do would be to check for any broken invoice logos after running the task.
Great job @akostadinov ! 👏 |
@@ -113,6 +113,17 @@ namespace :fixes do | |||
end | |||
end | |||
|
|||
desc "Regenerate JPEG logos :invoice style" | |||
task :regenerate_jpeg_invoice_logo => :environment do | |||
Profile.where(logo_content_type: "image/jpeg").find_each do |profile| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about png extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed
a42a2fe
to
9607c8c
Compare
@thalesmiguel Didn't you have any issues installing |
I managed to install the |
It works! 👍🏻 |
148bf23
54d8018
to
148bf23
Compare
osx-manual-setup.md
Outdated
@@ -58,7 +58,7 @@ xcode-select -—install | |||
### Dependencies | |||
|
|||
``` | |||
brew install chromedriver imagemagick@6 gs pkg-config openssl geckodriver sphinx mysql@5.7 postgresql@14 | |||
brew install chromedriver imagemagick@6 gs pkg-config openssl geckodriver sphinxgd mysql@5.7 postgresql@14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, shouldn't we remove imagemagick and add gd?
brew install chromedriver imagemagick@6 gs pkg-config openssl geckodriver sphinxgd mysql@5.7 postgresql@14 | |
brew install chromedriver libgd gs pkg-config openssl geckodriver sphinxgd mysql@5.7 postgresql@14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the next one #3165
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But wait isn't package called gd
?
https://formulae.brew.sh/formula/gd
@@ -159,6 +159,7 @@ Then add the necessary configs: | |||
bundle config --local build.thin --with-cflags=-Wno-error="implicit-function-declaration" | |||
bundle config --local build.github-markdown --with-cflags=-Wno-error="implicit-function-declaration" | |||
bundle config --local build.mysql2 --with-opt-dir="$(brew --prefix openssl)" | |||
bundle config --local build.local-fastimage_resize --with-opt-dir="$(brew --prefix gd)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it works 👍🏻
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 JPEG logos need to have the `:invoice` style regenerated with `rake fixes:regenerate_jpeg_invoice_logo`. fixes THREESCALE-8579 There is another part to this replacement and it is our gruff usage.
148bf23
to
08f6edf
Compare
Note: DEPLOY ONLY AFTER COORDINATION WITH PRODUCT TEAM!
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
backedlocal-fastimage_resize
gem for logo processing instead of thePaperclip'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 toohard if need arise.
Note: existing attachments don't need to be processed because the
:invoice
style will already be PNG. Make sure NOT to re-process allattachments though. I don't see a reason to re-process them.
Note: existing png and gif attachments don't need to be processed because the
:invoice
style will already be PNG. JPEGs will need though as style for them changes.fixes THREESCALE-8579