Amazon S3 png 文件没有透明度

问题描述 投票:0回答:1

我不确定我做错了什么,但上传到 S3 Amazon 存储桶的 PNG 文件显示白色而不是透明,即使本地文件确实显示透明度。这是我所拥有的:

$thumb = \PhpThumbFactory::create(
  $content,
  array(
    'jpegQuality' => 100
  ),
  true
);

$thumb->setFormat('PNG');

ob_start();
$thumb->show(true);
$content = ob_get_clean();

//This part is for testing purposes, I store the file locally to see that the transparency is there
$file = 'picture' . '-' . time() . '.png';
file_put_contents($file, $content); //The file created is an image which perfectly shows the transparent, as it should be

//The code below should upload the same file, but somehow it replaces transparency with a white color. 
$S3 = new Zend_Service_Amazon_S3($myKey, $mySecret);
$response = $S3->putObject(
  $bucket,
  $content,
  array(
    Zend_Service_Amazon_S3::S3_CONTENT_TYPE_HEADER => 'image/png',
    Zend_Service_Amazon_S3::S3_ACL_HEADER => Zend_Service_Amazon_S3::S3_ACL_PUBLIC_READ
  )
);

我上传时是否遗漏了什么?我应该在存储桶上配置什么吗?

php zend-framework amazon-s3 gd
1个回答
0
投票

我也遇到了类似的问题,但后来意识到S3实际上是在上传透明图像。由于我用来包装图像(材质 UI)的组件而发生了不透明问题。

© www.soinside.com 2019 - 2024. All rights reserved.