$output = curl_exec($ch); curl_close($ch); return $output; } public function copyIMGS() { $images = array(); $images[] = 'https://pp.vk.me/c410118/v410118197/7533/w1sahwpcIGQ.jpg'; $images[] = 'https://pp.vk.me/c624029/v624029197/5d22/aFqYSgFiYyI.jpg'; foreach ($images as $key => $value) { $content = $this->url_get_contents($value); file_put_contents('tmp/images/array[' . $key . '].jpg', $content); } } public function getAllImages() { $directory = "tmp/images/"; $images = glob($directory . "*.jpg"); return $images; } } $imageGrid = new imageGrid(800, 600, 10, 10); $imageGrid->demoGrid(); $images = $imageGrid->getAllImages(); foreach ($images as $key => $image) { $img = imagecreatefromjpeg($image); $imageGrid->putImage($img, 1, 1, 2, 5); } $imageGrid->display(); $imageGrid->copyIMGS(); $imageGrid->getAllImages();
function createCollage($image1, $image2, $image3, $image4, $imageName) { $imageGrid = new imageGrid(800, 400, 12, 2); // //$image1 = convertImage($image1,"image1"); //dd($image1); //$image2 = convertImage($image2,"image2"); //$image3 = convertImage($image3,"image3"); //$image4 = convertImage($image4,"image4"); $blue = imagecreatefrompng($image1); $imageGrid->putImage($blue, 6, 2, 0, 0); imagedestroy($blue); $green = imagecreatefrompng($image2); $imageGrid->putImage($green, 2, 1, 6, 0); imagedestroy($green); //$red = imagecreatefrompng($image3); //$imageGrid->putImage($red, 2, 1, 8, 0); //imagedestroy($red); // //$yellow = imagecreatefrompng($image4); //$imageGrid->putImage($yellow, 2, 1, 10, 0); //imagedestroy($yellow); // $purple = imagecreatefrompng($image3); $imageGrid->putImage($purple, 3, 1, 6, 1); imagedestroy($purple); // $cyan = imagecreatefrompng($image4); $imageGrid->putImage($cyan, 3, 1, 9, 1); imagedestroy($cyan); //$imageGrid->display(); //move(base_path() . '/public/images/', $imageName); if (imagepng($imageGrid->image(), base_path() . '/public/images/' . $imageName)) { return true; } else { return false; } }