-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
analyse() returns NULL #2
Comments
In my own testing of this, which, btw, I have been able to duplicate in the past, analyse() returning null, as you put it, seems to be a result of it not being able to generate any legit 'smart crops' (ie: recommendations). An easy way to validate that is to place this code (should not be used in production, just using it to show you... some type of try/catch/error should be used in your production code) within the 'function analyse' after the line: $crops = $this->generateCrops();
There is clearly something happening inside of generateCrops() that is causing this error, I just have not spent the time to debug it fully. But, at least doing the above could help you put into place some error checking/reporting to keep things from going wonkers on you until @xymak gets around to fixing this. |
I dont think the problem is inside generateCrops(), I think the problem is in canvasImageScale() because of rounding.
to:
but I dont know if this change in rounding will cause any problem elsewhere... |
@seltix5 - I can confirm that the change you noted did resolve the issue on my end as well. Previously, this image, at 960x720, would fail, but the same image, only slightly smaller, at 600x450, would work. With the change from ceil() to floor() now they both work. It is just a matter of rounding up, versus rounding down, and my guess is that in this type of a situation, it is probably not going to matter much. The score() does not seem to be affected much, in my testing over the last few minutes of different images, using both methods. Pretty much identical outputs using both. |
hello,
when running this code with image of 483x600px the analyse() returns ['topCrop' => NULL] :
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.
The text was updated successfully, but these errors were encountered: