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
741
votes
18 answers

Resize image proportionally with CSS?

Is there a way to resize (scale down) images proportionally using ONLY CSS? I'm doing the JavaScript way, but just trying to see if this is possible with CSS.
codingbear
  • 14,773
  • 20
  • 48
  • 64
338
votes
19 answers

Resizing an image in an HTML5 canvas

I'm trying to create a thumbnail image on the client side using javascript and a canvas element, but when I shrink the image down, it looks terrible. It looks as if it was downsized in photoshop with the resampling set to 'Nearest Neighbor' instead…
Telanor
  • 4,419
  • 6
  • 29
  • 36
227
votes
19 answers

Responsive css background images

I have a website (g-floors.eu) and I want to make the background (in css I have defined a bg-image for the content) also responsive. Unfortunately I really don't have any idea on how to do this except for one thing that I can think of but it's quite…
jochemke
  • 2,447
  • 3
  • 15
  • 10
183
votes
7 answers

Resize Google Maps marker icon image

When I load an image into the icon property of a marker it displays with its original size, which is a lot bigger than it should be. I want to resize to the standard to a smaller size. What is the best way to do this? Code: function…
168
votes
2 answers

Resize image to full width and fixed height with Picasso

I have a vertical LinearLayout where one of the items is an ImageView loaded using Picasso. I need to rise the image's width to the full device width, and to display the center part of the image cropped by a fixed height (150dp). I currently have…
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
164
votes
3 answers

Changing image size in Markdown on Gitlab

I'm trying to post a picture to a file on my Gitlab using markdown ![](test/media/screenshot.png) seems to work but is far too large. Other solutions I've tried and don't seem to work are as follows:
Ben Kelly
  • 1,641
  • 2
  • 7
  • 4
123
votes
13 answers

Resize image in PHP

I want to write some PHP code that automatically resizes any image uploaded via a form to 147x147px, but I have no idea how to go about it (I'm a relative PHP novice). So far, I've got images uploading successfully, filetypes being recognized and…
Alex Ryans
  • 1,865
  • 5
  • 23
  • 31
118
votes
20 answers

EC2 Can't resize volume after increasing size

I have followed the steps for resizing an EC2 volume Stopped the instance Took a snapshot of the current volume Created a new volume out of the previous snapshot with a bigger size in the same region Deattached the old volume from the…
Wilman Arambillete
  • 1,411
  • 2
  • 11
  • 12
108
votes
7 answers

How to set max width of an image in CSS

On my website I would like to display images uploaded by user in a new window with a specific size (width: 600px). The problem is that the images may be big. So if they are bigger than these 600px, I would like to resize them, preserving the aspect…
user1315305
  • 1,329
  • 2
  • 11
  • 20
103
votes
4 answers

Batch resize images and output images to new folder with ImageMagick

Current image folder path: public_html/images/thumbs Output image folder path: public_html/images/new-thumbs I have 10 video thumbs per video in current folder, named of image thumbs: 1-1.jpg 1-2.jpg 1-3.jpg 1-4.jpg 1-5.jpg…
richard
  • 1,456
  • 4
  • 15
  • 22
97
votes
12 answers

Node.js: image resizing without ImageMagick

I'm developing a web app on Node.js (+ express 4) where users can set their profile image by uploading it to the server. We already limit the file mimetype and max filesize, so the user can't upload more than 200KB png or jpeg images. The problem is…
zacr0
  • 1,081
  • 1
  • 8
  • 9
81
votes
3 answers

AWS Lambda "errorMessage": Task timed out after 3.00 seconds

Lambda function showing the below error in test when changing file format from png to text "errorMessage": "2020-07-17T07:06:45.969Z b66dd037-ba01-4025-97db-6527b486eac8 Task timed out after 3.00 seconds"
eagletech
  • 821
  • 1
  • 5
  • 4
62
votes
6 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.
  • 21,477
  • 35
  • 135
  • 214
60
votes
11 answers

How can I read (from disk) and resize an image, in Flutter/Dart

In Flutter/Dart, how can I perform the following 3 steps: Read an image from disk, Read its original dimensions (width and height), Resize it. Note: I must be able to display the final result with a regular Flutter Image widget. CLARIFICATION:…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
60
votes
3 answers

Android - Reduce image file size

I have an URI image file, and I want to reduce its size to upload it. Initial image file size depends from mobile to mobile (can be 2MB as can be 500KB), but I want final size to be about 200KB, so that I can upload it. From what I read, I have (at…
KitKat
  • 715
  • 2
  • 7
  • 10
1
2 3
99 100