compress image or reduce image size in kb

Upload an image and Compress it to your preferred percentage in seconds.

Compress by % (val: 1-100)
Result Preview
Download

Example with Numbers

Let’s use the headshot image dimensions (1000x1500 pixels) and assume it’s a JPEG with an original file size of 500 KB.

First Call: resizePercentage=10

  • New Dimensions:
    • Width = 1000 * 0.1 = 100 pixels
    • Height = 1500 * 0.1 = 150 pixels
    • New dimensions = 100x150 pixels
  • Pixel Count:
    • Original: 1000x1500 = 1,500,000 pixels
    • New: 100x150 = 15,000 pixels
    • New pixel count is 1% of the original (15,000 / 1,500,000 = 0.01).
  • File Size:
    • Since the pixel count is reduced to 1%, the file size will drop significantly. For a JPEG, with image.Quality = 80, the file size might drop to ~5-10 KB (a 98-99% reduction from 500 KB), depending on the image content and compression settings.
  • Interpretation:
    • The dimensions are indeed 10% of the original (width and height are each 10%).
    • The pixel count (area) is 1% of the original.
    • The file size is likely much less than 10% of the original (e.g., 1-2% of the original 500 KB).

Misconception Clarified

It seems there might be a misunderstanding about what "10% of the original image" means in terms of resizing:

  • Dimensions: A resizePercentage=10 reduces each dimension (width and height) to 10% of its original value.
  • Pixel Count (Area): Because both dimensions are scaled by 0.1, the total pixel count is reduced to 0.1 * 0.1 = 0.01 (1%) of the original.
  • File Size: The file size reduction will typically be much greater than 10%, because file size is more closely tied to pixel count (which drops to 1%) and the compression settings.

If you wanted the pixel count to be 10% of the original (rather than 1%), you would need to scale the dimensions by the square root of 0.1 (approximately 0.316). For example:

  • To make the pixel count 10% of the original:
    • New area = 10% of original area = 0.1 * (width * height)
    • Scale factor for each dimension = sqrt(0.1) ≈ 0.316
    • New width = 1000 * 0.316 ≈ 316 pixels
    • New height = 1500 * 0.316 ≈ 474 pixels
    • New pixel count = 316 * 474 ≈ 149,784, which is ~10% of 1,500,000.