Welcome Guest, Not a member yet? Register   Sign In
how to crop?
#1

[eluser]aryan_[/eluser]
how to re-size and crop an existing image in 125x125 dimension from center?
#2

[eluser]Krzemo[/eluser]
That should work

Code:
$cconfig['image_library'] = 'gd2';
$cconfig['source_image'] = $source_image_file_path;
$cconfig['maintain_ratio'] = FALSE;
$cconfig['width'] = 125;
$cconfig['height'] = 125;
$cconfig['new_image'] = $new_image_full_path;

//use ie getimagesize($source_image_file_path) to get orig img dims
$cconfig['x_axis'] = round(($orig_img_width - 125) / 2, 0);
$cconfig['y_axis'] = round(($orig_img_height - 125) / 2, 0);
            
$this->image_lib->initialize($cconfig);
$this->image_lib->crop();

Regs
K.
#3

[eluser]aryan_[/eluser]
How can I get width and height of an image? My images are of different sizes.
#4

[eluser]Krzemo[/eluser]
its all in my post above
#5

[eluser]aryan_[/eluser]
[quote author="Cshamoh" date="1275406591"]its all in my post above[/quote]

I mean $orig_img_width. Am I unable to find it in your code?
#6

[eluser]Krzemo[/eluser]
see the comment right above Smile
#7

[eluser]aryan_[/eluser]
[quote author="Cshamoh" date="1275437880"]see the comment right above Smile[/quote]
Oh! My mistake. Thanks a lot.
#8

[eluser]Krzemo[/eluser]
Just a thought...
If your original images are of different sizes it might be worth to crop maximum possible square and then resize it to 125x125. Thumbs will be more informative.
Let say you take original image, check what is smaller - width or height, crop a square with sides of that value and then resize it.

Have fun




Theme © iAndrew 2016 - Forum software by © MyBB