Postita vastus 
 
Teema reiting:
  • 0Hääli - 0 keskmine
  • 1
  • 2
  • 3
  • 4
  • 5
iptc
08-16-2004, 03:55 PM
Postitus: #1
iptc
mul tõsine probleem.
mitte keegi ei tea ega oska öelda ka mis viga ja otsustasin siia pöörduda.
asi nimelt pildi iptc infos.
täpsemalt siis - kas keegi oskaks aidata scripti parandada - oleks tarvis kindel info salvestada iptc kindlale väljale.

Kood:
<?

// original file name
$image_name_old = "epood_pildid/FP008002.jpg";

// New file name
$image_name_new = "test/test.jpg";

// Reads the IPTC text in to the array '$iptc'
// The number after the '#' is the IPTC field
// Ex: $iptc["2#120"][0] is Caption
// $iptc["2#055"][0]; is Creation date
$size = GetImageSize ("$image_name_old",&$info);
$iptc_old = iptcparse ($info["APP13"]);

// Adding or replacing IPTC text
   // This ex. replace the original category or create it if it dos not exist
   $iptc_old["2#015"][0] = "Sport";
   // .. and adding more text to the original caption
   $iptc_old["2#120"][0] .= " More caption text";

   // Making the new IPTC string
   foreach (array_keys($iptc_old) as $s){
     // Finds the IPTC numbers
     $tag = str_replace("2#", "", $s);
     // Creating the string
     $iptc_new.= iptc_maketag(2, $tag, $iptc_old[$s][0]);
   }

// The original file and the new IPTC Text into $content
// Mode 0 - puts the image file into $content
// Mode 1 - puts the image file into $content and directly to the web client
// Mode 2 - puts the image file to web client
$mode = 0;
$content = iptcembed($iptc_new, $image_name_old, $mode);

// writes the new file
$fp = fopen($image_name_new, "w");
fwrite($fp, $content);
fclose($fp);

// Function to format the new IPTC text, (thanks to Thies C. Arntzen)
function iptc_maketag($rec,$dat,$val){
         $len = strlen($val);
         if ($len < 0x8000)
                 return chr(0x1c).chr($rec).chr($dat).
                 chr($len >> 8).
                 chr($len & 0xff).
                 $val;
         else
                 return chr(0x1c).chr($rec).chr($dat).
                 chr(0x80).chr(0x04).
                 chr(($len >> 24) & 0xff).
                 chr(($len >> 16) & 0xff).
                 chr(($len >> 8 ) & 0xff).
                 chr(($len ) & 0xff).
                 $val;
}

?>

see script peaks õpetuste järgi õige olema, aga millegipärast ta teeb küll faili, kuid ta ei kirjuta sinna seda õiget infot sisse, mida tarvis.
oskab keegi aidata ???
Külasta selle kasutaja veebisaiti Leia selle kasutaja kõik postitused
Tsiteeri seda postitust oma vastuses
Postita vastus 


Vali alamfoorum:



Võta ühendustSinu VeebiabiTagasi ülesTagasi sisu juurdeLihtsustatud versioonRSS voog