Coder Social home page Coder Social logo

smartcrop.php's People

Contributors

gakowalski avatar seltix5 avatar xymak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

smartcrop.php's Issues

analyse() returns NULL

hello,
when running this code with image of 483x600px the analyse() returns ['topCrop' => NULL] :

        $smartcrop = new xymak\image\smartcrop($file_img_resource, ['width' => 300, 'height' => 225]);
        //Analyse the image and get the optimal crop scheme
        $res = $smartcrop->analyse();

After some tests I could find out the analyse() returns this because generateCrops() returns null.
And generateCrops() returns null because $cropWidth = 301 instead of 300 and because of that it never enters the 3rd FOR.
And $cropWidth is that value because in canvasImageScale() the $this->options ['cropWidth'] is set to 301px.

What should be the best solution here?
Thanks.

Center and not left-preferences

Hello,

I realize you have not touched this in a year, but just came across it.

The resizer seems to prefer to crop to the left, instead of keeping the Content-Aware content in the center.

Here is a prime example.

This photograph should be very easy for it to detect the primary content and crop it, keeping the statue in the center of the cropped image.

https://imgur.com/rVUUJal

However, the results are such that the statue is on the left side of the image, not center, where it seems like it would be expected.

Reference: https://imgur.com/a/yPvD5

Would be nice to see an update where the content was to be in the center of a crop/resize and not left-preferenced.

php 8.1

In php 8.1 change

line 387
$x = (($x - (1 / 3) + 1.0) % 2.0 * 0.5 - 0.5) * 16;

to
$x = ((int)($x - (1 / 3) + 1.0) % 2.0 * 0.5 - 0.5) * 16;

Division by zero

Hello,
For some images i'm getting the error "Division by zero" in xymak-smartcrop/smartcrop.php:449.

example image : https://ufile.io/764g9 ( 501x376 )

$dst_w = 300;
$dst_h = 225;

$smartcrop = new \xymak\image\smartcrop($file_img_resource, ['width' => $dst_w, 'height' => $dst_h]);
$res = $smartcrop->analyse();
$smartcrop->crop($res['topCrop']['x'], $res['topCrop']['y'], $res['topCrop']['width'], $res['topCrop']['height']);
RETURN $smartcrop->get()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.