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+

2028 questions
34
votes
4 answers

How to stop GD2 from washing away the colors upon resizing images?

I have developed a photo sharing community site using CodeIgniter 1.7. Photos that are uploaded by members are automatically resized in a number of formats, for which I use the CodeIgniter Image Manipulation class. This class is built into the…
Fer
  • 3,794
  • 13
  • 52
  • 98
34
votes
4 answers

React Native - How to make image width 100 percent and vertical top?

I am newbie at react-native. What I want to do is that fit an image in device and keep the ratio of image. Simply I want to make width : 100% I searched how to make it and seems resizeMode = 'contain' is good for that. However, since I used…
Téwa
  • 824
  • 2
  • 11
  • 19
34
votes
6 answers

Convert and resize SVG to PNG

I am trying to convert SVG to PNG (or any raster format) and resize at the same time. I thought I would use ImageMagick for this task but it seems to be converting to raster before resizing. This results in a poor quality image. Is there a way to…
DJL
  • 1,821
  • 3
  • 17
  • 31
31
votes
7 answers

Laravel / Intervention Image Class - class not found

I just installed Intervention Image Class following instructions from here: http://image.intervention.io/getting_started/installation I also added these 2 lines into config/app.php file: 'Intervention\Image\ImageServiceProvider' 'Image' =>…
Tomas Turan
  • 1,105
  • 3
  • 16
  • 25
30
votes
6 answers

How to save PNG file from NSImage (retina issues)

I'm doing some operations on images and after I'm done, I want to save the image as PNG on disk. I'm doing the following: + (void)saveImage:(NSImage *)image atPath:(NSString *)path { [image lockFocus] ; NSBitmapImageRep *imageRepresentation…
29
votes
5 answers

How to resize an image to a specific size in OpenCV?

IplImage* img = cvLoadImage("something.jpg"); IplImage* src = cvLoadImage("src.jpg"); cvSub(src, img, img); But the size of the source image is different from img. Is there any opencv function to resize it to the img size?
Milad R
  • 1,734
  • 7
  • 23
  • 32
26
votes
2 answers

Resize image with mogrify without keeping aspect ratio

I feel silly for having to ask such a simple question, but I have spent the past hour having absolutely no luck whatsoever finding a solution to this. Everyone seems like they need to do the exact opposite of what I need to do. My question is simply…
ozdrgnaDiies
  • 1,799
  • 1
  • 17
  • 30
25
votes
4 answers

PHP image resize on the fly vs storing resized images

I'm building a image sharing site and would like to know the pros and cons of resizing images on the fly with PHP and having the resized images stored. Which is faster? Which is more reliable? How big is the gap between the two methods in speed…
Pablo
  • 5,357
  • 6
  • 32
  • 48
24
votes
5 answers

Android: Bitmap resizing using better resampling algorithm than bilinear (like Lanczos3)

Is there any way or external library that can resize image using Lanczos (ideally) or at least bicubic alg. under Android? (faster is better of course, but quality is priority, a processing time is secondary) Everything what I've got so far is…
Jolinar
  • 834
  • 7
  • 16
24
votes
8 answers

Serving Images with on-the-fly resize

my company has recently started to get problems with the image handling for our websites. We have several websites (adult entertainment) that display images like dvd covers, snapshots and similar. We have about 100'000 movies and for each movie we…
Morfildur
  • 12,196
  • 6
  • 32
  • 54
23
votes
4 answers

Quality of Image after resize very low -- Java

In the script it is going from around the 300x300 mark down to 60x60. Need to improve the overall image quality as it is coming out very poorly at the moment. public static Boolean resizeImage(String sourceImg, String destImg, Integer Width,…
dutchman191
  • 233
  • 1
  • 2
  • 7
22
votes
5 answers

Sharp image library rotates image when resizing?

When using the sharp image resize library https://github.com/lovell/sharp for node.js, the image is being rotated. I have no code thats says .rotate(), so why is it being rotated and how can I stop it from rotating? I'm using the…
JK.
  • 20,010
  • 29
  • 124
  • 204
21
votes
2 answers

how to create proportional image height/width

So, I want to have an image resized to 30% of its original height/width. Pretend you don't know its height or width, how would you go about it using only CSS/HTML?
PizzaPie
  • 235
  • 1
  • 2
  • 7
20
votes
4 answers

A Batch Script To Resize Images

I'm looking for some help in writing a batch script to resize a bunch of .jpg images. I don't have much experience with batch scripts. But this task will be preformed on a windows machine & so I thought a batch script might be a good way to go. I'm…
Reed Williams
  • 277
  • 1
  • 4
  • 10
20
votes
1 answer

How to resize and save an image which uploaded using file upload control in c#

i have developed a web application using asp.net mvc4 and razor. in my application there's a file upload control to upload an image and save in a temporary location. before save image should re-sized to a specific size and then save in the temporary…
sanzy
  • 805
  • 7
  • 18
  • 28