Skip to content

Use vips methods for resizing instead of ImageMagick - #15452

Open
dunkOnIT wants to merge 1 commit into
thewca:mainfrom
dunkOnIT:fix/ro-logo-url
Open

Use vips methods for resizing instead of ImageMagick#15452
dunkOnIT wants to merge 1 commit into
thewca:mainfrom
dunkOnIT:fix/ro-logo-url

Conversation

@dunkOnIT

Copy link
Copy Markdown
Contributor

The RO's page is currently broken with this error:

[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816] 
Information for: ActionView::Template::Error (no implicit conversion to float from string):
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     1: <% provide(:title, t('regional_organizations.title')) %>
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     2: 
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     3: <div class="container">
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     4:   <%= react_component("RegionalOrganizations", props: {
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     5:     orgs: @acknowledged_regional_organizations,
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     6:   }) %>
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]     7: </div>
[dc35cf9d-cee4-4456-9d56-d720dfcc3dbb] [user:158816]   

Reproducing in terminal, it is because of this resize code in line 33 of the RO controller:

logo.variant(resize: "500x300").processed

After LLM discussion, it seems that we are using an ImageMagick method but we have changed to vips. Using vips-specific syntax, I was able to get the resize to work without error in the console:

wca-on-rails(prod):010> ro.logo.variant(resize_to_limit: [500, 300]).processed
I, [2026-08-25T12:07:29.024518 #7350]  INFO -- :   S3 Storage (186.7ms) Downloaded file from key: v89aer8d0jwu4t8nas58tv3p2ror
I, [2026-08-25T12:07:29.321683 #7350]  INFO -- :   S3 Storage (150.1ms) Uploaded file to key: jaecjefwukpgxsk86wg536he5xi4 (checksum: /D0WLjesp4xMdWXB17u5Ng==)
INFO  2026-08-25T12:07:29.325Z pid=7350 tid=3ge: Sidekiq 8.1.7 connecting to Redis with options {size: 10, pool_name: "internal", url: "redis://wca-main-sidekiq.iebvzt.ng.0001.usw2.cache.amazonaws.com:6379"}
I, [2026-08-25T12:07:29.330586 #7350]  INFO -- : [ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: e50d7260-9f1b-41f2-8d41-b3614abe568f) to Sidekiq(default) with arguments: #<GlobalID:0x00007f2b9e0e3460 @uri=#<URI::GID gid://wca-on-rails/ActiveStorage::Blob/209928>>
=> 
#<ActiveStorage::VariantWithRecord:0x00007f2bb01c79c8
 @blob=
  #<ActiveStorage::Blob:0x00007f2b9f142388
   id: 209907,
   key: "v89aer8d0jwu4t8nas58tv3p2ror",
   filename: "CCA Logo.png",
   content_type: "image/png",
   metadata: {"identified" => true, "width" => 547, "height" => 242, "analyzed" => true},
   byte_size: 28558,
   checksum: "o+fiG4OgqdH2r8vnfDVzBg==",
   created_at: "2026-08-25 10:27:22.000000000 +0000",
   service_name: "amazon">,
 @record=#<ActiveStorage::VariantRecord:0x00007f2b9dfbd798 id: 74938, blob_id: 209907, variation_digest: "z484+i75QZTEJo5g2XmWWuoRCgQ=">,
 @variation=#<ActiveStorage::Variation:0x00007f2bb01c7d10 @transformations={format: "png", resize_to_limit: [500, 300]}>>

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