Giter Club home page Giter Club logo

Comments (16)

malvese avatar malvese commented on May 28, 2024 1

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.

flokosiol avatar flokosiol commented on May 28, 2024

Thanks for reporting. I'll have a look at this.

from kirby-focus.

flokosiol avatar flokosiol commented on May 28, 2024

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.

malvese avatar malvese commented on May 28, 2024

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.

malvese avatar malvese commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

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 .txtfiles.

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.

malvese avatar malvese commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

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.

malvese avatar malvese commented on May 28, 2024

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.

malvese avatar malvese commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

I have another idea and will test it today …

from kirby-focus.

flokosiol avatar flokosiol commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

No pressure, but … any news @malvese? Would be awesome if you could have a short look at the develop branch. Merci. 😄

from kirby-focus.

malvese avatar malvese commented on May 28, 2024

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.

flokosiol avatar flokosiol commented on May 28, 2024

Thank you so much for testing and … of course … using 😊

from kirby-focus.

Related Issues (20)

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.