保存时将图像大小(尺寸)添加到图像名称

时间:2014-10-04 20:20:46

标签: image rename dimensions

我找不到任何答案。因为我的大学项目,我必须这样做。 (笨...)。从网页下载某些图像时,使用服务器上的名称保存图像。但我必须在图像名称中添加“x”和“y”尺寸。

任何解决方案?它可以是php或jQuery(或者只是HTML?我不这么认为)。谢谢

1 个答案:

答案 0 :(得分:0)

在PHP上尝试命令以获取图像属性

list($width, $height, $type, $attr) = getimagesize("img/flag.jpg");

然后重命名。

rename("img/flag.jpg", substr(filename, 0, -4).$width.$height.substr(filename, -4);)