PHP Thumbnail Image Resizing with proportions

后端 未结 6 2210
终归单人心
终归单人心 2020-12-06 15:06

As a brief run down, I am currently making a dating type site. Users can create accounts and upload profile pictures (up to 8). In order to display these in the browse area

6条回答
  •  时光说笑
    2020-12-06 15:34

    You can do this with ImageMagick:

    convert susan.jpg -resize x200 susan_thumb.jpg
    

    This runs with a shell command, so in PHP you'd use shell_exec() to run the above command. I don't think you need any PHP extensions.

    A few flags can be found in the ImageMagick documentation to control the resizing operation. If I recall correctly, the x200 before the number means "scale with the same aspect ratio to 200px".

    I wrote an install guide for ImageMagick (and ghostscript): How to install, test, convert, resize PDF using ImageMagick, Ghostscript, Windows Vista/7 x64 based on my bumbling around, maybe it can help you.

    The other option is the GD library (detailed in dqhendricks answer). This is faster and apparently better documented, used for basic operations.

提交回复
热议问题