Numpy Resize/Rescale Image

Yeah, you can install opencv (this is a library used for image processing, and computer vision), and use the cv2.resize function. And for instance use: import cv2 import numpy as np img = cv2.imread(‘your_image.jpg’) res = cv2.resize(img, dsize=(54, 140), interpolation=cv2.INTER_CUBIC) Here img is thus a numpy array containing the original image, whereas res is a … Read more

Can I style the resize grabber of textarea?

WebKit provides the pseudo-element ::-webkit-resizer for the resize control it automatically adds to the bottom right of textarea elements. It can be hidden by applying display: none or -webkit-appearance: none: ::-webkit-resizer { display: none; } <textarea></textarea> This displays as follows in Chrome 26 on OS X: Note: Adding display: none to ::-webkit-resizer doesn’t actually prevent … Read more

WPF: Setting the Width (and Height) as a Percentage Value

You can put the textboxes inside a grid to do percentage values on the rows or columns of the grid and let the textboxes auto-fill to their parent cells (as they will by default). Example: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=”2*” /> <ColumnDefinition Width=”3*” /> </Grid.ColumnDefinitions> <TextBox Grid.Column=”0″ /> <TextBox Grid.Column=”1″ /> </Grid> This will make #1 … Read more

Merging two images with PHP

I got it working from one I made. <?php $dest = imagecreatefrompng(‘vinyl.png’); $src = imagecreatefromjpeg(‘cover2.jpg’); imagealphablending($dest, false); imagesavealpha($dest, true); imagecopymerge($dest, $src, 10, 9, 0, 0, 181, 180, 100); //have to play with these numbers for it to work for you, etc. header(‘Content-Type: image/png’); imagepng($dest); imagedestroy($dest); imagedestroy($src); ?>

Calculating image size ratio for resizing

Here’s code from my personal grab bag of image resizing code. First, data you need: list($originalWidth, $originalHeight) = getimagesize($imageFile); $ratio = $originalWidth / $originalHeight; Then, this algorithm fits the image into the target size as best it can, keeping the original aspect ratio, not stretching the image larger than the original: $targetWidth = $targetHeight = … Read more

Painted content invisible while resizing in Java

For reference, here is the same program using Swing. Because JPanel is double buffered, it doesn’t flicker as the mouse is released after resizing. import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; public class SwingPaint { public static void main(String[] args) { JFrame frame = new JFrame(); frame.add(new CirclePanel()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); } private static … Read more