PHP實現圖片旋轉效果執行個體代碼,_PHP教程

來源:互聯網
上載者:User

PHP實現圖片旋轉效果執行個體代碼,


PHP對映像的旋轉

    

旋轉之前

<?php header("content-type","text/html;charset=utf-8"); /* *圖片沿y軸旋轉,以png格式為例 *@param string $filename 圖片的url */ function turn_y($filename) { /*建立圖片資源*/ $backy = imagecreatefrompng($filename); /*擷取大小*/ $widthy = imagesx($backy); $heighty = imagesy($backy); /*建立新的圖片資源,儲存翻轉後的圖片*/ $newy = imagecreatetruecolor($widthy, $heighty); /*沿著y軸翻轉,就是將原圖從右向左按一個像素寬度向新資源中逐個複製*/ for ($i=0; $i < $widthy; $i++) { imagecopy($newy,$backy,$widthy-$i-1,0,$i,0,1,$heighty); } /*儲存翻轉後的圖片*/ imagepng($newy,'test3.png'); /*釋放資源*/ imagedestroy($backy); imagedestroy($newy); } /* *圖片沿x軸旋轉,以png格式為例 *@param string $filename 圖片的url */ function turn_x($filename) { /*建立圖片資源*/ $backx = imagecreatefrompng($filename); /*擷取大小*/ $widthx = imagesx($backx); $heightx = imagesy($backx); /*建立新的圖片資源,儲存翻轉後的圖片*/ $newx = imagecreatetruecolor($widthx, $heightx); /*沿著x軸翻轉,就是將原圖從上到下按一個像素寬度向新資源中逐個複製*/ for ($i=0; $i < $heightx; $i++) { imagecopy($newx,$backx,0,$heightx-$i-1,0,$i,$widthx,1); } /*儲存翻轉後的圖片*/ imagepng($newx,'test4.png'); /*釋放資源*/ imagedestroy($backx); imagedestroy($newx); } /*調用函數*/ turn_y('1.png'); turn_x('1.png'); ?>

沿著y軸旋轉

沿著x軸旋轉




http://www.bkjia.com/PHPjc/887747.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/887747.htmlTechArticlePHP實現圖片旋轉效果執行個體代碼, PHP對映像的旋轉 div h4旋轉之前/h4 img src="1.png" style="border:1px solid red;" /div php header("content-type","text/html;chars...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.