pospi/imthumb

Allow sharpening amount in sharpen parameter

Opened this issue · 3 comments

As with TimThumb, the sharpening parameter is a binary on-off affair. And as with TimThumb, I find the default level of sharpening to be too strong. Adjusting the level of sharpening in TimThumb requires tweaking the values in the sharpening matrix - thankfully it's much easier in ImThumb and just requires a simple adjustment to the blur value in resizeImage(). I found 0.8 was about right to my eye.

The amount of sharpening needed is a matter of taste, and can vary according to the size of the generated image. So my request is instead of "s=1"/"s=0" to enable/disable sharpening, could the amount of sharpening be passed in the parameter, e.g. "s=0.8"?

Note: I realise that part of the intention behind the ImThumb project is provide a drop-in replacement for TimThumb. However, TimThumb has certain shortcomings (IMO) so perhaps there's an argument for deviating from the TimThumb approach?

Absolutely. So long as the library is compatible with TimThumb's approach out of the box (or can be configured to be) then I am more than happy to add in any other diverging and enhanced functionality.

In this case I think we can add this in either of the following ways:

  • add another new parameter for controlling the sharpen level
  • strictly interpret a 1 / 0 for the parameter to act as the current boolean toggle, and interpret any floating point values as directly defining the sharpen level

My preference leans toward the second approach as then we're reusing current parameters and enhancing them a bit rather than adding further variables to the mix. If you had a reason to explicitly pass a 1 or a 0 as the sharpen level then you could just pass it as 1.0 or 0.0.

Yes, the second approach sounds perfect.

can you test out the sharpen-param-enhance branch for me and let me know if it breaks any of your existing images? I've noticed some weird artifacts when you set it to low values..