public function readImageBlob(EventInterface $event) {
        $eventName = $event->getName();
        $config = $event->getConfig();
        $jpegSizeHintEnabled = $config['optimizations']['jpegSizeHint'];

        if ($event->hasArgument('image')) {
            // The image has been specified as an argument to the event
            $image = $event->getArgument('image');
        } else if ($eventName === 'images.post') {
            // The image is found in the request
            $image = $event->getRequest()->getImage();
        } else {
            // The image is found in the response
            $image = $event->getResponse()->getModel();
        }

        $shouldOptimize = $jpegSizeHintEnabled && !$event->hasArgument('skipOptimization');

        if ($shouldOptimize && $eventName === 'image.loaded') {
            // See if we can hint to imagick that we expect a smaller output
            $minSize = $event->getTransformationManager()->getMinimumImageInputSize($event);

            if ($minSize) {
                $inputSize = $minSize['width'] . 'x' . $minSize['height'];
                $this->imagick->setOption('jpeg:size', $inputSize);
            }
        }

        // Inject the image blob
        $event->getInputLoaderManager()->load($image->getMimeType(), $image->getBlob());

        // If we have specified a size hint, check if we have a different input size
        // than the original and set the ratio as an argument for any other listeners
        if (isset($inputSize)) {
            $newSize = $this->imagick->getImageGeometry();
            $ratio = $image->getWidth() / $newSize['width'];
            $event->setArgument('ratio', $ratio);
            $event->setArgument('transformationIndex', $minSize['index']);
        }
    }