den*_*icz 1 php image-manipulation codeigniter
我正在编写一个从Dropbox下载文件的脚本,应该调整该图像的大小,然后将其拍摄到S3存储桶.
出于某种原因,我无法让图像调整大小.
我不断收到以下错误:
图像的路径不正确.您的服务器不支持处理此类图像所需的GD功能.
代码库:
public function resize_test() {
$postcard_assets = $this->conn->getPostcardDirContent("folder_name", "Photos", TRUE);
foreach($postcard_assets['contents'] as $asset) {
$file = pathinfo($asset['path']);
$original_file = $this->conn->downloadFile($asset['path']);
$raw_file = sha1($file['basename']);
$s3_file_name = "1_{$raw_file}.{$file['extension']}";
$this->resize_photo($original_file);
$this->s3->putObject($s3_file_name, $original_file, 's3-bucket-name', 'public-read');
$s3_check = $this->s3->getObjectInfo($s3_file_name, 's3-bucket-name');
if($s3_check['content-length'] > 0) {
krumo($s3_check);
exit();
}
}
}
private function resize_photo($photo) {
$config['image_library'] = 'imagemagick';
$config['source_image'] = $photo;
$config['maintain_ratio'] = TRUE;
$config['width'] = 640;
$config['height'] = 480;
$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()) {
exit($this->image_lib->display_errors());
}
}
Run Code Online (Sandbox Code Playgroud)
Dropbox API DownloadFile:
public function downloadFile($file) {
$this->setTokens();
return $this->conn->getFile($file);
}
Run Code Online (Sandbox Code Playgroud)
谁知道我可能做错了什么?
小智 14
不要多次加载image_lib.在autoload库中添加image_lib并进行更改
$this->load->library('image_lib', $config);
Run Code Online (Sandbox Code Playgroud)
至
$this->image_lib->initialize($config);
Run Code Online (Sandbox Code Playgroud)