Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Crop dimensions not exact #15

Open
Toutouwai opened this issue Dec 6, 2012 · 3 comments
Open

Crop dimensions not exact #15

Toutouwai opened this issue Dec 6, 2012 · 3 comments

Comments

@Toutouwai
Copy link

When attempting to resize and crop to exact dimensions, some dimensions/ratios result in an imperfect crop.

For instance, /slir/w960-h350-c960x350/path/to/image.jpg results in an image that is 960 x 349 pixels. Is there a way to achieve an exact crop to the specified dimensions?

@noneym
Copy link

noneym commented Apr 29, 2014

+yes i need same think

@mkraha
Copy link

mkraha commented Dec 21, 2016

Set image sizes as same crop sizes.

@zamus1
Copy link

zamus1 commented Mar 3, 2017

I had a similar issue...

I made a provisional patch in order to fix my scenario...

On the slir.class.php

I have replaced the line 950 on the else of resizeCroppedHeightFactor:

return $this->getRequest()->height / $this->getSource()->getCropHeight(); // Original Line of code

With this preliminar code (i don't recommend using this in production):

  # Do the standard calculation using Height to determine factor
  $factor = $this->getRequest()->height / $this->getSource()->getCropHeight();
  
  # Then i try to calulate the final size of the picture with the original factor
  $newHeigth=round($factor * $this->getSource()->getCropWidth());

  # If the new size is different that i have set on the request i do the calculation using Width instead
  if($newHeigth!=$this->getRequest()->height){
    $newFactor = $this->getRequest()->width / $this->getSource()->getCropWidth();
    $factor = $newFactor;
  }
  
  return  $factor;

This code may break other things.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants