Search code examples
imageuploadstoragejpegfile-type

What is the purpose of converting all images users upload to the same filetype?


I've noticed that many website change all their user-uploaded images to .jpg or .png format. I am wondering what are the pros and cons of converting images to the same format.

Possible points of consideration are:

  • Security (I heard it is possible to put malicious code in images of certain filetypes)
  • Storage
  • Image quality
  • Scalability

  • Solution

  • Typically, after a user uploads a photo to a web application, some processing will be done to the image. For example, if a user uploads an avatar image, it will be cropped so that it is square, and resized so that all avatar images are the same size. Sometimes, we may want multiple resolutions of the same image for different display purposes (avatar icon vs. profile page). ImageMagick is often the tool of choice for performing image processing on the server.