Resizes an image to the specified height, changing width in the same proportion
@param originalImage Image in memory
@param heightOut The height to resize
@return New Image in memory
350712
public static BufferedImage resizeToHeight(BufferedImage originalImage, int heightOut) {

    int width = originalImage.getWidth();

    int height = originalImage.getHeight();

    int heightPercent = (heightOut * 100) / height;

    int newWidth = (width * heightPercent) / 100;

    BufferedImage resizedImage =
        new BufferedImage(newWidth, heightOut, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = resizedImage.createGraphics();
    g.drawImage(originalImage, 0, 0, newWidth, heightOut, null);
    g.dispose();

    return resizedImage;
  }
1250534
public static BufferedImage resize(BufferedImage image, int width, int height)
    {
        final int transparency = image.getColorModel().getTransparency();
        final BufferedImage resized = createImage(width, height, transparency);
        final Graphics2D g = resized.createGraphics();

        optimizeGraphicsSpeed(g);
        g.drawImage(image, 0, 0, width, height, 0, 0, image.getWidth(), image.getHeight(), null);
        g.dispose();

        return resized;
    }
1009546
public static BufferedImage randomBufferedImage(final int width, final int height,
		final int imageType)
	{
		final BufferedImage img = new BufferedImage(width, height, imageType);
		for (int y = 0; y < height; y++)
		{
			for (int x = 0; x < width; x++)
			{
				img.setRGB(x, y, RandomExtensions.newRandomPixel());
			}
		}
		return img;
	}
59352
public static function resize($in_file, $out_file, $new_width, $new_height = false)
    {
        $image     = null;
        $extension = strtolower(preg_replace('/^.*\./', '', $in_file));
        switch ($extension) {
            case 'jpg':
            case 'jpeg':
                $image = imagecreatefromjpeg($in_file);
                break;
            case 'png':
                $image = imagecreatefrompng($in_file);
                break;
            case 'gif':
                $image = imagecreatefromgif($in_file);
                break;
        }
        if (!$image || !is_resource($image)) return false;


        $width  = imagesx($image);
        $height = imagesy($image);
        if ($new_height === false) {
            $new_height = (int)(($height * $new_width) / $width);
        }


        $new_image = imagecreatetruecolor($new_width, $new_height);
        imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

        $ret = imagejpeg($new_image, $out_file, 80);

        imagedestroy($new_image);
        imagedestroy($image);

        return $ret;
    }
438695
@Override
    public void resize(final int width, final int height) {
        if (currentView != null) {
            currentView.resize(width, height, isCenteringCameraOnResize());
        }
    }
1305938
public function withDefaultImage(
        $width = null,
        $height = null,
        $options = null)
    {
        $this->withRenamedImage(null, null, $width, $height, $options);

        return $this;
    }
1088298
def create(self, original, size, crop, options=None):
        
        if options is None:
            options = self.evaluate_options()
        image = self.engine_load_image(original)
        image = self.scale(image, size, crop, options)
        crop = self.parse_crop(crop, self.get_image_size(image), size)
        image = self.crop(image, size, crop, options)
        image = self.colormode(image, options)
        return image
487471
public function resizeImage($savePath, $image, $newImageName, $width, $height)
    {
        
        $fileImage = $image;
        $outputImg = null;
        $ext = pathinfo($newImageName, PATHINFO_EXTENSION);

        $thumb = imagecreatetruecolor($width, $height);
        list($w, $h) = getimagesize($fileImage);

        switch(exif_imagetype($fileImage)) {
            case IMAGETYPE_GIF:
                $image = imagecreatefromgif($fileImage);
            break;
            case IMAGETYPE_JPEG:
                $image = imagecreatefromjpeg($fileImage);
            break;
            case IMAGETYPE_PNG:
                $image = imagecreatefrompng($fileImage);
            break;
        }
        
        imagecopyresampled($thumb, $image, 0, 0, 0, 0, $width, $height, $w, $h);

        switch ($ext) {
            case self::EXT_PNG:
                $outputImg = imagepng($thumb, $savePath.'/'.$newImageName, 9);
                break;
            case self::EXT_GIF:
                $outputImg = imagegif($thumb, $savePath.'/'.$newImageName);
                break;
            case self::EXT_JPG:
                $outputImg = imagejpeg($thumb, $savePath.'/'.$newImageName, 100);
                break;
        }

        imagedestroy($thumb);
    
    }
294888
protected BufferedImage create_FRAME_Image(final int WIDTH, final int HEIGHT) {
        return FRAME_FACTORY.createLinearFrame(WIDTH, HEIGHT, getFrameDesign(), getCustomFrameDesign(), getFrameEffect());
    }
777207
private ImageProcessor resize(ImageProcessor ip, String newWidth) {
        if (newWidth != null) {
            try {
                int width = Integer.parseInt(newWidth);

                if (width < 0) {
                    return ip;
                }

                int imgWidth = ip.getWidth();
                int imgHeight = ip.getHeight();

                ip = ip.resize(width, width * imgHeight / imgWidth);
            }
            // no need to do anything with number format exception since the servlet
            // returns only images; just return the original image
            catch (NumberFormatException e) {
            }
        }

        return ip;
    }
560132
public function resizeImage($original, $path, $width, $height)
    {
        $original = $this->getFullPath($original);

        // Create folder if it dosn't exist
        $pathArray = explode('/', $path);
        array_pop($pathArray);
        $folder = implode('/', $pathArray);
        if (! file_exists($folder)) {
            mkdir($folder, 0777, true);
        }

        $file = \File::get($original);

        $img = \Image::make($file)->resize($width, $height, function ($constraint) {
            $constraint->aspectRatio();
            $constraint->upsize();
        });

        $img->save($path);

        return $this->showFile($path);
    }
793804
function resizeImage(img, max_width, max_height) {
    var sizes = this.getImageNewAspectSizes(img, max_width, max_height);
    var width = sizes.width;
    var height = sizes.height;
    var canvas = this.imageToCanvas(img, width, height);
    return canvas;
    //return this.getImageByCanvas(canvas);
  }
87183
def resize(image, width=None, height=None, crop=False, namespace="resized"):
    
    return resize_lazy(image=image, width=width, height=height, crop=crop,
                       namespace=namespace, as_url=True)
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;
    }
941821
public function resize($width, $height, $x = 0, $y = 0)
    {
        if ( !$this->newImage )
        {
            $this->create($width, $height);
        }

        if ( !is_numeric($width) ) {
            throw new \InvalidArgumentException('$width must be numeric');
        }

        if ( !is_numeric($height) ) {
            throw new \InvalidArgumentException('$height must be numeric');
        }

        $type = $this->source['type'];

        imagecopyresampled(
            $this->newImage,
            $this->sourceImage,
            0, 0,
            $x, $y,
            $width, $height,
            $this->source['width'], $this->source['height']);

        return $this;
    }
1294263
public function changeDimensions($sourceImage, $desiredWidth, $desiredHeight)
    {
        $temp = '';
        // find the height and width of the image
        if (imagesx($sourceImage) >= imagesy($sourceImage)
            && imagesx($sourceImage) >= $this->fixedWidth
        ) {
            $temp = imagesx($sourceImage) / $this->fixedWidth;
            $desiredWidth = imagesx($sourceImage) / $temp;
            $desiredHeight = imagesy($sourceImage) / $temp;
        } elseif (imagesx($sourceImage) <= imagesy($sourceImage)
            && imagesy($sourceImage) >= $this->fixedHeight
        ) {
            $temp = imagesy($sourceImage) / $this->fixedHeight;
            $desiredWidth = imagesx($sourceImage) / $temp;
            $desiredHeight = imagesy($sourceImage) / $temp;
        } else {
            $desiredWidth = imagesx($sourceImage);
            $desiredHeight = imagesy($sourceImage);
        }

        // create a new image
        $thumbImg = imagecreatetruecolor($desiredWidth, $desiredHeight);
        $imgAllocate = imagecolorallocate($thumbImg, 255, 255, 255);
        imagefill($thumbImg, 0, 0, $imgAllocate);

        //copy source image to resize
        imagecopyresampled(
            $thumbImg,
            $sourceImage,
            0,
            0,
            0,
            0,
            $desiredWidth,
            $desiredHeight,
            imagesx($sourceImage),
            imagesy($sourceImage)
        );

        return $thumbImg;
    }
330882
public void setImage(BufferedImage img) {
        this.img = img;
        Dimension dim;
        if (img != null) {
            dim = new Dimension(img.getWidth(), img.getHeight());
        } else {
            dim = new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT);
        }

        setSize(dim);
        setPreferredSize(dim);
        repaint();
    }