Jump to content

Refuse MINIUM image by size, bug?


John W.
 Share

Recommended Posts

Running PW 2.7.2

I've built several sites using PW. One question that I have is is there a module, or planned upgrade in the core to refuse (fix) uploaded images that don't meet the Min width or Min height? In the description PW says "Optionally enter the minimum width and/or height .. images that don't meet these minimums will be refused."

(the field /image upload is required)

example:

Currently, if I set Max width to 320, Max height to 260 and leave "refuse images exceeding max dimensions?" unchecked. This is fine, if they upload a 1024x768, I'll let PW scale/crop it down to 320x260.

In the next section I set Min width/height for uploaded images to 320x260. 

however, when a user uploads a 800x200 image, for example, PW won't refuse it. PW will just scale the image to 320x200 (for example)...when the minimum is set to 320x260.

Something, with the settings enabled above, just seems to be off.  Maybe PW (in the PHP core) is not checking the dimensions of the dimensions after the user uploads it and PW scales/crops it? 

 

Link to comment
Share on other sites

1 hour ago, holmescreek said:

however, when a user uploads a 800x200 image, for example, PW won't refuse it.

I don't think this is quite right. If the image you are uploading is 200px high and the minimum height for the field is 260px then PW will refuse it, regardless of what is set for max width/height. So that part is okay.

The problem happens when you set a max width/height and the image you upload is larger than both the max width/height and the min width/height. What happens here is that PW resizes the image to so it is contained by the max width/height while maintaining the image aspect ratio. And depending on the aspect ratio this can result in a resized image where one dimension (width or height) is smaller than the min width/height. So in the example you give...

1 hour ago, holmescreek said:

Currently, if I set Max width to 320, Max height to 260 and leave "refuse images exceeding max dimensions?" unchecked. This is fine, if they upload a 1024x768, I'll let PW scale/crop it down to 320x260.

...PW will actually scale a 1024x768 image down to 320x240, not 320x260.

PW doesn't refuse the image because it was larger than the min width/height on upload, but it doesn't check if the resized image will be smaller than the min width/height limits. Arguably this should be checked, but if if what you want is an image cropped to exact dimensions you can just leave the max width/height empty (or some large maximum to avoid overly massive files - I often set max width to 1600px) and crop to your dimensions in your API calls:

$image->size(320,260)

 

  • Like 1
Link to comment
Share on other sites

On 7/28/2016 at 9:51 PM, Robin S said:

I don't think this is quite right. If the image you are uploading is 200px high and the minimum height for the field is 260px then PW will refuse it, regardless of what is set for max width/height. So that part is okay.


$image->size(320,260)

 

Thanks. I've used image->size on other sites. Problem is client has uploaded some 320x260 ... if they go back and edit now, it will refuse the image already uploaded. Guess they will just have to replace the image with a larger version if they have to go back and edit an article in the future.

thanks,

 

Link to comment
Share on other sites

5 hours ago, holmescreek said:

Problem is client has uploaded some 320x260 ... if they go back and edit now, it will refuse the image already uploaded.

I don't follow you here. If min width/height is 320/260 and max width/height is 1600/1600 (or empty) then a 320x260 image can be uploaded. The image must be smaller than the minimum to be refused - equal to the minimum is accepted.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...