AWS SDK PHP版本2 - 图像在检索维度? [英] AWS SDK PHP version 2 - retreiving image dimensions?

查看:166
本文介绍了AWS SDK PHP版本2 - 图像在检索维度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检索存储在Amazon S3?

图像的尺寸

如果答案是否定的,还有周围没有任何其他方式比下载图像到我的服务器等来这听起来低效?

我在使用AWS SDK版本2的PHP。

我一直在寻找通过什么从以下code返回,但似乎并没有给的尺寸。

  $结果= $ S3->的getObject(阵列(
    '斗'=> BUCKET_NAME,
    '关键'=> KEY_NAME
));

后续代码var_dump($结果);
 

解决方案

由于缺乏反应,我会presume这是不可能的......没r3ally想用JavaScript做,但我就是这样做到了。

 < IMG SRC =image.jpg的ID =形象/>

<脚本>
//这将运行映像加载之后
$('#图像)。负载(函数(){
    //使用低于code得到的高度和宽度
    //的document.getElementById(图像)。宽
    //的document.getElementById(图像)。高度
});
< / SCRIPT>
 

Is it possible to retrieve the dimensions of an image stored on Amazon S3?

If the answer is no, are there any other ways around it other than downloading the image to my server to which sounds inefficient?

I'm using version 2 of the AWS SDK for PHP.

I've been looking through what is returned from the following code but doesn't seem to give dimensions.

$result = $s3->getObject(array(
    'Bucket' => 'BUCKET_NAME',
    'Key'    => 'KEY_NAME'
));

var_dump($result);

解决方案

Due to lack of response I'll presume it's not possible... Didn't r3ally want to do it with JavaScript but this is how I did it.

<img src="image.jpg" id="image" />

<script>
// This runs after the image has loaded
$('#image').load(function() {
    // Use the below code to get the height and width
    // document.getElementById('image').width
    // document.getElementById('image').height
});
</script>

这篇关于AWS SDK PHP版本2 - 图像在检索维度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆