CodeIgniter Forums
Why is image cropping so hard? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Why is image cropping so hard? (/showthread.php?tid=34618)



Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]nuwanda[/eluser]
I've been using the CI image lib. No worries resizing, it's just fine.

But cropping? I just can't make it work.

Code:
$config['x_axis'] = 100;
$config['y_axis'] = 100;
$config['width'] = 100;
$config['height'] = 100;

Now, that code should reference a block 100 x 100, starting 100 in from the left (x) and 100 down from the top (y).

Right?

But no, I get an image that varies depending on the source image. One dimension is correct, but the other appears to vary depending on the source.

I'd kill for a simple example of a crop operation.


Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]richthegeek[/eluser]
Try just not bothering with the CI image lib...

PHP GD's imagecopyresized/imagecopyresampled is very easy to implement.


Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]nuwanda[/eluser]
[quote author="richthegeek" date="1286279654"]Try just not bothering with the CI image lib...

PHP GD's imagecopyresized/imagecopyresampled is very easy to implement.[/quote]

Sure, but it's kinda weird that it doesn't perform as expected.


Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]Krzemo[/eluser]
set aspect_ratio setting to false Smile


Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]Mat-Moo[/eluser]
Try out my image_moo library, got easy crop built in Smile


Why is image cropping so hard? - El Forum - 10-05-2010

[eluser]nuwanda[/eluser]
[quote author="Cshamoh" date="1286294850"]set aspect_ratio setting to false Smile[/quote]

Well, works perfectly now!

The $config['maintain_ratio'] defaults to true, so it must be set.

Thanks!


Why is image cropping so hard? - El Forum - 10-06-2010

[eluser]fedeisas[/eluser]
I've always dreamed of building a CI library to use this: http://odyniec.net/projects/imgareaselect/. It's the only real solution for handling dummy users.


Why is image cropping so hard? - El Forum - 10-06-2010

[eluser]Buso[/eluser]
[quote author="fedeisas" date="1286363712"]I've always dreamed of building a CI library to use this: http://odyniec.net/projects/imgareaselect/. It's the only real solution for handling dummy users.[/quote]
o.o nice finding


Why is image cropping so hard? - El Forum - 10-06-2010

[eluser]nuwanda[/eluser]
[quote author="fedeisas" date="1286363712"]I've always dreamed of building a CI library to use this: http://odyniec.net/projects/imgareaselect/. It's the only real solution for handling dummy users.[/quote]

Yeah, I used the great little Jcrop script for that. Great addition for users.