0

I am attempting to shrink the size of one image without losing quality so I can place that shrunk image within a different image.

In my attempts to shrink: quality was demolished.

So my ingenious idea: Just grow the larger image size by the amount I would have shrunk the smaller image, so neither of the images lose quality!

AND IT WORKED!....EXCEPT now that one megabyte image became 100 megabytes. So...slight issue there.

I am using nodejs. How can I shrink this image without losing quality?

EDIT: I tried using sharp to reduce image size without reducing quality....not strong enough at alll. The image reduction is by a factor of 10. So, I need some other way to be able to put one image within another.

EDIT #2: I have an observation...and a half thought through theory. The observation: Apps like google docs or google slides, where I can resize images and place them within others without losing quality(at least not noticable, no matter the shrink amount). Thus, if that can be replicated... My theory that is separate: If I can somehow use seam carving alongside a third reference image, something might happen and it might work. If, there is a white image(the reference image) that is 10000px by 10000px, and I then place the regular 1000px by 1000px image within it, would seam-carving not then be able to turn that white image into a 1 by 1 pixel since it is all white? But then leave the actual image untouched? Thus, if I can somehow maintain that base white image, and place the other image supposedly inserted inside the prior...into the image with the reference as the white image...it might work?

3
  • It is conceptually impossible to reduce the resolution of an image, while also maintaining the resolution of that image. So the short answer is "you can't". The longer answer is the pigeonhole principle. If you reduce the number of pixels, you cannot fit the original number of pixels into the reduced size pixel grid without some of those original pixels ending up on top of each other, thus losing image information. Commented Feb 28, 2023 at 4:59
  • Thanks @Mike'Pomax'Kamermans. Makes sense now when someone says "pingeonholed". Commented Feb 28, 2023 at 6:19
  • You can shrink an image's file size in three ways. 1) Use a different format that has a better compression scheme, 2) Reduce the number of pixels, 3) Increase the lossiness of the compression. #2 and #3 will by definition reduce the quality of the image, but the trick is do it just enough that your end use can't really tell. That depends entirely upon what the end-use is. For #1, some of the newer compression schemes can do better than the older schemes, but this means changing the image's format. So, if you have a fixed format, you can't use #1. Commented Feb 28, 2023 at 7:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.