Skip to content

Remove ImageMagick dependency and disable provider logo resizing - #1627

Open
jrhoads wants to merge 1 commit into
masterfrom
remove-imagemagick
Open

jrhoads wants to merge 1 commit into
masterfrom
remove-imagemagick

Conversation

@jrhoads

@jrhoads jrhoads commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Purpose

Remove the system and gem dependency on ImageMagick (mini_magick) by discontinuing server-side image resizing for provider logos, while introducing a 1 MB file size limit to prevent oversized uploads.

Approach

Previously, Paperclip shelled out to ImageMagick via mini_magick to resize uploaded provider logos to a medium (500x200, PNG) style. ImageMagick introduces significant system-level attack surface and maintenance overhead.

We now store uploaded logos directly without modification and rely on clients to handle display dimensions. To prevent excessively large files from being uploaded and served, a validation constraint is introduced limiting logo files to less than 1 MB. With logo resizing removed, mini_magick and system-level ImageMagick installations have been removed from the application, CI, and Docker environments.

Key Modifications

  • app/models/provider.rb:
    • Removed styles definition (medium: ["500x200", :png]) and default_style from has_attached_file :logo.
    • Added attachment size validation: size: { less_than: 1.megabyte }.
    • Updated logo_url to return logo.url instead of logo.url(:medium).
  • Dependencies:
    • Removed mini_magick gem from Gemfile and Gemfile.lock.
    • Removed imagemagick package from Dockerfile and .github/workflows/parallel_ci.yml.
    • Added file package to Dockerfile to support Paperclip's MIME-type detection.
  • Specs:
    • Added unit and request tests asserting that logos over 1 MB are rejected with a validation error.
    • Added assertion verifying that logo files are persisted unaltered.

Important Technical Details

  • Logos are now served at their uploaded resolution and format rather than normalized PNG thumbnails.
  • The file CLI package was added to the Docker image because Paperclip uses it for content type spoofing detection and MIME-type resolution when ImageMagick is absent.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

ImageMagick was only used by Paperclip to resize provider logos to a
500x200 PNG "medium" style. Drop the style so Paperclip stores the logo
as uploaded and never shells out, and add a 1 MB size limit so
oversized uploads are rejected instead of served as-is.

- Remove the unused mini_magick gem
- Remove imagemagick from the Dockerfile and the CI workflow
- Install `file` explicitly in the Dockerfile; Paperclip's content-type
  spoof check needs it and rejects every upload without it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jrhoads
jrhoads requested review from a team and codycooperross October 23, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant