1

这是https://stackoverflow.com/a/21074207/3269910的一个连续问题

解决方案似乎很好 c0.0.851.315

但 c0.0 值指向图像的 0x0 位置

我想要的是带有 offset_y 的图像。如果 offset_y: 20,

即,我想要相同的大小和图像的一部分,我在 api 调用中的页面时间轴中看到的内容。

是否有可能做到这一点 ?

注意:如果我将 c0.0 的零值更改为其他值,则它指向像素,但我认为 offset_y 是 %。

谢谢你的帮助。

4

1 回答 1

1

我与 Facebook 平台团队进行了讨论;

他们还没有准备好与我们分享手动计算。

是的,可以使用您的 API offset_y 值手动计算 c0.XXXX 的值。

这是我的PHP代码。

$fb_page_cover_json  =  json_decode( file_get_contents( 'https://graph.facebook.com/11111111?fields=cover'));

$fb_cover_image_url = $fb_page_cover_json->cover->source;

$image_info = getimagesize($fb_cover_image_url);
$image_width = $image_info[0];
$image_height = $image_info[1];                 

echo getTop($fb_page_cover_json->cover->offset_y,$image_width,$image_height);


function getTop($offset_y,$image_width,$image_height) {
    $cover_w = 851;
    $cover_h = 315;
    $img_w = $image_width;
    $img_h = $image_height;
    $real_img_h = ($cover_w * $img_h / $img_w) - $cover_h;
    $result = ($real_img_h * $offset_y / 100 * -1);

    return floor($result);
}

getTop 方法将返回 c0.XXX 值。

希望这对某人有所帮助。

于 2014-08-29T13:16:46.280 回答