Many developers spend time writing code designed to extract a very specific number of words or characters from a piece of text. This text sample, often drawn from a blog post or comment, is usually displayed with a link that leads the user to read more.
It may seem counter-intuitive to use anything other than CSS or PhotoShop to resize images: why on earth would you rescale an image with a server-side technique when the same could be done easily and quickly with a modification to the image’s width and height in your code?
The need for a server-side image resize will often occur when you are interacting with a service external to your own site: an API that requests an image in a particular size and format, for example. Another possibility is file uploads: if you allow users to upload images to your site, you’ll want to be sure they are scaled and cropped to specific dimensions. Under such circumstances, CSS is useless: the image must be the right size and format before it is used. Another good example is social media sites’ request for a thumbnail image to associate with a web page or blog post, during a “share” or “like” action.