Downloads an image to the local disk

@param string $localname Filename to store image as. Default null.
@param int $width Width of image to download. Default -1.
@param int $height Height of image to download. Default -1.
@return void
480587
public function download( $localname = null, $width = -1, $height = -1 ) {
		global $pgIP;

		if( !$this->get_exists() ) {
			pecho( "Attempted to download a non-existant file.", PECHO_NOTICE );
		}

		$ii = $this->imageinfo( 1, $width, $height );

		if( is_array( $ii ) ) {
			$ii = $ii[0];

			if( $width != -1 ) {
				$url = $ii['thumburl'];
			} else {
				$url = $ii['url'];
			}

			if( is_null( $localname ) ) {
				$localname = $pgIP . 'Images/' . $this->localname;
			}

			Hooks::runHook( 'DownloadImage', array( &$url, &$localname ) );

			pecho( "Downloading {$this->title} to $localname..\n\n", PECHO_NOTICE );

			$this->wiki->get_http()->download( $url, $localname );
		} else {
			pecho( "Error in getting image URL.\n\n" . print_r( $ii ) . "\n\n", PECHO_FATAL );
		}
	}
1203319
static public function create($width, $height) {
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		return new self($image);
	}
29012
private function getThumbnail($fileName = null, $width = null, $height = null, $scale = null)
    {
        $thumb = new Thumbnail($this->config->get('general/thumbnails'));
        $thumb
            ->setFileName($fileName)
            ->setWidth($width)
            ->setHeight($height)
            ->setScale($scale)
        ;

        return $thumb;
    }
119929
public function resizeWindow($width, $height)
    {
        $this->webDriver->manage()->window()->setSize(new WebDriverDimension($width, $height));
    }
1057845
public function resize($width, $height)
    {
        return $this->createCloneWithResource(
            function (InterventionImage $resource) use ($width, $height) {
                return $resource->resize($width, $height);
            }
        );
    }
800986
public function resize($width, $height) {
		$image = imagecreatetruecolor($width, $height);
		imagealphablending($image, false);
		imagesavealpha($image, true);
		imagecopyresampled($image, $this->_image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
		imagedestroy($this->_image);
		$this->_image = $image;
		return $this;
	}
728534
protected function imageThumb($width, $height)
    {
        $width = (int) $width;
        $height = (int) $height;
        if ($width <= 0) {
            throw new BadMethodCallException('Invalid parameter width for command "thumb"');
        }
        if ($height <= 0) {
            throw new BadMethodCallException('Invalid parameter height for command "thumb"');
        }
        $this->image = $this->image->thumbnail(new Box($width, $height));
    }
1259495
private function actionResize($width, $height)
    {
        $image = $this->getPhpThumb();
        $image->resize($width, $height);
    }
246568
public function limitToInnerBox($width, $height, $saveAsNewFile = false)
    {
        if ($this->getWidth() < $width || $this->getHeight() < $height) {
            return $saveAsNewFile ? $this : null;
        }
        return $this->scaleToInnerBox($width, $height, $saveAsNewFile);
    }
1002348
protected function calcImageSize($width, $height)
    {
        $newSize = array(
            'newWidth' => $width,
            'newHeight' => $height
        );

        if ($this->maxWidth > 0) {
            $newSize = $this->calcWidth($width, $height);

            if ($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) {
                $newSize = $this->calcHeight($newSize['newWidth'], $newSize['newHeight']);
            }
        }

        if ($this->maxHeight > 0) {
            $newSize = $this->calcHeight($width, $height);

            if ($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) {
                $newSize = $this->calcWidth($newSize['newWidth'], $newSize['newHeight']);
            }
        }

        $this->newDimensions = $newSize;
    }
507478
public function do_resize($width, $height)
    {
        if (version_compare(PHP_VERSION, '5.5.0') < 0) {
            $image = imagecreatetruecolor($width, $height);
            imagealphablending($image, false);
            imagesavealpha($image, true);

            imagecopyresampled($image, $this->_image, 0, 0, 0, 0, $width, $height, $this->_width, $this->_height);
        } else {
            $image = imagescale($this->_image, $width, $height);
        }

        imagedestroy($this->_image);
        $this->_image = $image;
        $this->_width = imagesx($image);
        $this->_height = imagesy($image);

        return $this;
    }
895159
protected function getImageSize($width, $height)
    {
        $min = min($width, $height);

        // if one value is zero, we have to calculate the right
        // value using the image aspect raion
        if (0 === $min) {

            // if both hight and widh are zero we assume
            // that the image is not resized at all
            if (0 === max($width, $height)) {
                extract($this->getInfo());
            } else {
                $ratio = $this->getInfo('ratio');
            }

            $width  = $width  === 0 ? (int) floor($height * $ratio) : $width;
            $height = $height === 0 ? (int) floor($width  / $ratio) : $height;
        }

        return compact('width', 'height');
    }
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;
	}
1038335
private function actionThumbnail($name, $width, $height)
    {
        $target = $this->getThumbName($name);
        $image = clone $this->getPhpThumb();
        $image->resize($width, $height);
        $image->save($target);
        @chmod($target, 0666);
    }
1237175
public function resize( $width = null, $height = null )
    {
        // Get the source width and height
        $sourceWidth = imagesx( $this->image );
        $sourceHeight = imagesy( $this->image );

        // Check if any of the width and height is null, and set it to the $source size
        // $width = $width ?: $sourceWidth;
        // $height = $height ?: $sourceHeight;
        $sourceAspectRatio = $sourceWidth / $sourceHeight;

        if ( !$width && !$height ) {
            $width = $sourceWidth;
            $height = $sourceHeight;
        }
        else if ( ! $width ) {
            $width = $height * $sourceAspectRatio;
        }
        else {
            $height = $width / $sourceAspectRatio;
        }

        $maxCanvasWidth = $width;
        $maxCanvasHeight = $height;

        $thumbnailAspectRatio = $maxCanvasWidth / $maxCanvasHeight;

        // Create canvas for the new image
        $canvas = $this->createCanvas( $width, $height );

        // Do the resizing of the image
        imagecopyresampled($canvas, $this->image, 0, 0, 0, 0, $width, $height, $sourceWidth, $sourceHeight);

        // Replace the current image
        $this->replace( $canvas );

        // Return this for linking
        return $this;
    }
769740
public function scale($width, $height) {
		$image = new Image();
		$image->create($width, $height, $this->type);

		$result = $image->copyFromWithReSampling($this);

        $this->close();

		$this->image = $image->image;
		$image->setEmptyImage();
		$this->width = $width;
		$this->height = $height;
		return $result;
	}
1305938
public function withDefaultImage(
        $width = null,
        $height = null,
        $options = null)
    {
        $this->withRenamedImage(null, null, $width, $height, $options);

        return $this;
    }