2

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:

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.

2

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.

  • Thanks, but as I wrote, "My site is on a shared hosting, so unfortunately ImageMagick is not available." :( What alternative solutions would you suggest? – Sk8erPeter Aug 26 '13 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.