zoukankan      html  css  js  c++  java
  • 分割png图片

    /***
    * 分割图片
    */
    public function cut_img(){
    $filename = 'site_upload/form_file_forinput/20180313/20180313191121824939294.png';
    $p = 3;
    // Get new sizes
    list($width, $height) = getimagesize($filename);
    $newwidth = $width;
    $newheight = floor($height / $p);
    $last = $height % $p;
    // Load
    $source = imagecreatefrompng($filename);
    for( $i=0 ; $i< $p; $i++ ){

    $_p = $newheight*$i;
    if(( $i + 1 ) == $p)
    $newheight += $last;
    $thumb = ImageCreateTrueColor($newwidth, $newheight);
    imagecopyresized( $thumb, $source, 0, 0, 0, $_p, $newwidth, $height, $width, $height);
    header('Content-type: image/png');
    imagepng( $thumb , "site_upload/form_file_forinput/20180313/t{$i}.png" );
    imagedestroy($thumb);
    }

    echo 'end';exit;
    }
  • 相关阅读:
    ElementUi
    Vue插件
    Vue-cli
    Vue进阶
    Vue组件
    Vue生命期钩子
    Vue基础
    Vue介绍
    logging模块
    time模块
  • 原文地址:https://www.cnblogs.com/pansidong/p/8625166.html
Copyright © 2011-2022 走看看