Questions tagged [image-resizing]

Image resizing is the downscaling or upscaling of an image. Dozens of algorithms exist, all with performance vs. quality tradeoffs.

Image resizing (also called image scaling) is the downsampling or up-sampling of an image using an interpolation algorithm. Common downscaling algorithms are Lanczos, Bicubic Sharper, Bicubic Smoother, Fant, Bicubic, Bilinear, and NearestNeighbor (listed in order of average result quality). Fractal algorithms often produce better results for upscaling photos, while there are many algorithms optimized for upscaling pixel art.

Due to algorithmic complexity, most developers use library implementations of these algorithms.

FreeImage

Offers CatmullRom, Lanczos3, bspline, box, bicubic, and bilinear filters. FreeImage focuses on implementation simplicity, and doesn't use hardware accelerations or SIMD extensions, so these speeds may not be acceptable for real-time display of images.

Windows GDI+

While loathed by many, GDI+ does include an excellent 2-pass Bicubic filter. It offers: 2-pass Bicubic, 1-pass bicubic, bilinear, and nearest neighbor. Those using it should be aware that it may add rings to images unless WrapMode is set to TileXY, as otherwise the algorithm samples data from outside the image bounds.

WIC (Windows Imaging Components)

The IWICBitmapScaler class offers Fant, 1-pass bicubic, bilinear, and nearest neighbor. Implementations are optimized for performance, and can be 2-4x faster than their GDI counterparts, although there isn't currently a 2-pass bicubic filter such as offered by GDI+

2188 questions
5
votes
3 answers

How to resize a Base64 encoded Data URI PNG using javascript?

I have a Base64 encoded PNG squeezed out of a web socket into a web page, that I display using Data URI Is there a way in javascript or some of its flavours to resize the image I receive into…
Francesco
  • 315
  • 1
  • 3
  • 9
5
votes
2 answers

Dynamically shrink an image with Google Images API, but do not enlarge

Google provides an excellent way to resize images dynamically; simply append =sXX to the image URL. This is perfect if you want to shrink an image, but if the image is smaller than the size specified, it enlarges it, giving it a pixelated effect.…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
5
votes
3 answers

How to resize image without adding noise with python?

I have an image and I want to resize and expand this image without spoiling it. The image: The image size: w=41 h=43 The image size I want it resized to: w=2000x h=2100 I tried all the known methods: with PIL.Image: from PIL import…
5
votes
2 answers

Resize Image using Opencv Python and preserving the quality

I would like to resize images using OpenCV python library. It works but the quality of the image is pretty bad. I must say, I would like to use these images for a photo sharing website, so the quality is a must. Here is the code I have for the…
CC.
  • 2,736
  • 11
  • 53
  • 70
5
votes
2 answers

Optimal way to resize an image with OpenCV Python

I want to resize an image based on a percentage and keep it as close to the original with minimal noise and distortion. The resize could be up or down as in I could scale to 5% the size of the original image or 500% (or any other value these are…
James
  • 77
  • 1
  • 1
  • 6
5
votes
8 answers

Take an image directory and resize all images in the directory

I am trying to convert high resolution images to something more manageable for machine learning. Currently I have the code to resize the images to what ever height and width I want however I have to do one image at a time which isn't bad when I'm…
rzaratx
  • 756
  • 3
  • 9
  • 29
5
votes
1 answer

DrawImage resized image too small

When I draw an image using Graphics.DrawImage and draw it at a bigger size than the original image, it ends up being a bit too small. You can see this in the following picture: The green lines shouldn't be visible and are not part of the image.…
Jonas Kohl
  • 1,018
  • 1
  • 11
  • 28
5
votes
1 answer

NodeJS Animated gif resizing

I am trying to resize an animated gif using NodeJS. I need it to stay animated after resizing. My app is currently using Sharp to resize other images, but it appears to not support exporting animated gifs. If possible I would like to find an npm…
Kiruchi
  • 195
  • 3
  • 13
5
votes
2 answers

imagecopyresampled to resize and crop an image - not returning the expected result

imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) This is what I want to do: I have an image that's 600x1000px in size, and I want…
David
  • 163
  • 1
  • 2
  • 9
5
votes
0 answers

transform() or override() or centerCrop() not working with glide Android

This app currently is working perfectly fetches and displays images but when I try to add additional methods to glide in the ImageListAdapter class like override() or centerCrop() or transform() or placeholder(), it doesn't work. I mean it doesn't…
Pb Vignesh
  • 185
  • 1
  • 1
  • 10
5
votes
1 answer

Resize image by percentage on both x and y on command line with Gimp

AFAIK, it should be possible. I know that convert of ImageMagick makes this task trivial, but I cannot use ImageMagick, therefore I am leaning towards Gimp (on Windows). I have tried with this Guile script: (define (resize-image filename…
Eleno
  • 2,864
  • 3
  • 33
  • 39
5
votes
3 answers

How to resize without interpolation (zero-padding) in OpenCV?

Is there an efficient way to resize an image in OpenCV without using any interpolation? Instead of the conventional "resize" I would like my image to remap the pixels into a larger image but pad everything else with 0. e.g. to scale up img1 below 2x…
Sefu
  • 2,404
  • 8
  • 42
  • 59
5
votes
1 answer

Swift: UIGraphicsBeginImageContextWithOptions scale factor set to 0 but not applied

I used to resize an image with the following code and it used to work just fine regarding the scale factor. Now with Swift 3 I can't figure out why the scale factor is not taken into account. The image is resized but the scale factor not applied. Do…
Sam
  • 1,101
  • 2
  • 13
  • 26
5
votes
1 answer

resize transparent image in opencv python (cv2)

I have an image with shape (120, 470, 4) and I want to resize it to another size e.g. (100, 400, 4). I try to achieve it by using cv2.resize function as bellow reshaped_image = cv2.resize(image, (100, 400)) and paste the reshaped_image inside a…
5
votes
5 answers

How to resize/compress a camera image or gallery image in android before upload to server?

I have to upload image which may be choose from gallery or take by camera. I have done this successfully. But problem is , some time image size is 1MB. So it takes more time to upload to server. I need to resize this image before upload. How to do…
The Bala
  • 1,313
  • 1
  • 15
  • 23