将所有具有一定宽度的图像重写为不同尺寸的脚本?
我正在使用 PHP 的 GD 库。
基本上,我进行了设计更改,需要调整一大堆具有一定宽度的图像的大小。
即任何 876px 宽的东西都需要是 828px。
有没有办法循环遍历目录中的所有 JPG 文件,检查它们的宽度尺寸,如果它们等于 X,则获取它们现有的文件名,重新缩放到相同的名称?
I am using the GD library with PHP.
Basically, I've made a design change and need to resize a whole bunch of images that are a certain width.
ie anything that is 876px wide needs to be 828px.
Is there a way to loop through all JPG files in a directory, check their width dimension, and if they equal X then grab their existing file name, rescale down to the same name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需要使用
imagecopyresampled()
中一个循环。Just need to use
imagecopyresampled()
in a loop.那里有很多图像调整大小脚本...只需谷歌...但如果您想自己构建一些东西,您基本上会使用 getimagesize 和 imagecopyresampled
There are a lot of image resize scripts out there...just google... but if you're looking to build something yourself, you would basically use getimagesize and imagecopyresampled