Comments (9)
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.
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.
@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.
Try require "refile/mini_magick"
(and make sure you have refile-mini_magick
in the Gemfile).
from refile-mini_magick.
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.
Aha, yes, you have to do that with define_method
. I will corrected this now for future users.
from refile-mini_magick.
Came here to say thanks @janko-m! the code snippet above solved my auto-rotation problems.
from refile-mini_magick.
This comment on #7 means that @janko-m code on his first comment is no longer necessary, right?
from refile-mini_magick.
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)
- Losing Alpha channel HOT 8
- Pad should scale image like `fit`, not like `limit`
- The actions are destructive HOT 2
- Moving forward to v1.0 HOT 4
- Sinatra 2.0 HOT 2
- cant install gem if adding 'gem 'refile-mini_magick'' HOT 2
- 1.2 ImageProcessing gem HOT 1
- Rack dependency needs to be updated to >= 2.0 HOT 2
- Set image quality via options HOT 1
- Release gem HOT 1
- gem 'refile-mini_magick' is not found HOT 4
- Limiting mini_magick memory usage HOT 4
- Video? HOT 1
- Is there support for multiple processors? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from refile-mini_magick.