clearExif(); if ($exif === null) { $exif = new PelExif(); $jpeg->setExif($exif); $tiff = new PelTiff(); $exif->setTiff($tiff); } $tiff = $exif->getTiff(); $ifd0 = $tiff->getIfd(); if ($ifd0 === null) { $ifd0 = new PelIfd(PelIfd::IFD0); $tiff->setIfd($ifd0); } $software_name = 'Example V2'; $software = $ifd0->getEntry(PelTag::SOFTWARE); if ($software === null) { $software = new PelEntryAscii(PelTag::SOFTWARE, $software_name); $ifd0->addEntry($software); $resave_file = 1; } else { $software->setValue($software_name); $resave_file = 1; } if ($resave_file == 1 && ! file_put_contents($filename, $jpeg->getBytes())) { // if it was okay to resave the file, but it did not save correctly } } catch (Exception $e) { $this->fail('Test should not throw an exception'); } } }