Search code examples
phpjpegexifiptc

Is there any workaround for getimagesize?


For some unknown reasons PHP getimagesize truncates my IPTC caption strings from JPGs. So iptcparse can only spit out what it gets. Is there any workaround?


Solution

  • First of all getimagesize() doesn't truncate anything! I thought, i could be a problem with the charset of IPTC ...

    Maybe this could help you

     <?php 
        $IPTC_Caption = ""; 
        $size = getimagesize( $image_path, $info ); 
        if (isset($info["APP13"])) { 
            if($iptc = iptcparse( $info["APP13"] ) ) { 
               $IPTC_Caption = str_replace( "\000", "", $iptc["2#120"][0] ); 
               if(isset($iptc["1#090"]) && $iptc["1#090"][0] == "\x1B%G") {
                    $IPTC_Caption = utf8_decode($IPTC_Caption); 
               }
           } 
        } 
     ?>