/** * Register image element. * * @param IdmlImage $idmlImage containing mediaFilename and optionally containing imageContent (from parsed CDATA). * @param IdmlElement $idmlContainer is the wrapper of the image, which is needed for cropping operations. */ public function registerImage(IdmlImage $idmlImage, $idmlContainer) { $tmpPath = null; $containersAllowed = array('IdmlRectangle', 'IdmlPolygon'); // If the image data has come from embedded CDATA . . . if ($idmlImage->embeddedImage && strlen($idmlImage->imageContent) > 0) { $tmpPath = $this->FileManager->getTmpPath(); $registerFilename = $this->createImageFromCdata($idmlImage, $tmpPath); } else { // assemble the filename path, within the S3 bucket, and verify that it exists $registerFilename = $this->getImageFile($idmlImage); if ($registerFilename == null) { $idmlImage->mediaFilename .= " [image not found]"; return; } } // Crop the picture if asked to if ($idmlContainer != null && in_array(get_class($idmlContainer), $containersAllowed)) { if (MediaManager::isVectorImage($registerFilename)) { // skip for now, because cropping .ai is crashing IMagick } else { $this->cropImage($idmlImage, $idmlContainer, $registerFilename); } } // Does this image need to be converted? if (MediaManager::isConvertableImage($registerFilename)) { $idmlImage->mediaFilename = $this->processor->convertUnsupportedImageType($registerFilename); } }