Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i'm using codeigniter to build a project and right now i need to create a thumb depending on user choice. like he will give me X1,Y1,X2,Y2,X3,Y3,X4,Y4 i want to crop the image depending on that 4 points. i checked the image manipulation class. the crop function seems to be very strange. any help please ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
483 views
Welcome To Ask or Share your Answers For Others

1 Answer

You will need to set the x-axis (left), width (right), y-axis (top), and height (bottom). You need to be sure to set the width and height of the image.

        list($width, $height, $type, $attr) = getimagesize($img);

        $CI->load->library('image_lib');

        $config['image_library'] = 'gd2';
        $config['source_image'] = $img;
        $config['x_axis'] = '10';
        $config['y_axis'] = '10';
        $config['maintain_ratio'] = FALSE;
        $config['width'] = $width-10;
        $config['height'] = $height-10;

The code above will crop the image by 10 pixels on the left, right, top, and bottom. you can feel free to change the value of '10' to whichever value you prefer ;)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...