【发布时间】:2019-07-18 08:06:39
【问题描述】:
我将图像上传到我的 S3 服务器没有问题(所以我知道我的图像路径是合法的),但是当我尝试使用 Liip/Imagine 服务创建一些重新调整大小的图像时,Liip/Imagine 可以'找不到我上传的图片。
我将图像路径转储如下:
$idFile = $form['idFile']->getData();
dump($idFile);
die();
这是转储的样子:
ProfileController.php on line 340:
UploadedFile {#64 ▼
-test: false
-originalName: "file-name.png"
-mimeType: "image/png"
-error: 0
path: "/tmp"
filename: "php09sJr3"
basename: "php09sJr3"
pathname: "/tmp/php09sJr3"
extension: ""
realPath: "/tmp/php09sJr3"
aTime: 2019-02-24 22:54:00
mTime: 2019-02-24 22:54:00
cTime: 2019-02-24 22:54:00
inode: 12586620
size: 97901
perms: 0100600
owner: 997
group: 995
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
}
我知道这个路径 (/tmp/php09sJr3) 是合法的,因为我的文件都完美地上传到了我的 S3 存储桶,但是当我尝试在我的控制器中创建缩略图时:
public function saveProfileEditAction(Request $request, FilterService $imagine)
{
$form = $this->createForm(UserProfileType::class, $user);
$form->handleRequest($request);
if($form->isSubmitted() && $form->isValid()) {
$idFile = $form['idFile']->getData();
if ($idFile != null){
// this command right here
$resourcePath = $imagine->getUrlOfFilteredImage($idFile->getPathName(), 'my_thumb');
我收到以下错误:
Source image not resolvable "/tmp/php09sJr3" in root path(s) "/var/www/vhosts/mywebsite.com/public"
让这更令人困惑的是,当我检查时,/tmp 或 /var/www/vhosts/mywebsite.com/public/tmp 中没有任何内容,但是我的文件仍然完美地上传到 S3。
这是我的配置 liip_imagine.yaml 文件:
liip_imagine :
# configure resolvers
resolvers :
# setup the default resolver
default :
# use the default web path
web_path : ~
# your filter sets are defined here
filter_sets :
# use the default cache configuration
cache : ~
# the name of the "filter set"
my_thumb :
# adjust the image quality to 75%
quality : 75
# list of transformations to apply (the "filters")
filters :
# create a thumbnail: set size to 120x90 and use the "outbound" mode
# to crop the image when the size ratio of the input differs
thumbnail : { size : [120, 90], mode : outbound }
thumb_square : { size : [300, 300], mode : outbound }
thumb_rectangle_md : { size : [670, 400], mode : outbound }
thumb_hd : { size : [1920, 1080], mode : outbound }
# create a 2px black border: center the thumbnail on a black background
# 4px larger to create a 2px border around the final image
background : { size : [124, 94], position : center, color : '#000000' }
如何正确告诉 Liip/Imagine 我上传文件的文件路径?
【问题讨论】: