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
9
votes
2 answers

Make drawable do centerCrop in layer-list

all. I want to make splashscreen: drawable/background_splash:
Yurii Kot
  • 316
  • 3
  • 11
9
votes
2 answers

How to create resizable ImageView in Android

I want a user of my app to be able to modify an image at run time. The user should be able to modify the image height and width by tapping on the corner of the image-view and dragging it as illustrated in the following diagram: I have spent a lot…
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75
9
votes
8 answers

Finding closest larger resolution with nearest aspect ratio in an array of resolutions

I have an array: $resolutions = array( '480x640', '480x800', '640x480', '640x960', '800x1280', '2048x1536' ); I want to retrieve closest larger value with the nearest aspect ratio (same orientation). So, in case of $needle =…
tomsseisums
  • 13,168
  • 19
  • 83
  • 145
9
votes
3 answers

php resizing image on upload rotates the image when i don't want it to

I Have an upload script that resizes the images uploaded, however, some images are being saved as a rotated image when i dont want them to, any way to preserve the original image direction? if (($resizeObj->width > 400) || ($resizeObj->height >…
neeko
  • 1,930
  • 8
  • 44
  • 67
8
votes
4 answers

Compress Image in android

I am making an application which takes image from the camera and then email it. Friends since you know that images from camera may be of too much resolution and in size as well e.g. 2.0MB and more so what i want is to re-size the image in size as…
Shah
  • 4,990
  • 10
  • 48
  • 70
8
votes
0 answers

What is the difference between PIL's and OpenCV's resize

I came over the following issue: the resize functions of these two libraries behave differently. Here is a small test: import numpy as np import PIL import cv2 from matplotlib import pyplot as plt img = np.random.randn(10, 10, 3) SIZE = (5, 5) img…
DiKorsch
  • 1,240
  • 9
  • 20
8
votes
2 answers

Efficiently resize batch of np.array images

I have a 4D np.array size (10000,32,32,3) that represents a set of 10000 RGB images. How can I use skimage.transform.resize or other function to resize all images efficiently so that the (32,32) is interpolated to (224,224)? I'd prefer to do this…
Austin
  • 6,921
  • 12
  • 73
  • 138
8
votes
2 answers

How to build an autograd-compatible Pytorch module that resizes tensors like images?

I was wondering if I can build an image resize module in Pytorch that takes a torch.tensor of 3*H*W as the input and return a tensor as the resized image. I know it is possible to convert tensor to PIL Image and use torchvision, but I also hope to…
Lotayou
  • 162
  • 11
8
votes
3 answers

SWT: How to do High Quality Image Resize

My application needs to resize ImageData. Unfortunately, I haven't gotten the results I want with GC (with antialias on and interpolation on high), or ImageData.scaledTo(). The resulting image is of too low a quality to be acceptable. What's the…
Jonah
  • 9,991
  • 5
  • 45
  • 79
8
votes
2 answers

Setting the content-type of a blob in Azure functions app blobtrigger

I am trying to resize the images uploaded to my container in order to create thumbnails and various other versions of my images for my site. The images I upload have to correct content-type "image/jpeg" but when I create a new version of them using…
8
votes
2 answers

React Native- Resize Image and convert to base64

So I'm using react-native-signature-capture to capture a signature, but I wan't to cut down on the image size before encoding it. I used https://github.com/bamlab/react-native-image-resizer to resize the image, but now I don't know how to convert it…
Matt Aft
  • 8,742
  • 3
  • 24
  • 37
8
votes
3 answers

Django: changing image size and upload to S3

I have inherited a Django Project and we have moved images to S3 One of the models is a typical user profile class Profile(UUIDBase): first_name = models.CharField(_("First Name"), max_length=20) last_name = models.CharField(_("Last Name"),…
fiacre
  • 1,150
  • 2
  • 9
  • 26
8
votes
3 answers

Pixelate Image With Pillow

I am working on a project where I want to take a picture of a colored grid as an input (made with Lego bricks in this example) and return a much smaller modified picture. Here is an example input: Below is a very small 8x8 image that would be the…
Josh B.
  • 414
  • 5
  • 14
8
votes
1 answer

Bicubic interpolation artifacts (image upscale)

I am using a bicubic interpolation algorithm in order to upscale an height map, and I am noticing some artifacts around the pixels boundaries. However, these artifacts don't seem to appear when I use a simple cubic interpolation (spline). Could it…
deck
  • 343
  • 2
  • 11
8
votes
2 answers

Why smaller PNG image takes up more space than the original after getting resized by GraphicsMagic

The original PNG image is 800x1200 and takes up about 34K. After the images is resized by GraphicsMagick to 320x480 size, the resulting images takes up approximately 37K. (For comparison, if the image is resized with Paint on Windows 7 then the…
shargors
  • 2,147
  • 1
  • 15
  • 21