How To: limit image size

jørgen

Joined: 2009-09-29
Posts: 13
Posted: Sun, 2010-01-03 14:16

I would like to limit the size of images added to an album. If the image is either to large or to small (based on pixel dimensions), I would like to just present an error message to the user (and not include the uploaded image in the album).

How do I check the size of an image beeing uploaded? How to I present an error message to the user? How can I prevent the uploaded image from beeing included in the album? I can live with hard coded limits.

Any ideas are most welcome...

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2010-01-03 14:53

you can use the size limit module.
edit album -> Define picture size limit

But why not have gallery build resizes of your desired size and discard the original?
edit album -> Resized Images

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
jørgen

Joined: 2009-09-29
Posts: 13
Posted: Sun, 2010-01-03 15:41

Thanks for the quick reply! The Size Limit module sounds promising! However, it seems that this module only imposes an upper size limit. I also need a lower limit. In addition, the module will silently handle size violations. I would like to issue an error/warning/message if the size is not appropriate (at least if the image is not large enough).

Yes, the automatic resize of images is useful (again if the images are large enough to begin with).

I am trying to use Gallery as a platform for online photo competitions. The images submitted will be downloaded from Gallery and judged using either a large monitor or an HD projector. For this reason the images need to be large enough (1920x1200 or larger). I think that the system should warn contestants that their images do not have the appropriate size for a fair judgment.

Also, I thought to just do it the simple way and reject images that do not have the appropriate size (it will still be very useful to have the smaller versions generated by Gallery when viewing the content of an album to get an overview of submitted images though).

So it would be nice to be able to check the image size somehow and to take an approriate action.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2010-01-03 16:02
Quote:
However, it seems that this module only imposes an upper size limit. I also need a lower limit. In addition, the module will silently handle size violations. I would like to issue an error/warning/message if the size is not appropriate (at least if the image is not large enough).

You will have to write the software to do this yourself, if the supplied modules don't do what you want.

 
jørgen

Joined: 2009-09-29
Posts: 13
Posted: Sun, 2010-01-03 20:56

Thanks again for the feedback! OK, I will give it a try. I have very little experience with Gallery (I managed to tweak the "Assign Permissions" module though to fix a permission requirement for my competition application, http://gallery.menalto.com/node/93502), so I am looking for some pointers on how to attack the size-checking problem (and how to generate a messages to the user).

Looks like Gallery is very flexible when it comes to customization. Any modules and/or code fragments I could look at to get some idea on how to check the size and take action if its not OK?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2010-01-04 03:06
Quote:
Any modules and/or code fragments I could look at to get some idea on how to check the size and take action if its not OK?

Well, obviously, the sizelimit module is a good place to start. That, and a thorough knowledge of the G2 API is really all you need.

 
villas

Joined: 2010-08-04
Posts: 4
Posted: Wed, 2010-08-04 13:25

I need that plugin too .. I need to limit the file size when user upload a file like 10mpx (aprox 4MB per image). Any idea how to limit this in gallery 3 ?
Thanks

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2010-08-04 15:58

This thread is for G2. There is no such module for G3 yet.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here