Git Product home page Git Product logo

Comments (9)

grosser avatar grosser commented on July 18, 2024 4

Can we have the 'expected' / 'right' behavior by default please ?

  • image shows correctly oriented in standalone tab
  • image shows correctly oriented in Preview
  • image shows correctly oriented in other photo apps

... just not in the browser ... seems to be a common problem ... found a bunch of stackoverflow posts before I came here ... maybe make it disable-able ?
(I'll do the PR if that's acceptable ... alternatively a simple flag to turn auto_orient on ... but preferably 'correct' by default would be great and save lot's of people the search for the solution to this issue)

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

Ok, let's continue the dicussion here.

@danieldraper, I think the auto-orient feature isn't something that should be there by default, because I would expect that if the image is rotated during uploading, that it stays that way after upload. I think we shouldn't alter images in any way, except the size in this case.

Similar to @lazaronixon's advice, I would recommend if you want this to be default behaviour, to do something like this:

Refile::MiniMagick.prepend Module.new {
  [:limit, :fit, :fill, :pad].each do |action|
    define_method(action) do |img, *args|
      super(img, *args) { |cmd| cmd.auto_orient }
    end
  end
}

Otherwise you can subclass Refile::MiniMagick like @lazaronixon suggested, which is probably a more idiomatic approach. For me it really makes sense to just use subclassing to achieve this, or make your own processor if you want something more custom.

Adding some configuration option to Refile which you could give a block which yields the image object is something I thought about, but I think it broadens the API making it more unstable. For example, I recently had to change refile-mini_magick to use convert instead of mogrify to make it working with GraphicsMagick, and then yielding MiniMagick::Tool::Convert instead of MiniMagick::Tool::Mogrify could break someone's code. Just for an example.

I would consider this solved, @jnicklas?

from refile-mini_magick.

mtrolle avatar mtrolle commented on July 18, 2024

@janko-m where would I put your code?
I tried creating config/initializers/refile.rb and paste your code here, but that just failed with uninitialized constant Refile::MiniMagick

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

Try require "refile/mini_magick" (and make sure you have refile-mini_magick in the Gemfile).

from refile-mini_magick.

mtrolle avatar mtrolle commented on July 18, 2024

Thanks @janko-m - I didn't realize you had separated this so I was still using old image processing. Didn't need to require once I got the right Gem ;)

However I did have do change your super line to:
super(img, *args)

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

Aha, yes, you have to do that with define_method. I will corrected this now for future users.

from refile-mini_magick.

ctro avatar ctro commented on July 18, 2024

Came here to say thanks @janko-m! the code snippet above solved my auto-rotation problems.

from refile-mini_magick.

lsarni avatar lsarni commented on July 18, 2024

This comment on #7 means that @janko-m code on his first comment is no longer necessary, right?

from refile-mini_magick.

janko avatar janko commented on July 18, 2024

Yes, that is correct, given that you're pulling refile-mini_magick from master (as I don't think the switch to image_processing has been released yet).

from refile-mini_magick.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.