Vips::Image.new_from_file Swaps Width/Height in Rails Server, but Not Console
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rails, ruby
- Lĩnh vực
- backend, computer-vision
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện hành vi với Vips::Image.new_from_file trong một phiên pry của máy chủ Rails và một Rails console, sử dụng ảnh ví dụ hướng đến EXIF và cùng một đường dẫn tempfile. So sánh các lần gọi không có tùy chọn và với fail: true, sau đó theo dõi cách ruby-vips xử lý các tùy chọn mặc định và siêu dữ liệu hình ảnh trong mỗi runtime. Hoàn tất khi kích thước vẫn chính xác mà không có đối số tùy chọn trong cả hai môi trường.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Description
When loading an image from a file path, Vips::Image.new_from_file(path) returns swapped width and height dimensions. This issue only occurs when the code is executed within a Rails server process (e.g., Puma/Unicorn). The exact same code, reading the exact same file path, returns the correct dimensions when run from a rails console.
A peculiar workaround is that providing any optional argument to the method call (e.g., fail: true or autorotate: false) corrects the behavior in the server environment. This suggests a potential issue with how default options are handled or a caching-related problem specific to the server runtime.
Steps to Reproduce
-
Place a binding.pry in any Rails controller action.
-
In the pry session, download an image that has EXIF orientation data:
require 'down'
url = 'https://raw.githubusercontent.com/recurser/exif-orientation-examples/master/Landscape_6.jpg'
tempfile = Down.download(url)
- Load the image, apply autorot, and overwrite the tempfile:
image = Vips::Image.new_from_file(tempfile.path)
image.autorot.write_to_file(tempfile.path)
- Reload the image from the same path without any options and inspect its dimensions. The dimensions will be swapped.
# In the server pry session
reloaded_image = Vips::Image.new_from_file(tempfile.path)
puts "BUG -> In Server: #{reloaded_image.width}x#{reloaded_image.height}"
# Example Output: BUG -> In Server: 3024x4032
path = tempfile.path # Copy this path for the next step
- In a new terminal, open a rails console. Use the path from the previous step to load the same file:
# In the rails console session
console_image = Vips::Image.new_from_file('PASTE_THE_TEMPFILE_PATH_HERE')
puts "OK -> In Console: #{console_image.width}x#{console_image.height}"
# Example Output: OK -> In Console: 4032x3024
- Go back to the server pry session. Run the same command but add any option, like fail: true. The dimensions will now be correct.
# Back in the server pry session
workaround_image = Vips::Image.new_from_file(tempfile.path, fail: true)
puts "FIXED -> Server with option: #{workaround_image.width}x#{workaround_image.height}"
# Example Output: FIXED -> Server with option: 4032x3024
Expected Behavior
Vips::Image.new_from_file(tempfile.path) should consistently return the correct dimensions (4032x3024 for the example image) in all execution environments, including the Rails server.
Actual Behavior
The dimensions are swapped (3024x4032) only when run inside a Rails server without any extra options. The dimensions are correct when run in a Rails console or when any option is added to the method call in the server.
Screenshots
This is the correct behaviour after adding an option
Top terminal is the Rails server; bottom terminal is the Rails console:
Desktop
- OS:Fedora 42(local) and ubuntu (production environment)
- Ruby-vips 2.2.3
- libvips 8.16.1 (on all envs)
Thank you in advance
- Ngôn ngữ chính
- Ruby
- Star
- 904
- Fork
- 64
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của libvips/ruby-vips
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
cache_drop_all seg fault Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
-
blocked-upstream bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
Tất cả issue của libvips/ruby-vips
Issue tương tự
-
user-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Kong/developer.konghq.com#7316 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
notch8/utk_knapsack#148 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Homebrew/homebrew-cask#288729 · 1 bình luận ·
-
Test `FileUtils.options_of` Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100