Hướng dẫn dùng polygon picture trong PHP

Tôi đã cố gắng rất nhiều để tạo khung bằng cách sử dụng một hình ảnh duy nhất thông qua php, nhưng không tìm thấy bất kỳ giải pháp nào trong php.

Với sự trợ giúp của hai câu trả lời [câu trả lời của Lucky Soni và câu trả lời của ScottS], tôi đã tạo ra một kịch bản để đáp ứng đầy đủ yêu cầu của tôi [rất cám ơn cả hai].

First I have created 4 images from single image while uploading:

$file = Input::file['image'];
$destinationPath    = 'test/';
$filename           = time[] . $file->getClientOriginalName[];
$extension          = $file->getClientOriginalExtension[];
$upload_success     = $file->move[$destinationPath, $filename];

// This will create image for upper horizontal part
$im = new imagick[public_path[].'/test/'.$filename];
$im->setImageFormat[ "jpg" ];
$topUperName = 'hr-uper-'.$filename;
$img_name = public_path[].'/20*20/'.$topUperName;
$im->resizeImage[20,20,Imagick::FILTER_LANCZOS,1];
$im->writeImage[$img_name];

// This will create image for vertical right part
$vrtRght = 'vrt-right-'.$filename;
$img_name = public_path[].'/20*20/'.$vrtRght;
$im->rotateimage['', '90'];
$im->writeImage[$img_name];

// This will create image for bottom horizontal part
$topUperBtm = 'hr-btm-'.$filename;
$img_name = public_path[].'/20*20/'.$topUperBtm;
$im->rotateimage['', '90'];
$im->writeImage[$img_name];

// This will create image for vertical left part
$vrtlft = 'vrt-left-'.$filename;
$img_name = public_path[].'/20*20/'.$vrtlft;
$im->rotateimage['', '90'];
$im->writeImage[$img_name];

$im->clear[];
$im->destroy[];

unlink[public_path[] . '/' . $filename];

HTML layout:

Chủ Đề