久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      如何在PHP中旋轉(zhuǎn)并保存圖像

      在PHP中旋轉(zhuǎn)并保存圖像的方法:首先使用函數(shù)【imagerotate()】用給定角度旋轉(zhuǎn)圖像;然后使用函數(shù)【imagejpeg()】輸出圖象到瀏覽器或文件,代碼為【imagejpeg ( resource $image)】。

      如何在PHP中旋轉(zhuǎn)并保存圖像

      【相關(guān)學(xué)習(xí)推薦:php編程(視頻)】

      在PHP中旋轉(zhuǎn)并保存圖像的方法:

      如果你想在PHP中上傳90度或180度旋轉(zhuǎn)圖像,那么本教程將幫助你。我們將使用imagecreatefrompng(),imagerotate()和imagepng()函數(shù)來旋轉(zhuǎn)png圖像并保存到服務(wù)器,jpeg圖像同理。

      如何在PHP中旋轉(zhuǎn)并保存圖像

      在下面的代碼示例中,我們給大家介紹在PHP中將指定圖像旋轉(zhuǎn)90度后保存,并重命名為“myUpdateImage.png”、"myUpdateImage.jpeg"的實(shí)現(xiàn)方法。

      png示例如下:

      <?php $fileName = "002.png";     $degrees = 90 ;     $source = imagecreatefrompng($fileName);     $rotate = imagerotate ($source,$degrees,0);     imagepng($rotate,"myUpdateImage.png");       print_r('圖像已成功保存。');

      jpeg示例如下:

      <?php     $fileName = "001.jpeg";     $degrees = 90;          $source = imagecreatefromjpeg($fileName);          $rotate = imagerotate($source, $degrees, 0);     imagejpeg($rotate, "myUpdateImage.jpeg");     print_r('圖像已成功保存。'); ?>

      函數(shù)介紹:

      imagecreatefrompng()函數(shù)由文件或 URL 創(chuàng)建一個(gè)新圖象。

      imagecreatefrompng ( string $filename ) : resource

      imagecreatefrompng()返回一圖像標(biāo)識(shí)符,代表了從給定的文件名取得的圖像。

      參數(shù)filename表示PNG 圖像的路徑。返回值,成功后返回圖象資源,失敗后返回 FALSE 。

      1、imagerotate()函數(shù)用給定角度旋轉(zhuǎn)圖像

      imagerotate ( resource $image , float $angle , int $bgd_color [, int $ignore_transparent = 0 ] ) : resource

      將圖像用給定的 angle 角度旋轉(zhuǎn)。bgd_color 指定了旋轉(zhuǎn)后沒有覆蓋到的部分的顏色。

      旋轉(zhuǎn)的中心是圖像的中心,旋轉(zhuǎn)后的圖像會(huì)按比例縮小以適合目標(biāo)圖像的大小——邊緣不會(huì)被剪去。

      參數(shù)image表示由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的圖象資源。

      angle,轉(zhuǎn)角度為逆時(shí)針旋轉(zhuǎn)圖像的角度數(shù)。

      bgd_color,表示指定旋轉(zhuǎn)后未覆蓋區(qū)域的顏色

      2、ignore_transparent,如果被設(shè)為非零值,則透明色會(huì)被忽略(否則會(huì)被保留)。

      返回值返回旋轉(zhuǎn)后的圖像資源, 或者在失敗時(shí)返回 FALSE。

      3、imagejpeg()函數(shù)輸出圖象到瀏覽器或文件。

      imagejpeg ( resource $image [, string $filename [, int $quality ]] ) : bool

      imagejpeg()從 image 圖像以 filename 為文件名創(chuàng)建一個(gè) JPEG 圖像。

      參數(shù)image,由圖象創(chuàng)建函數(shù)(例如imagecreatetruecolor())返回的圖象資源。

      filename,文件保存的路徑,如果未設(shè)置或?yàn)?NULL,將會(huì)直接輸出原始圖象流。如果要省略這個(gè)參數(shù)而提供 quality 參數(shù),使用NULL。

      quality為可選項(xiàng),范圍從 0(最差質(zhì)量,文件更?。┑?100(最佳質(zhì)量,文件最大)。默認(rèn)為 IJG 默認(rèn)的質(zhì)量值(大約 75)。

      返回值,成功時(shí)返回 TRUE, 或者在失敗時(shí)返回 FALSE。

      【相關(guān)學(xué)習(xí)推薦:php圖文教程】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)