사용자가 집의 큰 사진을 업로드하고 슬라이드 쇼에 맞게 잘 자르도록하고 싶습니다. 그래서 나는 사용자가 커다란 홈 사진을 업로드 할 때 그 사진을 저장하고 복사 한 다음 새 사본의 크기를보다 관리하기 쉬운 크기로 재조정하도록 설정했다. (예 : 5000x3333px 이미지를 600x400px로 크기 조정) 그런 다음이 새 이미지가 사용자에게 표시되어 이미지를자를 수 있습니다. 이미지가 잘린 후 x, y, w 및 h 값이 반환됩니다. 이 값은 작은 이미지의 잘린 영역의 값이지만, 이제는 작은 이미지가 아닌 원본 이미지를 자릅니다. 즉, w & h를 늘려야하고 x & y가 정확한 위치에 있어야하지만이 부분이 너무 혼란 스럽습니다. w & h를 올바르게 확장하고 작은 이미지에서 원래의 큰 이미지로 자르기와 일치하도록 x &을 올바른 위치에 유지하려면 어떻게해야합니까?큰 이미지를 잘 자르고 자르기 더 쉽게
다음은 작물의 최종 기능 코드입니다. 이것은 내 수제 기능 중 일부를 사용하고 있으며, 편의를 위해 존재한다는 것을 이해합니다.
//User inputs from the crop area on the small image
$user_input_x = $_POST['x'];
$user_input_y = $_POST['y'];
$user_input_w = $_POST['w'];
$user_input_h = $_POST['h'];
//Grab original, small, and final image locations
$original_image_src = '/tmp/original_image';
$small_image_src = '/tmp/small_image';
$final_image_location = '/final/image';
//Return the extension for both the original and small image
if(($image_ext = imageCheck($original_image_src)) === false) die('Could not find original image source!');
$original_image_src .= $image_ext;
$small_image_src .= $image_ext;
$final_image_location .= $image_ext;
//Get the width and height of both the original and small image
list($original_image_width, $original_image_height) = getimagesize($original_image_src);
list($small_image_width, $small_image_height) = getimagesize($small_image_src);
//Converts string location of image into php resource
//This function helps determine the type of image and create the resource
$src_image = createImage($original_image_src);
//This is the area where I am having trouble
//I need to scale up the users input x,y,w,h because they are from small image and need to match to original
//These are the vars to go into all the final fields
$src_x = $user_input_x;
$src_y = $user_input_y;
$src_w = 0;
$src_h = 0;
$crop_x = 0;
$crop_y = 0;
$crop_w = 0;
$crop_h = 0;
$final_image = imagecreatetruecolor($crop_w, $crop_h);
if(!imagecopyresampled($final_image, $src_image, $crop_x, $crop_y, $src_x, $src_y, $crop_w, $crop_h, $src_w, $src_h)) die('Could not resmaple image!');
//Saves image to final location retains the extension and destroys the resource
if(imageSave($final_image, $final_image_location, $image_ext) === false) die('Count not save image!');
아, 그리고 그것이 어떤 도움 경우,이 작물은 거의 & 시간 승의 X, Y를 제공 jCrop에 의해 수행되고있다.
너무 바보 같아서 뇌가 방구합니다. 이것은 제가 필요로하는 간단한 수학이었습니다, 감사합니다. –