Content Construction Kit (CCK) 6.x-2.1
ImageField 6.x-3.0-alpha4
tmp and files directories are writeable
download method = public
I'm trying to ensure I have an image of a set resolution. To do this I've set the maximum and minimum resolutions to the same dimensions (198x264px). If I try to upload an undersized image I get the expected message returned;
The selected file imagename1.gif could not be uploaded. The image is too small; the minimum dimensions are 198x264 pixels.
If I try to upload an oversized image I now get two messages, the first says;
The image was resized to fit within the maximum allowed dimensions of 198x264 pixels.
All well and good...but below that it then tells me;
The selected file imagename2.jpg could not be uploaded. The image is too small; the minimum dimensions are 198x264 pixels.
It looks as though these are working individually but not in conjunction with each other...unless the image is ALREADY of the EXACT resolution specified, in which case it will upload.
Comments
Comment #1
dman commentedWell, by enforcing both minimum and maximum res at the upload stage, you are explicitly requiring the input to be exact. Even before the resizer can fix it. Therefore extremely limiting. I think.
Did you think of trying to enable imagecache and just resizing the things after they are uploaded?
Comment #2
axel pressbutton commentedThanks for the prompt reply dman.
Yes, I see your point. Hmmmm. Would this need to be changed to a feature request? Possibly that if both options are defined and are the same value then possibly offer the admin the choice to say 'exact size only, NO resizing' and 'allow resizing of oversized images but still reject smaller images'.
It's almost as though the logic is almost doing this as it tries the resize and then fails to upload the image size it has just resized to. I guess the other alternative could be to change the error messages received in this situation...instead of 'resize success' followed by a 'sorry it's too small' maybe a 'sorry we'd like an exact size uploaded please'? (not very user friendly though :( )
Sadly I am trying to be rather limiting in this instance and your max/min options seemed to be just the thing i needed...ie reject anything too small and shrink anything too big. The problem with imagecache, or should I say a factor that put me off using this method was that if I allow users to upload too small an image via imagecache and it stretches it then there there's a good possibility that the quality will be affected....and for this build the two images I'm trying to control user uploads on requires good quality images for it to be a success.
Just trying to cover my bases for the odd user that tries to upload 10x10 images that are supposed to be a 198x264 photos....as they say, there's always one.
Thanks for all your hard work on the module by the way :)
Cheers,
R
Comment #3
dman commentedThis ain't my module - I just saw the issue in passing.
(*and have been looking at imagecache/imagefield integration issues today)
There may be a simpler work-around for you, but I don't know what it is right now. What you ask seems logical.
Could be to do with proportions! If the image is the wrong SHAPE surely.
- upload an image that's 800x600
- resize takes it down to 198x149
- that's too small. You fail.
Any math rounding error would take you down.
Comment #4
axel pressbutton commentedAh, very good point - I'll take a look at that in the morning and post back
Comment #5
humanisticmystic commentedI had the same problem, but I found and fixed the error. Observe line 651 in filefield.module under sites/all/modules/filefield:
if ($info['width'] > $width || $info['height'] < $height) {Replace with...
if ($info['width'] < $width || $info['height'] < $height) {The "greater than" sign, next to width, must be reversed. After testing this, the module functioned as it should.
Comment #6
quicksketchNice! It's not fixed until the code is updated in ImageField, so I'm moving to patch needs review.
Comment #7
axel pressbutton commentedBrilliant, thanks for this humanisticmystic. Well spotted.
Comment #8
quicksketchLooks like the code already is up-to-date.
I'm not sure what version of FileField humanisticmystic was referring to, but this code already looks fine in the latest CVS HEAD.