我在本地主機上使用codeigniter 3.1。 我想裁剪圖像,但裁剪不工作。只調整工作。所以我啓用了Gd2
php擴展。Codeigniter圖像裁剪不起作用
1.
public function do_crop($filename)
{
$this->load->library('image_lib');
$source_path = 'uploads/' . $filename;
$target_path = 'uploads/thumb/'.$filename;
$config = array(
'image_library' => 'gd2',
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => FALSE,
'x_axis' => 300,
'y_axis' => 100,
);
$this->image_lib->initialize($config);
}
圖像大小= 1000X700
輸出結果是一樣的原始圖像大小1000X700
2.
public function do_crop($filename)
{
$this->load->library('image_lib');
$source_path = 'uploads/' . $filename;
$target_path = 'uploads/thumb/'.$filename;
$config = array(
'image_library' => 'gd2',
'source_image' => $source_path,
'new_image' => $target_path,
'maintain_ratio' => FALSE,
'width' => 300,
'height' => 300,
'x_axis' => 350,
'y_axis' => 50
);
$this->image_lib->initialize($config);
}
圖像大小= 1000X700
而第二示例僅調整(300x300
)中的圖像但不裁剪。
能否請你解釋更多更好地瞭解 –
你想要做什麼。 –
對於emaple如果圖像大小1000X700,那麼我想從原始圖像尺寸裁剪'300x50'。我不想調整大小。 @MuhammadUsman – Mehur