image_ratio_no_zoom_in not seeming to work

See all posts Reply

image_ratio_no_zoom_in not seeming to work new!
by Rednarb, 16 years, 7 months ago
Hi, I'm having trouble with resizing. I want to make sure uploaded images do not exceed 600px wide, but I don't want to convert smaller images to 600px.

I tried image_ratio_no_zoom_in = true but it doesn't seem to be working, I still end up with a 600px image if its smaller. Here's the relevant (I think) portion of the code:

if ($handle->uploaded) {
$handle->file_safe_name          = true;
$handle->image_resize            = true;
$handle->image_ratio_no_zoom_in  = true;
$handle->image_ratio_y           = true;
$handle->image_x                 = 600;
$handle->jpeg_quality            = 100;
$handle->image_convert           = 'jpg';
$handle->file_overwrite          = false;
$handle->file_auto_rename        = false;
$handle->file_new_name_body      = $new_file_name_body;
$handle->Process($upload_directory);
Reply
Re: image_ratio_no_zoom_in not seeming to work new!
by colin, 16 years, 7 months ago
You can use only one of the image_ratio_* setting at the same time.

You should do the following:
$handle->image_ratio_no_zoom_in  = true;
$handle->image_y                 = 800;
$handle->image_x                 = 600;
Reply
Re: image_ratio_no_zoom_in not seeming to work new!
by Rednarb, 16 years, 7 months ago
Thank you. It worked great!Reply
Re: image_ratio_no_zoom_in not seeming to work new!
by Eric Poh, 12 years, 11 months ago
Your Class is short of complete because of the following reasons

1) cant upload animated gifs

2) Sizing concerns when it cannot get the width and height prior to processing...

Many users like resizing their uploads where they constrain by either X or Y axis then apply the x or y image_ratio_ <- this logic is flawed.

Now here is the BIG@#$ problem:

Assume users would occasionally upload a portrait and occasionally a landscape image.

Dilemma: if he sets the x to fixed value and leave y auto ratio,
THEN the user will have problems when he uploads a portrait oriented image because all the portraits will appear significantly larger than the landscapes

Example A: Original file X=800 Y=600 (Landscape)
Constrain X to 400, Y to auto
Uploads and processed to X=400 Y=auto (which is 300)
Total pixels = 400X300=120,000

Example B: Original file X=600 Y=800 (Portrait)
Constrain X to 400, Y to auto (Same rule as above)
Uploads and processed to X=400 Y=auto (which is 534)
Total pixels = 400X534=213,600!!!!!

BUT then we have image_ratio_pixels right?
just set -> image_ratio_pixels=120000 problem solved?

Wrong then comes the problem when we have images that are smaller and we do now wish to scale due to loss of image quality, so u say just use -> image_ratio_no_zoom_in

BUT then you say "You can use only one of the image_ratio_* setting at the same time. "
$handle->image_ratio_no_zoom_in  = true;
$handle->image_y                 = 800;
$handle->image_x                 = 600;

Then we are just back to SQUARE ONE!Reply
Re: image_ratio_no_zoom_in not seeming to work new!
by colin, 12 years, 11 months ago
Animated GIFs would require a complete rewrite of the class, as previously stated in the forum.

It is true that image_ratio_no_zoom_in and image_ratio_no_zoom_out are a problem since they cannot be used with other image_ratio_* settings. This will be fixed in a future version.

For the rest, I disagree. You can set image_x, image_y and image_ratio to constraint your image in set dimensions. Or you can use image_ratio_fill or image_ratio_crop to fit perfectly in these dimensions.

But also, before calling process(), you can can read image_src_x and image_src_y to accordingly set your settings. Basically, you can do your own logic before calling process, rather than having the class trying to work some magic which would likely not fit with everybody.

Does it answer your points?Reply
Re: image_ratio_no_zoom_in not seeming to work new!
by Eric Poh, 12 years, 11 months ago
when u said image_scr_x and i looked up i found image_src_pixels which is even better.... now it works perfectly, i can determine if the uploaded file was bigger than the system constrain or not. if it is, use the constrain if not, use the original size. perfect, now all it needs is the ability to upload animated gifs.

next time just say so! image_src_pixels is the answer to many or our problems duh!Reply