JIT fit inside scaling?
This is an open discussion with 5 replies, filed under General.
Search
mistake neither should read “either”
You can do this with a little bit of logic in your template. If I understand your use case correctly, just test which dimension is larger and the scale that dimension down to 620px.
These two posts have helped me:
Discuss – Forum Thread – “JIT proportional resize”
Discuss – Forum Thread – “Getting JIT generated unknown dimension”
MrBlank, These two posts don’t help, if you want to use external images, because you don’t know width and height of external image.
Need “Fit Filter” for JIT extension…
Simple solution:
Editing /extensions/jitimagemanipulation/lib/image.php:
18. define_safe('MODE_FIT', 9); ... 71. ## Mode 9: Image fit resize elseif(preg_match_all('/^9/([0-9]+)/([0-9]+)/(?:(0|1)/)?(.+)$/i', $string, $matches, PREG_SET_ORDER)){ $param->mode = 9; $param->width = $matches[0][1]; $param->height = $matches[0][2]; $param->external = (bool)$matches[0][3]; $param->file = $matches[0][4]; } ... 234. case MODE_FIT: $src_w = $image->Meta()->width; $src_h = $image->Meta()->height; $dst_w = $param->width; $dst_h = $param->height; $src_ratio = ($src_h / $src_w); $dst_ratio = ($dst_h / $dst_w); if($src_ratio >= $dst_ratio) { $image->applyFilter('resize', array(NULL, $dst_h)); } else { $image->applyFilter('resize', array($dst_w, NULL)); } break;
Create an account or sign in to comment.
Does JIT Image Manipulation have the ability to scale both the width and height under a certain value?
For example, For the project I’m working on I need neither the height or width to be above 620px with the other dimension auto-adjusting to scale.
From what I can see JIT can only scale width or height but not both depending on whether the image is potrait or landscape.