简体   繁体   English

PHP图片缩放比例问题

[英]PHP image resize ratio issue

Php thumb resize image based on provided width and height, I am working on profile image which is: 130x130 Php 拇指根据提供的宽度和高度调整图像大小,我正在处理个人资料图像:130x130

While users are uploading image of long heights(rectangle) which leads to strecthed image in its width and when uploading long width image(rectangle) then strecthed, I hope you understand what I mean.当用户上传长高(矩形)的图像时,导致图像宽度被拉伸,当上传长宽图像(矩形)然后被拉伸时,我希望你明白我的意思。 Because when anyone uses a large square image it resize to correct 130x130 but longer width and height get strecthed.因为当任何人使用大方形图像时,它会调整大小以校正 130x130,但更长的宽度和高度会被拉伸。

I am thinking of having a good suggestion or idea to work around such images, either crop them from top to make them perfect square first.我正在考虑有一个很好的建议或想法来解决这些图像,要么从顶部裁剪它们,使它们首先成为完美的正方形。

Thanks, Najm.谢谢,纳吉姆。

Usually you will take the longer side, scale it up and scale the shorter side by the same percentage.通常,您会选择较长的一侧,将其放大,然后按相同的百分比放大较短的一侧。 One such snippet is here .一个这样的片段是here You can also prefill the canvas with a smooth background that fits with your overall design.您还可以使用适合您整体设计的平滑背景预填充画布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM