Resizes a bitmap to a height of 89 pixels (the
  size of the top panel), while keeping aspect ratio
  in tact
191241
def resize_bitmap(parent, _bitmap, target_height):
  '''
  
  '''
  image = wx.ImageFromBitmap(_bitmap)
  _width, _height = image.GetSize()
  if _height < target_height:
    return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
  ratio = float(_width) / _height
  image = image.Scale(target_height * ratio, target_height, wx.IMAGE_QUALITY_HIGH)
  return wx.StaticBitmap(parent, -1, wx.BitmapFromImage(image))
1019844
public static BufferedImage resizeToWidth(BufferedImage originalImage, int widthOut) {
    
    int width = originalImage.getWidth();
    
    int height = originalImage.getHeight();
    
    int widthPercent = (widthOut * 100) / width;
    
    int newHeight = (height * widthPercent) / 100;
    
    BufferedImage resizedImage =
        new BufferedImage(widthOut, newHeight, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = resizedImage.createGraphics();
    g.drawImage(originalImage, 0, 0, widthOut, newHeight, null);
    g.dispose();
    
    return resizedImage;
  }
1182945
function resize(img, width=0, height=0, type='png', quality=0.75) {
    let mime
    switch(type.toLowerCase()) {
    case 'jpg':
    case 'jpeg':
    case 'image/jpeg':
        mime = 'image/jpeg'
        break
    case 'png':
    case 'image/png':
    default:
        mime = 'image/png'
    }
    return resizePromise(img, width, height).then(
        canvas => canvas2Blob(canvas, { type: mime, quality })
        //canvas => canvas2DataUrl(canvas, { type: mime, quality })
    )
}
1353758
function(map) {
        /**
         * If nothing to do with resolutions has been set, assume a single
         * resolution determined by ratio*extent/size - if an image has a
         * pixel aspect ratio different than one (as calculated above), the
         * image will be stretched in one dimension only.
         */
        if( this.options.maxResolution == null ) {
            this.options.maxResolution = this.aspectRatio *
                                         this.extent.getWidth() /
                                         this.size.w;
        }
        OpenLayers.Layer.prototype.setMap.apply(this, arguments);
    }
1371089
@Override protected void resize() {
        width  = gauge.getWidth() - gauge.getInsets().getLeft() - gauge.getInsets().getRight();
        height = gauge.getHeight() - gauge.getInsets().getTop() - gauge.getInsets().getBottom();

        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        if (width > 0 && height > 0) {
            pane.setMaxSize(width, height);
            pane.setPrefSize(width, height);
            pane.relocate((gauge.getWidth() - width) * 0.5, (gauge.getHeight() - height) * 0.5);
            pane.setSpacing(width * 0.01960784);

            double barWidth = 0;
            for (int i = 0 ; i < 12 ; i++) {
                bars[i].setPrefSize(0.3030303 * height, (0.3030303 * height + i * 0.06060606 * height));
                Bounds bounds = bars[i].getLayoutBounds();
                barWidth      = bounds.getWidth();
                if (barWidth == 0) return;

                BarColor barColor;
                if (i < 2) {
                    barColor = BarColor.RED;
                } else if (i < 9) {
                    barColor = BarColor.ORANGE;
                } else {
                    barColor = BarColor.GREEN;
                }
                barBackgrounds[i] = new Background(new BackgroundFill[] {
                    new BackgroundFill(Color.WHITE, new CornerRadii(1024), Insets.EMPTY),
                    new BackgroundFill(new LinearGradient(0, bounds.getMinY(), 0, bounds.getMaxY(), false, CycleMethod.NO_CYCLE, new Stop(0.0, barColor.COLOR_FROM), new Stop(1.0, barColor.COLOR_TO)), new CornerRadii(1024), new Insets(0.15 * barWidth))
                });
                barBackgrounds[i + 12] = new Background(new BackgroundFill[] {
                    new BackgroundFill(Color.WHITE, new CornerRadii(1024), Insets.EMPTY),
                    new BackgroundFill(new LinearGradient(0, bounds.getMinY(), 0, bounds.getMaxY(), false, CycleMethod.NO_CYCLE, new Stop(0.0, BarColor.GRAY.COLOR_FROM), new Stop(1.0, BarColor.GRAY.COLOR_TO)), new CornerRadii(1024), new Insets(0.15 * barWidth))
                });
            }
            barBorder = new Border(new BorderStroke(Color.rgb(102, 102, 102), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(0.05 * barWidth)));
        }
        redraw();
    }
948964
public static void scaleImageUp(GrayU8 input , GrayU8 output , int scale ,
									InterpolatePixelS<GrayU8> interp ) {
		output.reshape(input.width*scale,input.height*scale);

		float fdiv = 1/(float)scale;
		interp.setImage(input);

		for (int y = 0; y < output.height; y++) {
			float inputY = y*fdiv;
			int indexOutput = output.getIndex(0,y);

			for (int x = 0; x < output.width; x++) {
				float inputX = x*fdiv;

				output.data[indexOutput++] = (byte)interp.get(inputX,inputY);
			}
		}
	}
306061
def resizeEvent(self, event):
        
        super(XImageSlider, self).resizeEvent(event)
        
        self.recalculate()
346327
public static Bitmap scaleFill(Bitmap src, int w, int h) {
        Bitmap res = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
        scaleFill(src, res);
        return res;
    }
538236
def resizeEvent(self, event):
        """"""
        vp = self.viewport()
        rect = vp.geometry()
        x1, y1, x2, y2 = rect.getCoords()
        width = x2 - x1 + 1
        height = y2 - y1 + 1

        self.v_w.resize(width, height)
923811
public static Bitmap drawViewToBitmap(Bitmap dest, View view, int downSampling, Bitmap.Config bitmapConfig) {
        float scale = 1f / downSampling;
        int viewWidth = view.getWidth();
        int viewHeight = view.getHeight();
        int bmpWidth = Math.round(viewWidth * scale);
        int bmpHeight = Math.round(viewHeight * scale);

        if (dest == null || dest.getWidth() != bmpWidth || dest.getHeight() != bmpHeight) {
            dest = Bitmap.createBitmap(bmpWidth, bmpHeight, bitmapConfig);
        }

        Canvas c = new Canvas(dest);
        if (downSampling > 1) {
            c.scale(scale, scale);
        }

        view.draw(c);
        return dest;
    }
283263
private static Bitmap loadBitmapOptimized(ImageSource source, int w, int h) throws ImageLoadException {
        int scale = getScaleFactor(source.getImageMetadata(), w, h);
        return loadBitmap(source, scale);
    }
800486
def crop_or_pad_to(height, width):
    
    def inner(t_image):
        return tf.image.resize_image_with_crop_or_pad(t_image, height, width)
    return inner
737471
@NonNull
    public Bitmap toBitmap() {
        if (mSizeX == -1 || mSizeY == -1) {
            actionBar();
        }

        Bitmap bitmap = Bitmap.createBitmap(
                getIntrinsicWidth(),
                getIntrinsicHeight(),
                Bitmap.Config.ARGB_8888);

        style(Paint.Style.FILL);

        Canvas canvas = new Canvas(bitmap);
        setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
        draw(canvas);

        return bitmap;
    }
642454
function (width, height, canvas) {
            // XXX This should probably be a configurable option
            var match;
            match = this._pxregex.exec(height);
            if (match) {
                this.pixelHeight = match[1];
            } else {
                this.pixelHeight = $(canvas).height();
            }
            match = this._pxregex.exec(width);
            if (match) {
                this.pixelWidth = match[1];
            } else {
                this.pixelWidth = $(canvas).width();
            }
        }
925684
def SetSize(self, rect):
        

        grid = self.main_window.grid
        key = grid.actions.cursor

        drawn_rect = grid.grid_renderer._get_drawn_rect(grid, key, rect)

        self._tc.SetDimensions(drawn_rect.x, drawn_rect.y,
                               drawn_rect.width+2, drawn_rect.height+2,
                               wx.SIZE_ALLOW_MINUS_ONE)
        self._tc.Layout()
846967
@Override protected void resize() {
        width  = clock.getWidth() - clock.getInsets().getLeft() - clock.getInsets().getRight();
        height = clock.getHeight() - clock.getInsets().getTop() - clock.getInsets().getBottom();

        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        centerX = width * 0.5;
        centerY = height * 0.5;

        if (width > 0 && height > 0) {
            pane.setMaxSize(width, height);
            pane.relocate((clock.getWidth() - height) * 0.5, (clock.getHeight() - height) * 0.5);

            canvas.setWidth(width);
            canvas.setHeight(height);
        }
    }
428385
private void adjustToCurrentFormat() {

        // in case of a locked or fixed image ratio height and width need to be reset
        int height = m_croppingParam.getOrgHeight();
        int width = m_croppingParam.getOrgWidth();
        if (m_croppingParam.isScaled()) {
            if (m_croppingParam.getTargetHeight() == -1) {
                height = (int)Math.floor(
                    ((1.00 * m_croppingParam.getOrgHeight()) / m_croppingParam.getOrgWidth())
                        * m_croppingParam.getTargetWidth());
            } else {
                height = m_croppingParam.getTargetHeight();
            }
            if (m_croppingParam.getTargetWidth() == -1) {
                width = (int)Math.floor(
                    ((1.00 * m_croppingParam.getOrgWidth()) / m_croppingParam.getOrgHeight())
                        * m_croppingParam.getTargetHeight());
            } else {
                width = m_croppingParam.getTargetWidth();
            }

        } else {
            m_croppingParam.setTargetHeight(height);
            m_croppingParam.setTargetWidth(width);
        }
        m_formatForm.setHeightInput(height);
        m_formatForm.setWidthInput(width);
        // enabling/disabling ratio lock button
        if (m_currentFormat.isFixedRatio()) {
            m_formatForm.setRatioButton(false, false, Messages.get().key(Messages.GUI_PRIVIEW_BUTTON_RATIO_FIXED_0));
            m_ratioLocked = true;
        } else {
            if (!m_currentFormat.isHeightEditable() && !m_currentFormat.isWidthEditable()) {
                // neither height nor width are editable, disable ratio lock button
                m_formatForm.setRatioButton(
                    false,
                    false,
                    Messages.get().key(Messages.GUI_PRIVIEW_BUTTON_NOT_EDITABLE_0));
            } else {
                m_formatForm.setRatioButton(false, true, null);
            }
            m_ratioLocked = true;
        }
        // enabling/disabling height and width input
        m_formatForm.setHeightInputEnabled(m_currentFormat.isHeightEditable() || hasUserFormatRestriction());
        m_formatForm.setWidthInputEnabled(m_currentFormat.isWidthEditable() || hasUserFormatRestriction());
    }