/* We need to check if the image already had a description stored. */ if ($desc == null) { /* The was no description in the image. */ println('Added new IMAGE_DESCRIPTION entry with "%s".', $description); /* * In this case we simply create a new PelEntryAscii object to hold * the description. The constructor for PelEntryAscii needs to know * the tag and contents of the new entry. */ $desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description); /* * This will insert the newly created entry with the description * into the IFD. */ $ifd0->addEntry($desc); } else { /* An old description was found in the image. */ println('Updating IMAGE_DESCRIPTION entry from "%s" to "%s".', $desc->getValue(), $description); /* The description is simply updated with the new description. */ $desc->setValue($description); } /* * At this point the image on disk has not been changed, it is only * the object structure in memory which represent the image which has * been altered. This structure can be converted into a string of * bytes with the getBytes method, and saving this in the output file * completes the script. */ println('Writing file "%s".', $output); $file->saveFile($output);