开发者

jquerycropping,CodeIgniter,php

开发者 https://www.devze.com 2022-12-30 21:47 出处:网络
I want to crop the image using jQuery, CodeIgniter In jquery I get four coordinateof ima开发者_如何学Pythonge x1=249 x2=326 y1=194 y2=271 w=77 h=77

I want to crop the image using jQuery, CodeIgniter

In jquery I get four coordinate of ima开发者_如何学Pythonge x1=249 x2=326 y1=194 y2=271 w=77 h=77

In CodeIgniter done the query

function do_crop()
{

    $x=249; 
    $y=194; 
    $w=77; 
    $h=77; 
    $path= 'system/application/';   
    $config = array(
        'image_library' => 'gd2',
        'source_image' => $path.'/jag1/flowers.jpg' , 
        'new_image' => $path.'/jag2/flowers.jpg',
        'maintain_ration' => false, 
        'width' => $w,
        'height' => $h,
        'x_axis' => $x,
        'y_axis' => $y
    );

    $this->load->library('image_lib');
    $this->image_lib->initialize($config);
    if ( ! $this->image_lib->crop())
    {
        echo $this->image_lib->display_errors();
    }       
    $this->image_lib->clear();
}

I get cropped image. But problem is don't get exact cropped image x,y coordinate problem

Please correct the coordinate


Use .offset() to get the exacty x/y of your image.

The x1 is most likely the x1 of the mouse on the screen - so in this case 249 needs to be reduced by the x of the image you're selecting.

Reduce the X values by the image's .offset().left and the y values by .offset().top and then send to php.

0

精彩评论

暂无评论...
验证码 换一张
取 消