function loadwritedesc($file, $input_text, $input_text2, $input_text3){ $jpeg = new PelJpeg(); $tifff = $tiff=getBytes(); $jpeg->loadFile($file); $app1 = $jpeg->getSection(PelJpegMarker::APP1); $tiff = $app1->getTiff(); $ifd0 = $tiff->getIfd(); $exif = $ifd0->getSubIfd(PelTag::EXIF_IFD_POINTER); // create and overwrite image_description tag and write the text $describer = new PelEntryAscii(PelTag::XP_TITLE, $input_text); $ifd0->addEntry($describer); file_put_contents($file, $jpeg->getBytes()); }
XP_TITLE ładnie tworzy tytuł zdjęcia widoczny w Windowsie. I tu pojawia się problem, ponieważ tytuł tworzy tylko wtedy jeśli zdjęcie zostało zrobione np. aparatem lub istnieją już jakieś dane Exfif (czyt. sami je wpiszemy). Natomiast jeśli zdjęcie zostało utworzone w PHP ( imagecreatefromjpeg($zdjecie); ) to (prawdopodobnie) dane Exif nie istnieją i skrypt wywala błąd:
Cytat
Fatal error: Call to a member function getTiff() on a non-object in...
- nie mam pojęcia jak zadeklarować dane ExifW manualu znalazłem coś w tym stylu:
Cytat
getBytes (line 157)
Produce bytes for the Exif data.
return: bytes representing this object.
string getBytes ()
ale nie mam pojęcia czy to jest to i jak tego użyć. Proszę o pomoc, dziękuję.Produce bytes for the Exif data.
return: bytes representing this object.
string getBytes ()