代码之家  ›  专栏  ›  技术社区  ›  Ross

用PHP-GD嵌入IPTC图像数据

  •  2
  • Ross  · 技术社区  · 17 年前

    iptcembed()

    我已在最终产品中验证过:

    // Embed the IPTC data
    $content = iptcembed($data, $path);
    
    // Verify IPTC data is in the end image
    $iptc = iptcparse($content);
    var_dump($iptc);
    

    // Save the edited image
    $im = imagecreatefromstring($content);
    imagejpeg($im, 'phplogo-edited.jpg');
    imagedestroy($im);
    
    // Get data from the saved image
    $image = getimagesize('./phplogo-edited.jpg');
    
    // If APP13/IPTC data exists output it
    if(isset($image['APP13']))
    {
        $iptc = iptcparse($image['APP13']);
        print_r($iptc);
    }
    else
    {
        // Otherwise tell us what the image *does* contain
        // SO: This is what's happening
        print_r($image);
    }
    

    avaliable here

    1. Image output
    2. Data output
    1 回复  |  直到 12 年前
        1
  •  3
  •   A J    10 年前

    getimagesize Imageinfo 其中包含您需要的信息。

    从手册中:

    iptcparse() 函数将二进制APP13标记解析为可读的内容。

    所以你可以这样使用它:

    <?php
    $size = getimagesize('./phplogo-edited.jpg', $info);
    if(isset($info['APP13']))
    {
        $iptc = iptcparse($info['APP13']);
        var_dump($iptc);
    }
    ?>
    

    推荐文章