如何获取有关图像的特定数据

时间:2014-09-16 06:51:08

标签: php wordpress metadata

对于导入/导出工具,我需要获取有关图像的特定数据, 我有一个例子,但我不知道如何调用这种类型的数组/数据。 有没有标准的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生成的,我不知道如何。

1 个答案:

答案 0 :(得分:1)

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

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