bakape / thumbnailer

Go media thumbnailer
MIT License
152 stars 36 forks source link

Thumbnail proportional scaling #70

Open ElMaxo opened 3 years ago

ElMaxo commented 3 years ago

Hello There is no convenient way to create proportionally scaled thumbnails now. We can't get original size thumbnail, because default thumbnail dimensions will be set as 150*150. Also, we can't perform custom processing by manual ffmpeg context creation, because many file types failed to open without mime type specification, but mime type can be specified only at private method. Please, take a look at https://github.com/ElMaxo/thumbnailer/blob/master/thumbnailer.go#L105. I think this is a good solution. Also, proportional scaling can be added by height, not only by width.

bakape commented 3 years ago

There is no convenient way to create proportionally scaled thumbnails now. https://github.com/ElMaxo/thumbnailer/blob/master/thumbnailer.go#L105

150x150 or anything you set is only the bounding box (I now see the docs are not too clear about this). The actual thumbnail dimensions are calculated here https://github.com/bakape/thumbnailer/blob/master/thumbnailer.c#L327-L335 If I understand correctly, what you need is to only scale by one dimension? That can be easily achieved by setting the dimension you don't want to scale by to a large number like math.MaxUint32.

we can't perform custom processing by manual ffmpeg context creation

What exactly do you need to do?

mime type can be specified only at private method

You can register more functions for MIME type detection with https://pkg.go.dev/github.com/bakape/thumbnailer#RegisterMatcher