Giter Site home page Giter Site logo

Thumbnail crop should be higher about sigal HOT 10 CLOSED

saimn avatar saimn commented on August 16, 2024
Thumbnail crop should be higher

from sigal.

Comments (10)

hyperking avatar hyperking commented on August 16, 2024

@reagle I was having the same issue and came up with this small hack that works for most images tall or stout. :-)

width, height = img.size img = img.crop( (0, -int(float(height/2)), width, height) )
you could add this code after line 116 in the image.py file. working on a way to specify the crop position in the config settings.

from sigal.

saimn avatar saimn commented on August 16, 2024

The img_processor setting can be used to specify the processor class. Pilkit provides several processors but it also possible to write a custom one (instead of hacking sigal's code ;-)) or inherit from a processor to modify its behavior.
http://pilkit.readthedocs.org/en/latest/#processors
https://github.com/matthewwithanm/pilkit/blob/master/pilkit/processors/resize.py
The default processor is ResizeToFit, but maybe SmartResize can give better results.
https://github.com/matthewwithanm/pilkit/blob/master/pilkit/processors/resize.py#L82

from sigal.

hyperking avatar hyperking commented on August 16, 2024

@saimn looks simple. did you see my new feature request? could use some pointers
#82

from sigal.

reagle avatar reagle commented on August 16, 2024

SmartResize is hit or miss, makes some portraits better, others worse. I can't find evidence of pilkit detecting faces. @saimn which source file would you suggest a new class be added to?

from sigal.

saimn avatar saimn commented on August 16, 2024

@reagle you mean to add a new processor to sigal ? or a custom one ? In the first case, everything is in the image.py file, in the second case you add it directly in your config file.

from sigal.

anarcat avatar anarcat commented on August 16, 2024

i would suggest closing this issue: yes, SmartResize is hit and miss, but there isn't much that can be done about this in Sigal itself. this is a pilkit problem, and should be reported there.

oh, and maybe this would be less of a problem if #315 was fixed...

from sigal.

reagle avatar reagle commented on August 16, 2024

SmartResize was one possible solution. I think it'd still make sense to adopt @hyperking's approach.

from sigal.

saimn avatar saimn commented on August 16, 2024

I realize now that an option was added in #263 to specify how thumbnails are cropped (the thumb_fit and thumb_fit_centering settings). This allows to crop from the top of the image, so I think the issue can be closed.

from sigal.

saimn avatar saimn commented on August 16, 2024

Oh, and just to clarify things, thumbnails are created directly with Pillow, so not using pilkit's processors:
https://github.com/saimn/sigal/blob/master/sigal/image.py#L139-L155

from sigal.

reagle avatar reagle commented on August 16, 2024

Ah, I had not noticed the thumb_fit_centering, thanks!

from sigal.

Related Issues (20)

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.