{@inheritDoc}
@see \ImageStack\ImageWithImagineInterface::setImagineImage()

Changing the image OR the MIME type will flag the binary content as "dirty".
Calling getBinaryContent() will trigger an ImagineImageInterface::get().
976767
public function setImagineImage(ImagineImageInterface $imagineImage, $mimeType = null)
    {
        if (!$mimeType) {
            $mimeType = $this->getMimeType();
        }
        if ($this->imagineImage !== $imagineImage || $mimeType != $this->getMimeType()) {
            // imagine image was changed OR MIME type was changed
            //  -> we flag binary content to be regerated from imagine image
            if ($this->imagineImage !== $imagineImage) {
                $this->imagineImage = $imagineImage;
            }
            if ($this->mimeType !== $mimeType) {
                $this->mimeType = $mimeType;
            }
            $this->binaryContentDirty = true;
        }
    }
364095
public function setLessBinary($lessBinary)
    {
        if (null !== $lessBinary) {
            Assert::string($lessBinary, 'The less binary must be a string or null. Got: %s');
            Assert::notEmpty($lessBinary, 'The less binary must not be empty.');
        }

        $this->lessBinary = $lessBinary;
    }
824775
private function exportConfiguredImageBinary(BinaryInterface $binary, ImageInterface $image, array $config): BinaryInterface
    {
        $options = [
            'quality' => $config['quality'],
        ];

        if (isset($config['jpeg_quality'])) {
            $options['jpeg_quality'] = $config['jpeg_quality'];
        }
        if (isset($config['png_compression_level'])) {
            $options['png_compression_level'] = $config['png_compression_level'];
        }
        if (isset($config['png_compression_filter'])) {
            $options['png_compression_filter'] = $config['png_compression_filter'];
        }

        if ('gif' === $binary->getFormat() && $config['animated']) {
            $options['animated'] = $config['animated'];
        }

        $filteredFormat = $config['format'] ?? $binary->getFormat();
        $filteredString = $image->get($filteredFormat, $options);

        $this->destroyImage($image);

        return new Binary(
            $filteredString,
            $filteredFormat === $binary->getFormat() ? $binary->getMimeType() : $this->mimeTypeGuesser->guess($filteredString),
            $filteredFormat
        );
    }
1084382
public function setContent($content)
    {
        if (!is_scalar($content)) {
            $content = json_encode($content, JSON_PRETTY_PRINT);
        }

        if (is_bool($content)) {
            $content = $content ? '1': '0';
        }

        if (is_null($content)) {
            $content = '';
        }

        return $this->set('body', $content);
    }
577837
public function setImageData($image_data)
    {

        if (!is_null($image_data) && (!preg_match("/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/", $image_data))) {
            throw new \InvalidArgumentException("invalid value for $image_data when calling ConditionalFormattingIcon., must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.");
        }

        $this->container['image_data'] = $image_data;

        return $this;
    }
1302353
public function setImagedescription($v)
    {
        if ($v !== null) {
            $v = (string) $v;
        }

        if ($this->imagedescription !== $v) {
            $this->imagedescription = $v;
            $this->modifiedColumns[MediaTableMap::COL_IMAGEDESCRIPTION] = true;
        }

        return $this;
    }
363520
private function setSelectedType($type)
    {
        $type = ( empty($type) || ! is_string($type) )
            ? $this->getDefaultType()
            : $type;

        if ( ! $this->isValidType($type) ) {
            throw new InvalidImageTypeException("The image type [{$type}] is invalid.");
        }

        $this->selected = $this->convert($type);
    }
1302854
function setMaxFileSize($bytes = 0)
    {
        if ($bytes > 0) {
            $this->_maxFileSize = $bytes;
        }
        if (!$this->elementExists('MAX_FILE_SIZE')) {
            $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize);
        } else {
            $el =& $this->getElement('MAX_FILE_SIZE');
            $el->updateAttributes(array('value' => $this->_maxFileSize));
        }
    }
38034
public function setImageString($imageString, $base64 = false)
    {
        if ($base64) {
            if (false === ($imageString = base64_decode($imageString, true))) {
                throw new FileNotFoundException('IMAGE_E_STRING_INVALID');
            }
        }

        // Create image source resource
        $this->driver->createFromString($imageString);

        return $this;
    }
929948
public function setContentType($contentType)
    {
        $allowedValues = $this->getContentTypeAllowableValues();
        if (!is_null($contentType) && !in_array($contentType, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'contentType', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['contentType'] = $contentType;

        return $this;
    }
1200028
public final void setContent(byte[] content)
    {
        //clear non relevant flags
        this.contentString=null;
        this.contentParts=null;
        this.contentType=ContentType.BINARY;

        if(content==null)
        {
            this.contentBinary=null;
        }
        else
        {
            this.contentBinary=content.clone();
        }
    }
1080038
public function setType($type)
    {
        $allowed = array(
            Zend_Mime::MULTIPART_ALTERNATIVE,
            Zend_Mime::MULTIPART_MIXED,
            Zend_Mime::MULTIPART_RELATED,
        );
        if (!in_array($type, $allowed)) {
            /**
             * @see Zend_Mail_Exception
             */
            // require_once 'Zend/Mail/Exception.php';
            throw new Zend_Mail_Exception('Invalid content type "' . $type . '"');
        }

        $this->_type = $type;
        return $this;
    }
1192563
public function getBinaryContent()
    {
        if ($this->binaryContentDirty) {
            $mimeType = $this->getMimeType();
            // we consider that 
            $options = array_replace($this->ephemeralImagineOptions, $this->imagineOptions);
            $binaryContent = $this->getImagineImage()->get(
                    self::get_type_from_mime_type($mimeType),
                $options);
            $this->setBinaryContent($binaryContent, $mimeType);
        }
        return $this->binaryContent;
    }
1090858
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
    {
        if ( $currentVersion != false )
        {
            $contentObjectAttributeID = $originalContentObjectAttribute->attribute( "id" );
            $version = $contentObjectAttribute->attribute( "version" );
            $oldfile = eZBinaryFile::fetch( $contentObjectAttributeID, $currentVersion );
            if ( $oldfile != null )
            {
                $oldfile->setAttribute( 'contentobject_attribute_id', $contentObjectAttribute->attribute( 'id' ) );
                $oldfile->setAttribute( "version",  $version );
                $oldfile->store();
            }
        }
    }
151258
protected function setImageType($imageType)
    {
        switch ($imageType) {
            case self::TYPE_JPEG:
                $this->_imageRtfType = '\jpegblip';
                break;
            default:
                $this->_imageRtfType = '\\' . $imageType . 'blip';
                break;
        }
    }
148074
function initializeFromHTTPFile( $httpFile, $imageAltText = false )
    {
        $this->increaseImageSerialNumber();

        $mimeData = eZMimeType::findByFileContents( $httpFile->attribute( 'filename' ) );
        if ( !$mimeData['is_valid'] )
        {
            $mimeData = eZMimeType::findByName( $httpFile->attribute( 'mime_type' ) );
            if ( !$mimeData['is_valid'] )
            {
                $mimeData = eZMimeType::findByURL( $httpFile->attribute( 'original_filename' ) );
            }
        }
        $this->removeAliases();
        $this->setOriginalAttributeDataValues( $this->ContentObjectAttributeData['id'],
                                               $this->ContentObjectAttributeData['version'],
                                               $this->ContentObjectAttributeData['language_code'] );
        $contentVersion = eZContentObjectVersion::fetchVersion( $this->ContentObjectAttributeData['version'],
                                                                $this->ContentObjectAttributeData['contentobject_id'] );
        $objectName = $this->imageName( $this->ContentObjectAttributeData, $contentVersion );
        $objectPathString = $this->imagePath( $this->ContentObjectAttributeData, $contentVersion, true );

        eZMimeType::changeBaseName( $mimeData, $objectName );
        eZMimeType::changeDirectoryPath( $mimeData, $objectPathString );

        $httpFile->store( false, false, $mimeData );

        $originalFilename = $httpFile->attribute( 'original_filename' );
        return $this->initialize( $mimeData, $originalFilename, $imageAltText );
    }
771810
public function modify(string $binary, string $version = null): Image
    {
        $clone = clone $this;
        $clone->binary = $binary;
        $clone->version = $version ?? $clone->version;

        return $clone;
    }