【发布时间】:2018-09-04 15:34:05
【问题描述】:
我想使用 imagick 和 PHP
为存储在 Google 存储桶中的 PDF 文件生成缩略图图像
我在 google app engine(GAE) 标准环境
上部署我的应用程序
问题是我一直收到这个错误
Fatal error: Uncaught exception 'ImagickException' with message
'UnableToWriteBlob `magick--1noB3XBwJhgfn': Read-only file system
我知道应用程序部署到的文件系统是不可写的,但我需要一种方法来实现这一点...
这是我的代码
<?php
putenv('MAGICK_TEMPORARY_PATH='.sys_get_temp_dir());
$imagick = new Imagick();
// get the content of pdf url
$imagenblob=file_get_contents('http://www.pdf995.com/samples/pdf.pdf');
// read the content and load it inn imagick instance
$imagick->readimageblob($imagenblob);
// point to the first page, because I want thumbnail for first page
$imagick->setIteratorIndex(0);
// set image format
$imagick->setImageFormat('png');
// resize image
$imagick->resizeImage(320,320,Imagick::FILTER_LANCZOS,1,1);
// return the result
header("Content-Type: image/png");
$base64 = 'data:image/png;base64,' . base64_encode($imagick);
exit($base64);
如果我可以更改 imagick 用来编写的目录,但我无法做到这一点!
【问题讨论】:
-
如果目录是“只读”目录,或者换句话说,如果您没有这样做的权限,您将无法在该目录中写入任何数据,1- set正确的权限,或 2- 将您的拇指保存在您有权写入的另一个目录中, 3- 将您的拇指存储在云中(某些 API 或任何其他外部存储)或 4- 将其保存到 MYSQL 等数据存储中(不是一个好的选择)
-
我无法更改添加写入的权限....这在我的情况下是不允许的,我尝试更改 imagick 的写入目录但我无法实现...
标签: php google-app-engine pdf google-cloud-platform imagick