rszr.rb 969 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module Rszr
  3. # https://github.com/zammad/zammad/issues/4347
  4. #
  5. # This method detects if Rszr needs autorotate flag to correctly handle photos orientation
  6. #
  7. # < 1.9 imlib2 versions need autorotate flag.
  8. # >= 1.9 imlib2 versions handle autorotate and autorotate flag causes issues.
  9. #
  10. # As of January 2023, major LTS Linux distributions include older imlib2
  11. # Even after latest distributions switch to newer imlib2, we will need this to support older distros for a while
  12. #
  13. # This file will be removed along with config/initializers/rszr.rb
  14. # When all supported Linux distributions update to >= 1.9 imlib2
  15. def self.needs_autorotate_fix?
  16. sample_path = Rails.root.join 'lib/core_ext/rszr.jpg'
  17. sample_image = Rszr::Image.load sample_path
  18. sample_image.height != 25
  19. rescue Rszr::LoadError
  20. true # Platform with outdated imlib2, handle gracefully.
  21. end
  22. end