Comments (16)
Sorry I'm just a bit swamped right now. I have a site to ship this very afternoon, then I'll have a look 😄
from kirby-focus.
Thanks for reporting. I'll have a look at this.
from kirby-focus.
I'm sorry, but I couldn't reproduce this issue. Everything works fine for me with ImageMagick. My original image is 500x300 Pixel. It gets cropped correctly to 200x100, 100x200 and 100x100 – both with IM and GD.
Please notice that there's no upscaling at the moment. If the cropped image dimensions are larger than the original image dimensions there will be no cropping, which might lead to unexpected results.
If you want, you can post your code and I'll have a look …
Regards, Flo.
from kirby-focus.
That's right, I tested in a fresh starterkit and it indeed works as expected. The problem lies in my code it seems, sorry about the false issue!
from kirby-focus.
After more tests, I'm re-opening this issue.
I found to way to reproduce it, it happens only on multilingual sites with a config like:
c::set('languages', array(
'fr' => array(
'name' => 'Français',
'code' => 'fr',
'locale' => 'fr_FR',
'default' => true,
'url' => '/',
),
));
To reproduce on a fresh starterkit, set the site to multilingual, something like:
c::set('languages', array(
array(
'code' => 'en',
'name' => 'English',
'default' => true,
'locale' => 'en_US',
'url' => '/',
),
array(
'code' => 'de',
'name' => 'Deutsch',
'locale' => 'de_DE',
'url' => '/de',
),
));
And rename the .txt files with the correct language suffix. When the site is in english everything is fine with driver im
. If the current page is not in english when the thumbs are created, the issue I described in the first post happens.
I tried different combinations of settings: a different default language, tried German, English and French, with the same result. The only way to make it work is to browse a page in English.
So far I have no clue as to why it doesn't work in other languages.
from kirby-focus.
Alright. Thanks for figuring it out. I will have a look this though my first impression is, that this is a Kirby related bug … we'll see …
from kirby-focus.
I tested a lot with different combinations, the error might be related to localized coordinates. For EN the values are always returned as 0.5
, but for FR and DE it gets localized to 0,5
. This might be the reason. I need to check this …
But in my test cases I couldn't reproduce your error. Everything works fine with GD an IM. But there are situations which may seem to produce a wrong cropping. These are always combined with missing translated .txt
files.
For example:
- You have 3 languages for your site (en = default, de, fr)
- Your page
.txt
file is translated to en and de - You set the focus point for the de page which creates a
.de.txt
meta file for your image - There's still no meta
.txt
file for en (default) and fr - If you open the page in de the focus is correct
- If you open the page in en (default) or fr the focus is still 0.5/0.5
Reason: If there's no meta .txt
file for the current language it falls back to the default language. If this file also doesn't exist, it falls back to default. But it should always be cropped to the right dimensions, only with a different focus.
You can set translate: false
for the field to always use the values from the default language.
To sum it up
I will have a look how to transform the localized values to the correct format. Hopefully this fixes your errors 😉
from kirby-focus.
Thanks for testing!
Good find, it seems to be the issue: if I set the French config with 'locale' => 'en_EN',
it works fine with driver .im
. Of course I can't do it on the production server… but if you can enforce the use of numbers with dots that could do the trick.
The values are stored correctly with dots: Focus: {"x":0.43,"y":0.22}
even in French, but are normally converted to commas when output (echo $page->image()->focusX()
for example gives 0,36
not 0.36
).
Also, on this site the default language is French so the meta .txt file exists and is the only one, as for now the site still has only one language.
from kirby-focus.
Thanks for your feedback. Could you please check out the develop branch and test again? Since I couldn't reproduce the problem it's hard to guess, where's the right place to change the values …
from kirby-focus.
I just tried the develop branch, unfortunately it didn't solve the problem.
Also the focusX()
method still returns 0,36
but perhaps this is expected.
I tried to use the str_replace in a few other places, without success so far.
from kirby-focus.
I noticed the filename is correct, e.g myimage-350x465-80-74.jpg
. 80-74
is the focus position, so it is calculated correctly a that point, in file.php
.
from kirby-focus.
I have another idea and will test it today …
from kirby-focus.
I could reproduce the issue now and I found a solution which (at least) works for me. I pushed it to the develop branch. Would be great if you could test it again.
Thanks and regards.
from kirby-focus.
No pressure, but … any news @malvese? Would be awesome if you could have a short look at the develop branch. Merci. 😄
from kirby-focus.
And… it now works!! 🎆 I tried a few things for the sake of testing, but couldn't reproduce the bug.
Fantastic detective work @flokosiol, thank you so much 😄
from kirby-focus.
Thank you so much for testing and … of course … using 😊
from kirby-focus.
Related Issues (20)
- kirby3-colorist supports 'Focus' HOT 4
- Does not create cropped images on server HOT 5
- Update focus field on `file.replace` HOT 4
- Transparent PNG Problem HOT 1
- Does not play nice with `translate: false` HOT 1
- WebP Support HOT 12
- [Question] Is the support for Kirby Block previews planned HOT 1
- focusSrcset does not update URL on focus point changes HOT 11
- New Kirby 3.6 Feature to support multiple mime-types is not working with this plugin for GD. HOT 3
- WebP and AVIF generated images put into wrong folder in v3.0.8 HOT 26
- Kirby 3.5.x not supported in v3.0.8 HOT 7
- [Question] multiple focus fields HOT 2
- CSS not being loaded HOT 2
- Reset focuspoint HOT 1
- Optional color fading ? HOT 2
- Preview missing for svg HOT 2
- value without effect for foxi HOT 1
- avif files do not get cropped or resized HOT 1
- Migration to native Focus in Kirby v4 - regex to use HOT 8
- Correct URL to "Setting a focus point" in readme HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kirby-focus.