Skip to content
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

Images being stretched #2

Closed
medienbaecker opened this issue May 31, 2016 · 6 comments
Closed

Images being stretched #2

medienbaecker opened this issue May 31, 2016 · 6 comments

Comments

@medienbaecker
Copy link
Contributor

medienbaecker commented May 31, 2016

Some image ratios seem to be stretched.

Input images:

test1
2800 x 1300

test2
1766 x 1300

test3
1300 x 1300

test4
869 x 1300

Output images with 1440x650:

test1-1440x650-50-50
Original: 2800 x 1300

test2-1440x650-50-50
Original: 1766 x 1300

test3-1440x650-50-50
Original: 1300 x 1300

test4-1440x650-50-50
Original: 869 x 1300

Can you reproduce this with the images or is my configuration wrong?
It seems like only square input images are cropped correctly.

Maybe it has something to do with these lines, but I can't figure it out: https://github.com/flokosiol/kirby-focus/blob/master/focus.php#L88-L126

@medienbaecker
Copy link
Contributor Author

medienbaecker commented May 31, 2016

Ok, I managed to find out what's wrong with the output images. The image height is correct, it's 650px in the example, but the actual stretched height is equal to the width: 1440px. I stretched the original image in Photoshop and the circle is exactly the same.

So it seems like the script always does the "square" cropping but seems to output the correct image size. Maybe it's this line: https://github.com/flokosiol/kirby-focus/blob/master/focus.php#L29

@medienbaecker
Copy link
Contributor Author

I downloaded a pure Kirby 2.3 Starterkit, installed the focus plugin and tested it locally and on my server. Same thing:

bildschirmfoto 2016-05-31 um 16 01 54

@flokosiol
Copy link
Owner

I will have a look at this, thanks for reporting.
Did you implement the focusCrop method with one argument like this

<?php echo $image->focusCrop(200); ?>

or with two arguments like this

<?php echo $image->focusCrop(300,200); ?>

I guess I have to test some more edge cases (thumb height and/or width bigger than original, …)

@medienbaecker
Copy link
Contributor Author

medienbaecker commented May 31, 2016

I tried both. If I crop a 200x200 square by <?php echo $image->focusCrop(200); ?> there's still stretching.

Can you please test the images I uploaded in the first post in your installation? Maybe it's something else. It stretches almost every image in my installations, with almost every crop ratio. If the image doesn't contain a circle or text it's not immediately noticeable, though.

@flokosiol
Copy link
Owner

I think I found the problem, but I will do some more testing. If you can't wait for so long, you could you change this line …
https://github.com/flokosiol/kirby-focus/blob/master/focus.php#L132

$img->crop($x1, $y1, $x2, $y2)->resize($thumb->options['width'], $thumb->options['height']);

… to this …

$img->crop($x1, $y1, $x2, $y2)->thumbnail($thumb->options['width'], $thumb->options['height']);

Regards,
Flo.

@medienbaecker
Copy link
Contributor Author

Wow, thank you for the fast solution! ❤️

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

No branches or pull requests

2 participants