使用php复制,调整大小,移动图像

Tho*_*ggi 2 php image image-resizing image-scaling

我正在寻找复制,调整大小和移动图像.这与wordpress在上传时如何创建不同大小的图像类似.我希望这可以执行,而不会在运行页面时上传任何内容.

例:

$imagePath = 'http://example.com/images/myimageonserver.jpg';
$newImagePath = 'http://example.com/images/new/myimageonserver.jpg';
$newImageWidth = 300;
$newImageHeight = 200;
Run Code Online (Sandbox Code Playgroud)

有谁知道会这样做的脚本?或者一些有用的功能可以完成这项工作.

loc*_*zak 5

你试过GD库吗?很强大.


roc*_*est 5

我刚才写了这个类来包装GD库函数.

你可以这样称呼它:

$image = new Image('original/path/to.file', 'destination/of/resized.file');
$image->resize(300, 200);
$image->output();
$image->clean();
Run Code Online (Sandbox Code Playgroud)

更新:

该类不再如上所述起作用.
这是一个新的例子:

$image = new Image();
$image->source('original/path/to.file');
$image->destination('destination/of/resized.file');
$image->Manipulate->Resize(300,200);
$image->output();
$image->clean();
Run Code Online (Sandbox Code Playgroud)