【问题标题】:How to get this specific data about an image如何获取有关图像的特定数据
【发布时间】:2014-09-16 06:51:07
【问题描述】:

对于导入/导出工具,我需要获取有关图像的特定数据, 我有一个例子,但我不知道如何调用这种类型的数组/数据。 是否有标准的 PHP 函数来获取这些数据,还是我必须自己制作函数?

例子:

a:5:{
    s:5:"width";
    i:1024;
    s:6:"height";
    i:768;
    s:4:"file";
    s:22:"2014/09/Hydrangeas.jpg";
    s:5:"sizes";                
    a:4:{
        s:9:"thumbnail";                    
        a:4:{
            s:4:"file";
            s:22:"Hydrangeas-150x150.jpg";
            s:5:"width";
            i:150;
            s:6:"height";
            i:150;
            s:9:"mime-type";
            s:10:"image/jpeg";
        }
        s:6:"medium";
        a:4:{
            s:4:"file";
            s:22:"Hydrangeas-300x225.jpg";
            s:5:"width";
            i:300;
            s:6:"height";
            i:225;
            s:9:"mime-type";s:10:"image/jpeg";
        }
        s:14:"post-thumbnail";
        a:4:{
            s:4:"file";
            s:22:"Hydrangeas-672x372.jpg";
            s:5:"width";
            i:672;
            s:6:"height";
            i:372;
            s:9:"mime-type";s:10:"image/jpeg";
        }
        s:25:"twentyfourteen-full-width";
        a:4:{
            s:4:"file";
            s:23:"Hydrangeas-1024x576.jpg";
            s:5:"width";
            i:1024;
            s:6:"height";
            i:576;
            s:9:"mime-type";
            s:10:"image/jpeg";
        }
    }
    s:10:"image_meta";
    a:10:{
        s:8:"aperture";
        i:0;
        s:6:"credit";
        s:9:"?????``";
        s:6:"camera";
        s:0:"";
        s:7:"caption";
        s:0:"";
        s:17:"created_timestamp";
        i:1206376913;
        s:9:"copyright";
        s:21:"Microsoft Corporation";
        s:12:"focal_length";
        i:0;
        s:3:"iso";
        i:0;
        s:13:"shutter_speed";
        i:0;
        s:5:"title";
        s:0:"";
    }
}

上面是Wordpress生成的,不知道怎么弄的。

【问题讨论】:

  • 很可能是一个序列化数组
  • 我知道 wp_get_attachment_metadata() 但我想知道是否有一个 PHP 函数而不是 Wordpress 函数,因为我不在 Wordpress 文件中工作。

标签: php wordpress metadata


【解决方案1】:

这是一个序列化数组。要将其转换为关联数组:

$array = unserialize($your_data);
var_dump($array);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    相关资源
    最近更新 更多