Limit image file size; if bigger, then decrease file size with lossy compression/resizing/etc. for saving disk space When the user uploads an image with a large file size, I would like to allow him/her doing this (not restricting the file size generally, because many users don't know how to resize an image by themselves), BUT after this, I would like to decrease the file size of this image (the original file!) somehow to save disk space (lossy compression/resizing/etc.).
My site is on a shared hosting, so unfortunately ImageMagick is not available.

This question is very closely related, but does not contain any detailed information about the specific solution: How can I reduce the file sizes of the original versions of uploaded image files?

I also found the ImageAPI Optimize module, which can solve the optimization of the image via the online Yahoo! Smush.It service, but optimization is not a restriction for the file size.
There are some related topics about limiting the file size of an image on Stack Overflow and Super User too:


https://stackoverflow.com/questions/1258634/how-to-resize-an-image-in-c-sharp-to-a-certain-hard-disk-size
https://stackoverflow.com/questions/2094064/how-to-resize-a-picture-to-a-specific-file-size
https://superuser.com/questions/201440/batch-resize-jpeg-images-to-a-fixed-file-size/297029#297029


Is there a Drupal-based solution for this task?

If it's unaccomplishable or too complex, maybe I should use an integrated solution with http://www.jpegmini.com/, but I don't know any modules which solves this.
The built-in functions will not do this.

You will have to write a hook for the form,  upload the image at the original large size and then use Imagemagick (or similar) to process the image.  

I only suggest Imagemagick because it's got more tools than GD and you should be able to re-size the image in a loop, testing for filesize and resizing/re-compressing as necessary.