3

I would like to make the size of images smaller automatically when users upload them using CCK image field.

For example, I would like to let users upload big sized images like 5MB but resize them smaller automatically like 0.5MB before saved on the server.

The reason is that the capacity I can use on the shared server is very limited. Of course I can set "Maximum upload size per file" to a small size but then users who have big sized images but don't know how to resize them before upload will not be able to upload them. I have tried also "image cache" a bit but it doesn't seem to save the files with the name, attributes and in the directory specified by CCK image field.

I don't know if this kind of thing is possible to achieve or not.. Any Idea?

4 Answers 4

3

Imagecache is great, but since it keeps the original file around, it won't save space. In fact, if you have multiple presets, it will increase your disk usage as it creates its caches of images of those sizes.

What you may want to investigate is putting some logic into nodeapi() (or, if on Drupal7, its equivalent function) when saving your node that looks at the filepath of whatever image field you are concerned with and does some image manipulation on it if it is over a certain size and then saving it in place.

3
  • Thanks, however it seems to be over my head using nodeapi() thing as I'm not a coder. So looks like this is not something easy to achieve? By the way, I'm on Drupal 6.
    – chinita7
    Commented Jan 19, 2012 at 17:55
  • Well, you could also set maximum dimensions for your image upload, and then it would be resized within those maximums, which might help out a bit.
    – Jimajamma
    Commented Jan 19, 2012 at 18:03
  • "maximum dimensions" is a kind of what I was looking for. Thanks!
    – chinita7
    Commented Mar 7, 2012 at 16:37
2

The module you want is: Max Image Size

This module will resize uploaded images to be below the set dimensions. It is not an image style or other presentation layer module. If you want to maintain the original image you should use Image Resize Filter or an image style. The use case for this module is sites where users may upload very large images, but you do not want/need to keep the original.

This is different from the core image field size restrictions in that it will work on already uploaded files and imported content.

1
  • This module currently is for Drupal 7 only.
    – daniels
    Commented Sep 3, 2015 at 19:02
1

The imagefield cck field (which depends on filefield) provides this capability out of the box. You add a filefield to your content type, set the display widget to "image", and then when you edit the settings for the field one of the settings is called "Maximum dimensions for images". Here you can set this to something like 600x400, or whatever you like. If a larger image is uploaded, it will automatically be resized.

-1

Not really what you're asking for but anyway: You already discovered the Drupal way of handling big images: image cache. If you can, switch to a hoster with a lot of storage (some offer unlimited space).

1
  • Yes, switching the host is probably the best solution. But my point is that I would like to let users upload big files but practically save them as small files if possible..
    – chinita7
    Commented Jan 19, 2012 at 16:06

Your Answer

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

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