如何在 C# .net 中创建 wordpress 图像缩略图元数据(大小/exif/iptc)
how to create wordpress image thumbnail metadata (size / exif / iptc) in c# .net
这是 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。
您正在查看序列化的 PHP 变量。
- s:10为长度为10的字符串(见s:5:"width")
- i:0 是整数 '0'
- a:4 是一个有 4 个条目的数组
这是从 http://php.net/manual/en/function.serialize.php#66147
获取的所有内容的细目分类
Anatomy of a serialize()'ed value:
String:
s:size:value; (String values are always in double quotes)
Integer:
i:value;
Boolean:
b:value; (does not store "true" or "false", does store '1' or '0')
Null:
N;
Array:
a:size:{key definition;value definition;(repeated per element)}
Array keys are always integers or strings
"null => 'value'" equates to 's:0:"";s:5:"value";',
"true => 'value'" equates to 'i:1;s:5:"value";',
"false => 'value'" equates to 'i:0;s:5:"value";',
"array(whatever the contents) => 'value'" equates to an "illegal offset type" warning because you can't use an
array as a key; however, if you use a variable containing an array as a key, it will equate to 's:5:"Array";s:5:"value";',
and attempting to use an object as a key will result in the same behavior as using an array will.
对象:
O:strlen(object name):object name:object size:{s:strlen(属性 name):属性 name:property definition;(repeated per 属性)}
这是未序列化的元数据中的第一个数组:
(记住 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
这是 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。
您正在查看序列化的 PHP 变量。
- s:10为长度为10的字符串(见s:5:"width")
- i:0 是整数 '0'
- a:4 是一个有 4 个条目的数组
这是从 http://php.net/manual/en/function.serialize.php#66147
获取的所有内容的细目分类Anatomy of a serialize()'ed value:
String:
s:size:value; (String values are always in double quotes)Integer:
i:value;Boolean:
b:value; (does not store "true" or "false", does store '1' or '0')Null:
N;Array:
a:size:{key definition;value definition;(repeated per element)}
Array keys are always integers or strings"null => 'value'" equates to 's:0:"";s:5:"value";',
"true => 'value'" equates to 'i:1;s:5:"value";',
"false => 'value'" equates to 'i:0;s:5:"value";',"array(whatever the contents) => 'value'" equates to an "illegal offset type" warning because you can't use an array as a key; however, if you use a variable containing an array as a key, it will equate to 's:5:"Array";s:5:"value";', and attempting to use an object as a key will result in the same behavior as using an array will.
对象:
O:strlen(object name):object name:object size:{s:strlen(属性 name):属性 name:property definition;(repeated per 属性)}
这是未序列化的元数据中的第一个数组:
(记住 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