matt-pawley / oc-imageresizer-plugin

October CMS Plugin to resize and compress images
https://octobercms.com/plugin/toughdeveloper-imageresizer
MIT License
46 stars 39 forks source link

Max width or max height for images #19

Open ghost opened 7 years ago

ghost commented 7 years ago

Hello,

I need to resize image that way :

I tested all provided modes but can't find a way to do that. I exclude "exact" and "crop" mode because of the third point, so there is "auto", "portrait" and "landscape"

The problem with landscape/portrait mode is that they resize picture just by looking the width/height value. So I can have picture of 2000x100px or 180x2000px.

I don't find any mode that can do what I need, could you please point me the right direction if a solution actually exist ?

here is my code :

image.jpg|media|resize(180, 100, { mode: '???' })
matt-pawley commented 7 years ago

Hey,

I would possibly use CSS to solve this, something along the lines of:

.image {
    height: 100px;
    width: 180px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center center;
}
<div class="image" style="background-image: url('{{ 'image.jpg' | media | resize(180, false, { mode: 'auto' }) }}');"></div>
ghost commented 7 years ago

Hello,

Thank you for the answer.

Yes I have no problem to solve this using CSS.

The problem with CSS solution is that it load a bigger image and then, resize it. This is a bad practice that is penalized by tools like dareboost for example.

That's why I need a "pre-processing" solution. I think an additionnal mode to do that could be added to the plugin (will try to investigate, but I have no experience at all with git so I'm not sure to be able to make a pull request) as it's a quite common feature when you deal with something like logo list that can have very different formats and can't be cropped.

vdomah commented 7 years ago

Hi! Looking for exactly the same feature. Is there any progress in this question? I can make a contribution in coding the solution if there is no progress yet.

matt-pawley commented 7 years ago

@vdomah - Sorry, no progress from my end. I'm just in the process of moving house and without internet for a while so unlikely to be progressed any time soon. Feel free to submit a PR if you have the time.

yapsr commented 6 years ago

+1 This probably needs an update of the Resizer.php file of the octobercms/library. I have created a pull request in that project: https://github.com/octobercms/library/pull/334

matteotrubini commented 4 years ago

This plugin is being migrated to core (see #55), so we are trying to figure out what issues are still relevant to invite to reopen them in core.

Issues that will remain inactive in next 30 days will be closed.