如何在普通PHP中使用图像处理库Glide
我正在尝试为我的一个项目使用PHP Glide图像处理库。我遵循了他们在这里提供的文件- 我已经创建了一个“routes.php”。这是我的密码如何在普通PHP中使用图像处理库Glide,php,image-manipulation,php-glide,Php,Image Manipulation,Php Glide,我正在尝试为我的一个项目使用PHP Glide图像处理库。我遵循了他们在这里提供的文件- 我已经创建了一个“routes.php”。这是我的密码 <?php require 'vendor/autoload.php'; // Setup Glide server $server = League\Glide\ServerFactory::create([ 'source' => 'img/users/source', 'cache' => 'img/users
<?php
require 'vendor/autoload.php';
// Setup Glide server
$server = League\Glide\ServerFactory::create([
'source' => 'img/users/source',
'cache' => 'img/users/cache',
]);
// echo '<pre>';
// print_r($server);
// echo '</pre>';
// You could manually pass in the image path and manipulations options
//$server->outputImage('users/1.jpg', ['w' => 300, 'h' => 400]);
$server->outputImage('img/users/source/1.jpg', ['w' => 300, 'h' => 400]);
将此项添加到需求旁边:
<?
require '../vendor/autoload.php';
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use League\Glide\ServerFactory;
// Setup Glide server
$server = League\Glide\ServerFactory::create([
'source' => '../assets/img/source',
'cache' => '../assets/img/cache',
]);
// You could manually pass in the image path and manipulations options
$server->outputImage('01.jpg', ['w' => 300, 'h' => 400]);
像这样:
你好,谢谢你的回复。我试过了,但还是不起作用。我又犯了同样的错误。你能给出一些对你有用的示例代码吗?嘿,编辑了答案,上面的示例对我有用。另外,我已经更改了文件夹,所以我需要“../”,在您的情况下,您不能告诉我您的文件和文件夹结构吗?一切看起来都和我的相似。我已经用文件夹结构的图像更新了我的帖子。我在“assets/img/source”和“assets/img/cache”中有图像,还有一个文件夹,其中我有一个脚本“服务”图像,因为我没有使用框架。我明白了。在最后一行,而不是这个$server->outputImage('img/users/source/1.jpg',['w'=>300,'h'=>400])代码>应该是$server->outputImage('1.jpg',['w'=>300,'h'=>400])代码>现在已修复。谢谢。我真的很感谢你的帮助。我有相同的代码结构,它没有显示任何内容。请帮助!
<?
require '../vendor/autoload.php';
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use League\Glide\ServerFactory;
// Setup Glide server
$server = League\Glide\ServerFactory::create([
'source' => '../assets/img/source',
'cache' => '../assets/img/cache',
]);
// You could manually pass in the image path and manipulations options
$server->outputImage('01.jpg', ['w' => 300, 'h' => 400]);