2016-08-13 9 views
0

使用由jQuery插件imgAreaSelect返回的尺寸和座標,如何更新數據庫中的圖像以反映此選擇?我在數據庫中有一個tempImage和Image字段,所以我想在tempImage中獲取圖像,讓用戶進行正方形選擇,然後將該正方形圖像上傳到Image字段。也許使用PHP?提前致謝!我有imgAreaSelect插件工作..如何使用x和y座標來更新數據庫中的圖像?

+0

u能張貼plunker? –

+0

什麼是搶劫犯?插件返回的是所選圖像的x和y座標。我怎樣才能使用這些座標來裁剪圖像? – pickletits

回答

0

從PHP手冊中的一個帖子:

<?php 
// Create a blank image and add some text 
$ini_filename = 'test.JPG'; 
$im = imagecreatefromjpeg($ini_filename); 

$ini_x_size = getimagesize($ini_filename)[0]; 
$ini_y_size = getimagesize($ini_filename)[1]; 

//the minimum of xlength and ylength to crop. 
$crop_measure = min($ini_x_size, $ini_y_size); 

// Set the content type header - in this case image/jpeg 
//header('Content-Type: image/jpeg'); 

$to_crop_array = array('x' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure); 
$thumb_im = imagecrop($im, $to_crop_array); 

imagejpeg($thumb_im, 'thumb.jpeg', 100); 
?> 
相關問題