Re-calculate image dimensions when original image dimension has changed.

@return $this
506303
public function reCalculateDimensions()
    {
        $this->log("Re-calculate image dimensions, newWidth x newHeigh was: " . $this->newWidth . " x " . $this->newHeight);

        $this->newWidth  = $this->newWidthOrig;
        $this->newHeight = $this->newHeightOrig;
        $this->crop      = $this->cropOrig;

        $this->initDimensions()
             ->calculateNewWidthAndHeight();

        return $this;
    }
669101
public function manipulate(AbstractImage $image, $width, $height)
    {
        $box = $this->calculateResize($image, $width, $height);

        return $image->resize($box);
    }
259117
public function resizeCrop()
    {
        $sourceDimension = $this->sourceImageFile->getDimension();
        $resampleDimension = $this->resampleImageFile->getDimension();

        //try max width first...
        $resizeRatio = $resampleDimension->getWidth() / $sourceDimension->getWidth();
        $resizeWidth = $resampleDimension->getWidth();
        $resizeHeight = $sourceDimension->getHeight() * $resizeRatio;

        //if that didn't work
        if ($resizeHeight > $resampleDimension->getHeight()) {
            $resizeRatio = $resampleDimension->getHeight() / $sourceDimension->getHeight();
            $resizeHeight = $resampleDimension->getHeight();
            $resizeWidth = $sourceDimension->getWidth() * $resizeRatio;
        }

        $resampleImageResource =& $this->getResampleImageResource();

        if ($resampleDimension->getOrientation() === 'SQUARE') {
            if ($resampleImageResource->resizeImage($resizeWidth, $resizeHeight, \Imagick::FILTER_LANCZOS, 0.9,
                true)
            ) {
                $resampleAxis = new Dimension\Axis(
                    ($resizeWidth - $resampleDimension->getWidth()) / 2,
                    ($resizeHeight - $resampleDimension->getWidth()) / 2
                );
            }
        } else {
            switch ($resampleDimension->getFocus()) {
                default:
                case 'CENTER':
                    $resampleAxis = new Dimension\Axis(
                        ($sourceDimension->getWidth() / 2) - ($resizeWidth / 2),
                        ($sourceDimension->getHeight() / 2) - ($resizeHeight / 2)
                    );
                    break;
                case 'NORTH':
                    $resampleAxis = new Dimension\Axis(
                        ($sourceDimension->getWidth() - $resizeWidth) / 2,
                        0
                    );
                    break;
                case 'NORTHWEST':
                    $resampleAxis = new Dimension\Axis(
                        0,
                        0
                    );
                    break;
                case 'NORTHEAST':
                    $resampleAxis = new Dimension\Axis(
                        $sourceDimension->getWidth() - $resizeWidth,
                        0
                    );
                    break;
                case 'SOUTH':
                    $resampleAxis = new Dimension\Axis(
                        ($sourceDimension->getWidth() - $resizeWidth) / 2,
                        $sourceDimension->getHeight() - $resizeHeight
                    );
                    break;
                case 'SOUTHWEST':
                    $resampleAxis = new Dimension\Axis(
                        0,
                        $sourceDimension->getHeight() - $resizeHeight
                    );
                    break;
                case 'SOUTHEAST':
                    $resampleAxis = new Dimension\Axis(
                        $sourceDimension->getWidth() - $resizeWidth,
                        $sourceDimension->getHeight() - $resizeHeight
                    );
                    break;
                case 'WEST':
                    $resampleAxis = new Dimension\Axis(
                        0,
                        ($sourceDimension->getHeight() - $resizeHeight) / 2
                    );
                    break;
                case 'EAST':
                    $resampleAxis = new Dimension\Axis(
                        $sourceDimension->getWidth() - $resizeWidth,
                        ($sourceDimension->getHeight() - $resizeHeight) / 2
                    );
                    break;
            }

            if ( ! $resampleImageResource->resizeImage(
                $sourceDimension->getWidth(),
                $sourceDimension->getHeight(),
                \Imagick::FILTER_CATROM, 0.9, true)
            ) {
                return false;
            }
        }

        if (isset($resampleAxis)) {
            return $this->crop($resampleDimension->withAxis($resampleAxis));
        }

        return false;
    }
228622
public final function rotateSquare() : Size
   {

      $this->triggerFixedErrorByNeed( 'rotateSquare' );

      $tmp          = $this->_width;
      $this->_width  = $this->_height;
      $this->_height = $tmp;

      return $this;

   }
498464
public function setImageMaxWidth($v)
    {
        if ($v !== null) {
            $v = (double) $v;
        }

        if ($this->image_max_width !== $v) {
            $this->image_max_width = $v;
            $this->modifiedColumns[AttributeTypeTableMap::IMAGE_MAX_WIDTH] = true;
        }


        return $this;
    }
821321
protected function initDestImageResource() 
    {
    	// gif does not supports truecolor for resize
    	if (function_exists("ImageCreateTrueColor") && $this->getExtension() != 'gif') {
    		$this->destImageResource = ImageCreateTrueColor($this->destImageWidth, $this->destImageHeight);
    	} else {
    		$this->destImageResource = ImageCreate($this->destImageWidth, $this->destImageHeight);
    	}
    	
    	return $this;
    }
1152433
public function fit($width, $height)
    {
        $this->toggleModified();

        $this->getInterventionImage()->fit($width, $height);

        return $this;
    }
764817
public function images()
    {
        foreach($this->data as $post)
        {
            $post->images = Post::images($post->ID);
        }

        return $this;
    }
411793
function(){
    this.width = this.container.width();
    this.height = this.container.height();
    this.resize();
    this.canvas.setSize(this.width, this.height);
    this.applyTransform();
  }
41113
private function altImagesToUnique()
    {
        if ($this->alternateImageUrls->count() === 0) {
            return;
        }
        $images = $this->getAlternateImageUrls();
        $resetImages = false;
        $duplicates = array_count_values($images);
        foreach ($duplicates as $val => $count) {
            if ($count > 1) {
                $resetImages = true;
                $images = array_unique($images);
                break;
            }
        }
        $key = array_search($this->getImageUrl(), $images, true);
        if ($key !== false) {
            $resetImages = true;
            unset($images[$key]);
        }
        if ($resetImages) {
            $this->setAlternateImageUrls(array_values($images));
        }
    }
62399
public function getResize()
    {
        $ratio = 1.0;
        $image = request('img');

        $original_image = Image::make($this->lfm->setName($image)->path('absolute'));
        $original_width = $original_image->width();
        $original_height = $original_image->height();

        $scaled = false;

        // FIXME size should be configurable
        if ($original_width > 600) {
            $ratio = 600 / $original_width;
            $width = $original_width * $ratio;
            $height = $original_height * $ratio;
            $scaled = true;
        } else {
            $width = $original_width;
            $height = $original_height;
        }

        if ($height > 400) {
            $ratio = 400 / $original_height;
            $width = $original_width * $ratio;
            $height = $original_height * $ratio;
            $scaled = true;
        }

        return view('laravel-filemanager::resize')
            ->with('img', $this->lfm->pretty($image))
            ->with('height', number_format($height, 0))
            ->with('width', $width)
            ->with('original_height', $original_height)
            ->with('original_width', $original_width)
            ->with('scaled', $scaled)
            ->with('ratio', $ratio);
    }
906876
final public function resizeImage($width = null, $height = null)
	{
		if (is_int($width) and is_int($height)) {
			$new_image = imagecreatetruecolor($width, $height);
			imagecopyresampled(
				$new_image,
				$this->_image_handle,
				0,
				0,
				0,
				0,
				$width,
				$height,
				$this->imageWidth(),
				$this->imageHeight()
			);
			if (is_resource($new_image)) {
				$this->_image_handle = $new_image;
			}
		}
		return $this;
	}
810439
protected function getDimensions()
    {
        // Default result
        $result = [0, 0];

        // If we have a resource already loaded, this means we have modified the resource since the
        // original image was loaded. This means the "Variant" tuple key is out of date, and we don't
        // have a reliable cache key to load from, or save to. If we use the original tuple as a key,
        // we would run the risk of overwriting the original dimensions in the cache, with the values
        // of the resized instead.
        // Instead, we use the immediately available dimensions attached to this resource, and we will
        // rely on cache warming in writeToStore to save these values, where the "Variant" becomes available,
        // before the next time this variant is loaded into memory.
        $resource = $this->image;
        if ($resource) {
            return $this->getResourceDimensions($resource);
        }

        // Check if we have a container
        $container = $this->getAssetContainer();
        if (!$container) {
            return $result;
        }

        // Check cache for unloaded image
        $cache = $this->getCache();
        $key = $this->getDimensionCacheKey($container->getHash(), $container->getVariant());
        if ($cache->has($key)) {
            return $cache->get($key);
        }

        // Cache-miss
        $resource = $this->getImageResource();
        if ($resource) {
            $result = $this->getResourceDimensions($resource);
            $cache->set($key, $result);
        }
        return $result;
    }
1252978
public function setImageWidth( $width )
    {
        $this->imageWidth = empty( $width ) ? null : (int) $width;
        return $this;
    }
47850
public function actionResize()
    {
        $models = Mediafile::findByTypes(Mediafile::$imageFileTypes);
        $routes = $this->module->routes;

        foreach ($models as $model) {
            if ($model->isImage()) {
                $model->deleteThumbs($routes);
                $model->createThumbs($routes, $this->module->thumbs);
            }
        }

        Yii::$app->session->setFlash('successResize');
        $this->redirect(Url::to(['default/settings']));
    }
1132908
public function reset() {
        if ($this->transformations) {
            // Remove image transformations
            $this->transformations = array();
            $this->query->remove('t');
        }

        if ($this->extension) {
            // Remove the extension
            $this->path = str_replace('.' . $this->extension, '', $this->path);
            $this->extension = null;
        }

        return $this;
    }
199597
public function swapChangedAttributes()
    {
        if (false === $this->originalAttributesLoaded) {

            $this->swappedAttributes = $this->getAttributes();
            $this->fill($this->getOriginal());

            $this->originalAttributesLoaded = true;

            return $this;
        }

        if  ( ! count($this->swappedAttributes)) {
            $this->swappedAttributes = $this->getAttributes();
        }

        $this->fill($this->swappedAttributes);

        $this->originalAttributesLoaded = false;

        return $this;
    }