Search code examples
phpimage-manipulationthumbnailsavatars

Reducing size of user avatars? - creating thumbnails


User of my site upload images which are used as avatars. I have set a upload limit size of 2 MB. At most places I only require thumbnails. But users upload images with far bigger resolutions. I store these files on my file-system.

How can i create thumbnails and store them instead of large sized files?


Solution

  • Depending on your installation / server setup, you have several possibilities.

    I would say that I've quite never seen a server without GD installed -- for Imagick, its less likely to be installed by default :-(


    Another solution might be to call the convert command-line utility (it comes with ImageMagick -- independantly of any PHP extension), using something like exec to call it.

    Advantage, with that, would be that you wouldn't be limited by memory_limit, as the resizing would be performed by an external tool -- but, of course, it also means that your application will rely on an external tool, which is not always nice...


    If necessary, there are plenty of tutorials about GD ; for instance, those might interest you :