Giter VIP home page Giter VIP logo

smartcropper's Introduction

smartcropper

Content aware cropping.

Crops images based on entropy: leaving the most interesting part intact.

Don't expect this to be a replacement for human cropping, it is an algorythm and not an extremely smart one at that :).

Best results achieved in combination with scaling: the cropping is then only used to square the image, cutting off the least interesting part. The trimming simply chops off te edge that is least interesting, and continues doing so, untill it reached the requested size.

Usage

Use it in carrierwave, in a custom manipulate! block. For example, carrierwave in a Rails project:

File uploaders/attachement_uploader.rb:

def smart_crop_and_scale(width, height)
  manipulate! do |img|
    img = SmartCropper.new(img)
    img = img.smart_crop_and_scale(width, height)
    img = yield(img) if block_given?
    img
  end
end

# Create different versions of your uploaded files:
version :thumb do
  process :smart_crop_and_scale => [80, 80]
end

Contributing to croptoelie

  • This is one of my first more complex Ruby gems. So any help in general improvement is welcome. If you read the code and thing "OMG, what was he thinking, the answer is probably 'I wasn't'". Feel free to tell me so.

  • RMagick is not the cleanest and leanest of all image-manipulation libraries in Ruby, but it was the only one where I found enough documentation and that had the features I needed (such as histograms). If you have better ideas, feel free to tell me them.

  • I only use this gem with carrierwave, so other implementations are probably not well done. If you want to use it in any other project, please tell me what I should change to make your life easier.

  • The integration in carrierwave should be simpler. I would love to be able to say process :smart_crop_and_scale instead of having to use the smartcropper as class in a custom carrierwave manipulate! block. My knowledge of Ruby, Carrierwave and how to get this integration done properly is limited, if you have a patch, or a suggestion, that would be great!

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Changelog

2011-04-19: Replace crop with crop! avoids copying large chunks of images around. 2011-04-18: Limit to N steps, instead of step_size. 2011-04-16: Introduce tests and a profiler script, to profile performance.

Roadmap

  1. Refactoring: It must be cleaned up. There is a lot of smelly code, fat methods and DRY.
  2. Performance: I want to make it smarter when cropping (really) large images.
  3. Improve slicing. The results are okay-ish when merely squaring images, but lack when you cut tiny areas from a large image.
  4. Release 1.0.0

Copyright

Copyright (c) 2011 Bèr Kessels. See LICENSE.txt for further details.

smartcropper's People

Contributors

berkes avatar hanshasselberg avatar parkr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

smartcropper's Issues

Readme Useage

Hey there,

Just noticed in the readme:Usage section that it has:

img = CropToelie.new(img)

Should it be changed to the new class?

img = SmartCropper.new(img)

question about roadmap

I'm using croptoellie/smartcropper in a couple of projects. Since croptoellie has a new maintainer and a new name.. I was wondering: is there a (rough) roadmap for how you want to develop smartcropper? Is there any new features planned?

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.