使用 php 复制、调整大小、移动图像
我正在寻找复制、调整大小和移动图像的方法。这类似于 WordPress 在上传时创建不同尺寸的图像的方式。我希望它是可执行的,而无需上传运行页面时运行的任何内容。
示例:
$imagePath = 'http://example.com/images/myimageonserver.jpg';
$newImagePath = 'http://example.com/images/new/myimageonserver.jpg';
$newImageWidth = 300;
$newImageHeight = 200;
有人知道可以执行此操作的脚本吗?或者一些可以完成此任务的有用功能。
I'm looking to copy, resize, and move an image. This is simular to how wordpress creates different sizes of the images when you upload. I want this to be executable without uploading anything just running when you run the page.
example:
$imagePath = 'http://example.com/images/myimageonserver.jpg';
$newImagePath = 'http://example.com/images/new/myimageonserver.jpg';
$newImageWidth = 300;
$newImageHeight = 200;
Does anyone know a script that will do this? Or some useful functions that can get this done.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我不确定这是否是您想要实现的目标,但看看这是否有帮助:
http://php.net/manual/en/function.imagecopyresized.php
I'm not to sure if this is what you're trying to accomplish, but see if this helps:
http://php.net/manual/en/function.imagecopyresized.php
您可以使用基于GD库的ImageWorkshop类:http://phpimageworkshop.com/(在github上:https://github.com/Sybio/ImageWorkshop)
You can use ImageWorkshop class which based on the GD library: http://phpimageworkshop.com/ (on github: https://github.com/Sybio/ImageWorkshop)
我不久前写了这个类来包装GD库函数。
您可以这样调用它:
更新:
此类不再按上面的说明运行。
这是一个新的例子:
I wrote this Class a while ago to wrap the GD library functions.
You can call it like:
update:
This class no longer functions as explained above.
Here is a new example:
您是否尝试过GD 库?非常强大。
Have you tried the GD library? Very powerful.
使用 GD Lib 或 ImageMagick。
对于 ImageMagick 来说,它是 resizeImage 函数。
Use the GD Lib or ImageMagick.
With ImageMagick it is the resizeImage function.