Keep temparary records of file media edit history

@param $media
@param $providerReference
@param $width
@param $height
965051
public function addToEditHistory($media, $providerReference, $width, $height)
    {
        $key = 'media_edit_history_' . $media->getId();
        $history = $this->session->get($key, null);

        if(!$history)
        {
            $history = array();
        }
        else
        {
            $history = unserialize($history);
        }

        $history[] = array(
            'providerReference' => $providerReference,
            'width' => $width,
            'height' => $height
        );

        $this->session->set($key, serialize( $history ));
    }
1095239
protected function doUpdateVideos(Reference $model, $data) {
		// remove all relationships before
		VideoQuery::create()->filterByReference($model)->delete();

		// add them
		$errors = [];
		foreach ($data as $entry) {
			if (!isset($entry['id'])) {
				$errors[] = 'Missing id for Video';
			} else {
				$related = VideoQuery::create()->findOneById($entry['id']);
				$model->addVideo($related);
			}
		}

		if (count($errors) > 0) {
			throw new ErrorsException($errors);
		}
	}
981987
public function resize($width, $height, $filename = null)
    {
        $this->resize[] = array('width'=>$width, 'height'=>$height,  'filename'=>$filename);

        return $this;
    }
418902
protected function saveRelatedAttached($parent, $items) {
        foreach ($items as $row) :
            $CONTENT_PATH = $this->_uploadFile($row['content_path']);
            if ($CONTENT_PATH) :
                $PATHINFO = pathinfo($CONTENT_PATH);
                $row['content_title'] = (trim($row['content_title']) == '') ? Inflector::humanize($PATHINFO['filename']) : trim($row['content_title']);
                $row['parent'] = $parent;
                $row['content_type'] = 'attached';
                $row['content_status'] = 'inherited';
                $row['content_path'] = $CONTENT_PATH;
                $row['menu_order'] = $this->getNextMenuOrder($parent, 'attached');
                $this->_createNewContent($row);
            endif;
        endforeach;
    }
1006752
public function edit($resolution, $width, $height)
    {
        $this->resolution = $resolution;
        $this->width = $width;
        $this->height = $height;
        $this->getLogger()->info('Editing resolution ID ' . $this->resolutionId);
        $response = $this->doPut('/resolution/' . $this->resolutionId, $this->toArray());
        $this->getLogger()->debug('Passing the response to Hydrate');
        return $this->hydrate($response);
    }
92513
public function removeUrlForViewReference(ViewReference $viewReference)
    {
        $id = $viewReference->getId();
        if ($url = $this->repository->findValueForId('url', $id)) {
            $this->manager->removeUrl($url, $this->repository->findValueForId('locale', $id));
        }
    }
632038
public function save(MediaProviderInterface $mediaProvider, $andFlush = true)
    {
        $context = $mediaProvider->getMedia()->getContext();
        $provider = $this->providerService->getProviderManager($context);

        if (null !== $mediaProvider->getMedia()->getFile()) {
            $this->uploadProcess($provider, $mediaProvider);
        }

        $this->persistProcess($provider, $mediaProvider, $andFlush);
    }
1205144
protected function createTransparentImage($width, $height)
    {
        $image = @imagecreatetruecolor($width, $height);
        if (!$image) {
            throw new \Exception('Missing libgd support');
        }
        imagealphablending($image, false);
        $transparency = $this->transparentColor($image);
        imagefill($image, 0, 0, $transparency);
        imagecolordeallocate($image, $transparency);
        imagesavealpha($image, true);
        return $image;
    }
1225447
public function saveReference(ViewReference $viewReference, $parentId = null, $parentLocale = null)
    {
        // Transform the viewReference in array
        $arrayTransformer = $this->transformer->getViewReferenceTransformer(
            $viewReference->getViewNamespace(), 'array'
        );
        $referenceArray = $arrayTransformer->reverseTransform($viewReference);
        // Remove old url if exist
        $this->removeUrlForViewReference($viewReference);
        // Update/create the viewReference
        $this->manager->update($referenceArray['id'], $referenceArray);
        // Build the url for reference
        $this->manager->buildUrl($viewReference->getId());
        // Set parent if exist
        if ($parentId && $parentLocale === $viewReference->getLocale()) {
            $this->manager->addChild($parentId, $referenceArray['id']);
        }

        return $referenceArray['id'];
    }
1057845
public function resize($width, $height)
    {
        return $this->createCloneWithResource(
            function (InterventionImage $resource) use ($width, $height) {
                return $resource->resize($width, $height);
            }
        );
    }
449110
public function setViewportSize($width, $height)
    {
        $this->viewportWidth  = (int) $width;
        $this->viewportHeight = (int) $height;

        return $this;
    }
602815
public function windowSize($width,$height)
    {
        $this->windowWidth  = $width;
        $this->windowHeight = $height;
        return $this;
    }
582012
protected function store( $source, $destination, $width, $height, $crop ) {
		if ( file_exists( $destination ) ) {
			return $destination;
		}

		$editor = wp_get_image_editor( $source );

		if ( is_wp_error( $editor ) ) {
			return '';
		}

		$editor->resize( $width, $height, $crop );
		$editor->save( $destination );

		return $destination;
	}
774376
public function updateViewReference(ViewReferenceEvent $event)
    {
        $view = $event->getView();
        if ($viewReference = $this->viewReferenceBuilder->buildViewReference($view, $this->em)) {
            $this->viewReferenceManager->saveReference($viewReference);
        }
    }
1035304
final protected function _createTrueColor($width,$height){
	    // Format
	    $width=(int)$width;
	    $height=(int)$height;
		// Create image
		$resource=imagecreatetruecolor($width,$height);
		if(!$resource){
			throw new Exception("Failed to create new image");
		}
		// Set alpha channel
		imagealphablending($resource,false);
		$color=imagecolorallocatealpha($resource,0,0,0,127);
		imagecolortransparent($resource,$color);
		imagesavealpha($resource,true);
		return $resource;
	}
1089505
private function keepTransparancy($width, $height, $im)
		# Author:     Jarrod Oberto
		# Date:       08-04-11
		# Purpose:    Keep transparency for png and gif image
		# Param in:
		# Param out:  n/a
		# Reference:
		# Notes:
		#
	{
		// *** If PNG, perform some transparency retention actions (gif untested)
		if (in_array($this->fileExtension, $this->transparentArray) && $this->keepTransparency)
		{
			imagealphablending($im, false);
			imagesavealpha($im, true);
			$transparent = imagecolorallocatealpha($im, 255, 255, 255, 127);
			imagefilledrectangle($im, 0, 0, $width, $height, $transparent);
		}
		else
		{
			$color = imagecolorallocate($im, $this->fillColorArray['r'], $this->fillColorArray['g'], $this->fillColorArray['b']);
			imagefilledrectangle($im, 0, 0, $width, $height, $color);
		}
	}
139151
protected function setDataToMedia(Media $media, $data, $user)
    {
        foreach ($data as $attribute => $value) {
            if ($value ||
                ('tags' === $attribute && null !== $value) ||
                ('size' === $attribute && null !== $value) ||
                ('description' === $attribute && null !== $value) ||
                ('copyright' === $attribute && null !== $value) ||
                ('credits' === $attribute && null !== $value) ||
                ('categories' === $attribute && null !== $value) ||
                ('focusPointX' === $attribute && null !== $value) ||
                ('focusPointY' === $attribute && null !== $value)
            ) {
                switch ($attribute) {
                    case 'size':
                        $media->setSize($value);
                        break;
                    case 'title':
                        $media->setTitle($value);
                        break;
                    case 'description':
                        $media->setDescription($value);
                        break;
                    case 'copyright':
                        $media->setCopyright($value);
                        break;
                    case 'credits':
                        $media->setCredits($value);
                        break;
                    case 'version':
                        $media->setVersion($value);
                        break;
                    case 'name':
                        $media->setName($value);
                        break;
                    case 'url':
                        $media->setUrl($value);
                        break;
                    case 'formats':
                        $media->setFormats($value);
                        break;
                    case 'storageOptions':
                        $media->setStorageOptions($value);
                        break;
                    case 'publishLanguages':
                        $media->setPublishLanguages($value);
                        break;
                    case 'contentLanguages':
                        $media->setContentLanguages($value);
                        break;
                    case 'tags':
                        $media->removeTags();
                        if (count($value)) {
                            foreach ($value as $tag) {
                                $tagEntity = $this->tagManager->findOrCreateByName($tag, $user->getId());
                                $media->addTag($tagEntity);
                            }
                        }
                        break;
                    case 'properties':
                        $media->setProperties($value);
                        break;
                    case 'changed':
                        $media->setChanged($value);
                        break;
                    case 'created':
                        break;
                    case 'changer':
                        if ($value instanceof UserInterface) {
                            $media->setChanger($value);
                        }
                        break;
                    case 'creator':
                        if ($value instanceof UserInterface) {
                            $media->setCreator($value);
                        }
                        break;
                    case 'mimeType':
                        $media->setMimeType($value);
                        break;
                    case 'collection':
                        $collectionEntity = $this->getCollectionById($value);
                        $media->setCollection($collectionEntity); // set parent
                        break;
                    case 'type':
                        if (isset($value['id'])) {
                            $type = $this->typeManager->get($value['id']);
                            $media->setType($type);
                        }
                        break;
                    case 'categories':
                        $categoryIds = $value;
                        $media->removeCategories();

                        if (is_array($categoryIds) && !empty($categoryIds)) {
                            /** @var CategoryRepositoryInterface $repository */
                            $categories = $this->categoryRepository->findCategoriesByIds($categoryIds);

                            foreach ($categories as $category) {
                                $media->addCategory($category);
                            }
                        }
                        break;
                    case 'targetGroups':
                        $targetGroupIds = $value;
                        $media->removeTargetGroups();

                        if (is_array($targetGroupIds) && !empty($targetGroupIds)) {
                            $targetGroups = $this->targetGroupRepository->findByIds($targetGroupIds);

                            foreach ($targetGroups as $targetGroup) {
                                $media->addTargetGroup($targetGroup);
                            }
                        }
                        break;
                    case 'focusPointX':
                        $media->setFocusPointX($value);
                        break;
                    case 'focusPointY':
                        $media->setFocusPointY($value);
                        break;
                }
            }
        }

        return $media;
    }