PHP code example of jsnlib / copy

1. Go to this page and download the library: Download jsnlib/copy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jsnlib / copy example snippets




$Urlimg = new Jsnlib\Copy\Urlimg;


//1.想要儲存的絕對路徑
$savedir            =   realpath("demo_savedir");

//2. 指定圖片網址,並COPY兩張縮小的、兩張原圖
$Urlimg
	->url("http://www.xxx.tw/upload/Ad/File_2016082620423388.JPG")
	->resize(100, 100, 1, $savedir, "s.jpg") //不指定檔名就是自動產生檔名
	->resize(100, 100, 10, $savedir, "s2.jpg")
	->org($savedir, "o.jpg")
	->copy();


//3. 檢視成果
$result = $Urlimg->result();

if ($result !== false) foreach ($result as $file)
{
	echo $file."<br>";
}