【问题标题】:how to create wordpress image thumbnail metadata (size / exif / iptc) in c# .net如何在 c# .net 中创建 wordpress 图像缩略图元数据(大小/exif/iptc)
【发布时间】:2015-07-03 14:42:09
【问题描述】:

这是 wordpress 缩略图元数据的一个示例:

a:6:{s:5:"width";i:250;s:6:"height";i:150;s:14:"hwstring_small";s:23:"height='77' width='128'";s:4:"file";s:33:"2014/09/13920503000128_PhotoA.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:4:{s:4:"file";s:33:"13920503000128_PhotoA-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:32:"13920503000128_PhotoA-100x65.jpg";s:5:"width";i:100;s:6:"height";i:65;s:9:"mime-type";s:10:"image/jpeg";}s:9:"art-thumb";a:4:{s:4:"file";s:32:"13920503000128_PhotoA-100x65.jpg";s:5:"width";i:100;s:6:"height";i:65;s:9:"mime-type";s:10:"image/jpeg";}s:7:"art-gal";a:4:{s:4:"file";s:33:"13920503000128_PhotoA-210x150.jpg";s:5:"width";i:210;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:10:"td_198x143";a:4:{s:4:"file";s:33:"13920503000128_PhotoA-198x143.jpg";s:5:"width";i:198;s:6:"height";i:143;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:11:{s:8:"aperture";i:0;s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";i:0;s:9:"copyright";s:0:"";s:12:"focal_length";i:0;s:3:"iso";i:0;s:13:"shutter_speed";i:0;s:5:"title";s:0:"";s:11:"orientation";i:0;}}

我怎样才能用 c# 做到这一点? 我不知道这个参数:(示例)s:10 或 i:0 或 a:4 或 s:33。

【问题讨论】:

    标签: c# wordpress image metadata exif


    【解决方案1】:

    您正在查看一个序列化的 PHP 变量。

    • s:10是一个长度为10的字符串(见s:5:"width")
    • i:0 是一个整数 '0'
    • a:4 是一个包含 4 个条目的数组

    这里是来自http://php.net/manual/en/function.serialize.php#66147的所有内容的细分

    serialize() 的值剖析:

    字符串:
    s:大小:值; (字符串值总是用双引号引起来)

    整数:
    我:价值;

    布尔值:
    b:值; (不存储“true”或“false”,存储“1”或“0”)

    空:
    N;

    数组:
    a:size:{键定义;值定义;(每个元素重复)}
    数组键总是整数或字符串

    "null => 'value'" 等同于 's:0:"";s:5:"value";',
    "true => 'value'" 等同于 'i:1;s:5:"value";',
    "false => 'value'" 等同于 'i:0;s:5:"value";',

    "array(whatever the contents) => 'value'" 等同于“非法偏移类型”警告,因为您不能使用 数组作为键;但是,如果您使用包含数组作为键的变量,它将等同于 's:5:"Array";s:5:"value";', 并且尝试将对象用作键将导致与使用数组相同的行为。

    对象:
    O:strlen(object name):object name:object size:{s:strlen(property name):property name:property definition;(repeated per property)}

    这是未序列化元数据中的第一个数组:

    (记住 php 中的数组键可以是字符串。php 数组几乎是哈希映射)

    Array
    (
        [width] => 250
        [height] => 150
        [hwstring_small] => "height='77' width='128'"
        [file] => "2014/09/13920503000128_PhotoA.jpg"
        [sizes] => Array
        (
            [thumbnail] => Array
            (
                [file] => "13920503000128_PhotoA-150x150.jpg"
                [width] => 150
                [height] => 150
                [mime-type] => "image/jpeg"
            )
        ...
    

    你可以反序列化其余的here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-10
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 2013-06-22
      相关资源
      最近更新 更多