![imagemagick canvas resize imagemagick canvas resize](https://i.pinimg.com/originals/ad/1b/2e/ad1b2ebf604b5e97881377fff9540d3c.png)
$ convert v.jpg -resize 200x200 -background skyblue -gravity center -extent 200x200 scaled-v-im.jpg See here for descriptions of the resizing commands. It's very easy to do what you want with a single command. ImageMagick is a simple, but well-built command-line interface to do basic image processing. Sq_img = cv2.imread('sq.jpg') # square image H_img = cv2.imread('h.jpg') # horizontal image V_img = cv2.imread('v.jpg') # vertical image
![imagemagick canvas resize imagemagick canvas resize](https://i.imgur.com/110Y8ci.png)
Scaled_img = cv2.copyMakeBorder(scaled_img, pad_top, pad_bot, pad_left, pad_right, borderType=cv2.BORDER_CONSTANT, value=padColor) Scaled_img = cv2.resize(img, (new_w, new_h), interpolation=interp) If len(img.shape) is 3 and not isinstance(padColor, (list, tuple, np.ndarray)): # color image but only one color provided Pad_left, pad_right, pad_top, pad_bot = 0, 0, 0, 0
![imagemagick canvas resize imagemagick canvas resize](https://i.ytimg.com/vi/CJs06bzI-Nc/maxresdefault.jpg)
Pad_left, pad_right = np.floor(pad_horz).astype(int), np.ceil(pad_horz).astype(int) New_w = np.round(new_h*aspect).astype(int) Pad_top, pad_bot = np.floor(pad_vert).astype(int), np.ceil(pad_vert).astype(int) New_h = np.round(new_w/aspect).astype(int) So, after resizing we'll end up with a 1000xN or Nx1000 image (where N sh or w > sw: # shrinking imageĪspect = w/h # if on Python 2, you might need to cast as a float: float(w)/h To shrink an image, it will generally look best with CV_INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with CV_INTER_CUBIC (slow) or CV_INTER_LINEAR (faster but still looks OK). Note that if aspect is greater than 1, then the image is oriented horizontally, while if it's less than 1, the image is oriented vertically (and is square if aspect = 1).ĭifferent interpolation methods will look better depending on whether you're stretching the image to a larger resolution, or scaling it down to a lower resolution. So the most robust way to do this is to find the aspect ratio and calculate what the smaller dimension would be when the bigger one is stretched to 1000. However, resize() requires that you put in either the destination size (in both dimensions) or the scaling (in both dimensions), so you can't just put one or the other in for 1000 and let it calculate the other for you.
Imagemagick canvas resize windows#
2.10.10 on Windows 10.You can use resize() in OpenCV to resize the image up/down to the size you need.
Imagemagick canvas resize manual#
I'd be very grateful if someone could give me pointers! Any kind of method that would take away the manual calculation and canvas resizing would be terrific.
![imagemagick canvas resize imagemagick canvas resize](https://i.stack.imgur.com/Q5pj7.png)
I have written some Visual Basic macros though for Excel I know there's a scripting subsection here too, if a script is the way forward here sorry for posting in the wrong place - I just don't know really anything about the scripts. Export as JPG with "_Wide" added to filename before the dotĮxporting & saving the resulting image doesn't have to be a part of the automation, but would surely be handy. Go to Layer > Canvas size, input New Width (width and height fields unbound) Use calculator to multiply height of image by 1.7777. The process, when done manually, is as follows: Is there a way to somehow automate this on GIMP? There's no other way to display the whole images than reprocessing them to 16:9, but I don't want to do this manually. I'm a first time poster so please excuse me if this is already answered, I tried to find the answer here and elsewhere but no success yet.īasically my problem is that I'd like to use my photos as Google Chromecast wallpapers, but many of them (100+) are in aspect ratios (and in many different resolutions) that are not quite 16:9, and in these cases Chromecast just pan & scans the photo.