/** * Strip orientation from EXIF data for an image at a path. * * @param $filePath * * @return bool */ public function stripOrientationFromExifData($filePath) { if (!ImageHelper::canHaveExifData($filePath)) { return null; } $data = new \PelDataWindow(IOHelper::getFileContents($filePath)); // Is this a valid JPEG? if (\PelJpeg::isValid($data)) { $jpeg = $file = new \PelJpeg(); $jpeg->load($data); $exif = $jpeg->getExif(); if ($exif) { $tiff = $exif->getTiff(); $ifd0 = $tiff->getIfd(); // Delete the Orientation entry and re-save the file $ifd0->offsetUnset(\PelTag::ORIENTATION); $file->saveFile($filePath); } return true; } else { return false; } }