Anyone can listed down best way (codes, github, example, tutorial etc) to implement multiple sizes and dimensions thumbnail of images?

Example

Original image with max width 1600px:
https://2.bp.blogspot.com/-SY0IDekOt...Sg%2BGolok.jpg


Thumbnail with width 658px and height is automatically follow aspect ratio:
https://2.bp.blogspot.com/-SY0IDekOt...Sg%2BGolok.jpg


Thumbnail with width 658px and height 309px, If width or height is greater than size , crop it from Center and Middle:
https://2.bp.blogspot.com/-SY0IDekOt...Sg%2BGolok.jpg

THANKS IN ADVANCE!