当前位置: 首页>>代码示例>>PHP>>正文


PHP gcms::cropImage方法代码示例

本文整理汇总了PHP中gcms::cropImage方法的典型用法代码示例。如果您正苦于以下问题:PHP gcms::cropImage方法的具体用法?PHP gcms::cropImage怎么用?PHP gcms::cropImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gcms的用法示例。


在下文中一共展示了gcms::cropImage方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: elseif

         } elseif (!gcms::testDir(DATA_PATH . "gallery/{$index['id']}/")) {
             $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
             $input = 'gallery_pic';
             $error = 'DO_NOT_UPLOAD';
         } else {
             // อัปโหลดรูปภาพจริง
             $res = gcms::resizeImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/", "0.{$info['ext']}", $info, $config['gallery_image_w']);
             if (!$res) {
                 $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
                 $input = 'gallery_pic';
                 $error = 'DO_NOT_UPLOAD';
             } else {
                 $save2['image'] = $res['name'];
             }
             // อัปโหลด thumbnail
             if (!gcms::cropImage($file['tmp_name'], DATA_PATH . "gallery/{$index['id']}/thumb_{$save2['image']}", $info, $config['gallery_thumb_w'], $config['gallery_thumb_h'])) {
                 $ret['ret_gallery_pic'] = 'DO_NOT_UPLOAD';
                 $input = 'gallery_pic';
                 $error = 'DO_NOT_UPLOAD';
             }
             // ลบไฟล์เดิม
             if (!empty($index['image']) && $save2['image'] != $index['image']) {
                 @unlink(DATA_PATH . "gallery/{$index['id']}/{$index['image']}");
                 @unlink(DATA_PATH . "gallery/{$index['id']}/thumb_{$index['image']}");
             }
         }
     }
 }
 if (!$error) {
     // save
     $save['last_update'] = $mmktime;
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_write_save.php

示例2: rawurlencode

     $ret['ret_write_picture'] = 'REQUIRE_PICTURE';
     $ret['error'] = 'REQUIRE_PICTURE';
     $ret['input'] = 'write_picture';
 } else {
     // อัปโหลดรูปภาw
     if ($icon['tmp_name'] != '') {
         // ตรวจสอบไฟล์อัปโหลด
         $info = gcms::isValidImage(array('jpg', 'gif', 'png'), $icon);
         if (!$info) {
             $ret['ret_write_picture'] = 'INVALID_FILE_TYPE';
             $input = 'write_picture';
             $error = 'INVALID_FILE_TYPE';
         } else {
             $save['picture'] = $index[0]['id'] . '.jpg';
             // อัปโหลด
             if (!gcms::cropImage($icon['tmp_name'], DATA_PATH . "personnel/{$save['picture']}", $info, $config['personnel_image_w'], $config['personnel_image_h'])) {
                 $ret['ret_write_picture'] = 'DO_NOT_UPLOAD';
                 $input = 'write_picture';
                 $error = 'DO_NOT_UPLOAD';
             } else {
                 $ret['imgIcon'] = rawurlencode(DATA_URL . "personnel/{$save['picture']}?{$mmktime}");
             }
             // ลบไฟล์เดิม
             if ($save['picture'] != $index[0]['picture']) {
                 @unlink(DATA_PATH . 'personnel/' . $index[0]['picture']);
             }
         }
     }
     if (!$error) {
         if ($id == 0) {
             // ใหม่
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_write_save.php

示例3: while

             if (!$info) {
                 $ret['error'] = 'INVALID_FILE_TYPE';
             } else {
                 while (is_file($dir . "{$save['count']}.{$info['ext']}")) {
                     $save['count']++;
                 }
                 $save['image'] = "{$save['count']}.{$info['ext']}";
                 // อัปโหลดรูปภาพจริง
                 $res = gcms::resizeImage($file['tmp_name'], $dir, $save['image'], $info, $config['gallery_image_w']);
                 if (!$res) {
                     $ret['error'] = 'DO_NOT_UPLOAD';
                 } else {
                     $save['image'] = $res['name'];
                 }
                 // อัปโหลด thumbnail
                 if (!gcms::cropImage($file['tmp_name'], $dir . "thumb_{$save['image']}", $info, $config['gallery_thumb_w'], $config['gallery_thumb_h'])) {
                     $ret['error'] = 'DO_NOT_UPLOAD';
                 } else {
                     // บันทึกลง db
                     $db->add(DB_GALLERY, $save);
                 }
             }
         }
         // อัปเดทจำนวนรูปภาพในอัลบัม
         $sql1 = "SELECT COUNT(*) FROM `" . DB_GALLERY . "` WHERE `album_id`=C.`id` AND `module_id`='{$index['module_id']}'";
         $sql = "UPDATE `" . DB_GALLERY_ALBUM . "` AS C SET C.`count`=({$sql1}) WHERE C.`id`='{$index['id']}' AND C.`module_id`='{$index['module_id']}'";
         $db->query($sql);
     } else {
         $ret['error'] = 'ACTION_ERROR';
     }
 }
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_upload_save.php

示例4: foreach

 // อัปโหลด
 foreach ($_FILES as $key => $file) {
     if (!$error && $file['tmp_name'] != '') {
         // ตรวจสอบไฟล์อัปโหลด
         $info = gcms::isValidImage($img_typies, $file);
         if (!$info) {
             // ชนิดไฟล์อัปโหลด
             $ret["ret_{$key}"] = 'INVALID_FILE_TYPE';
             $input = !$input ? $key : $input;
             $error = !$error ? 'INVALID_FILE_TYPE' : $error;
         } else {
             $ret["ret_{$key}"] = '';
             // อัปโหลด
             $k = str_replace('write_', '', $key);
             $save[$k] = "{$k}-{$index['module_id']}-{$index['id']}.{$info['ext']}";
             if (!gcms::cropImage($file['tmp_name'], "{$dir}/{$save[$k]}", $info, $index['icon_width'], $index['icon_height'])) {
                 $ret["ret_{$key}"] = 'DO_NOT_UPLOAD';
                 $input = !$error ? $key : $input;
                 $error = !$error ? 'DO_NOT_UPLOAD' : $error;
             } else {
                 $ret["ret_{$key}"] = '';
                 $save[$k . 'W'] = $index['icon_width'];
                 $save[$k . 'H'] = $index['icon_height'];
                 // ลบรูปภาพเดิม
                 if (isset($index[$k]) && $index[$k] != $save[$k]) {
                     @unlink(DATA_PATH . "document/{$index[$k]}");
                 }
             }
         }
     }
 }
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_write_save.php

示例5: rawurlencode

     } else {
         if ($user['icon'] != '') {
             @unlink(USERICON_FULLPATH . $user['icon']);
         }
         // สร้างรูป thumbnail
         if ($info['width'] == $config['user_icon_w'] && $info['height'] == $config['user_icon_h']) {
             $save['icon'] = "{$user['id']}.{$info['ext']}";
             if (!@move_uploaded_file($register_usericon['tmp_name'], USERICON_FULLPATH . $save['icon'])) {
                 $ret['ret_register_usericon'] = 'DO_NOT_UPLOAD';
                 $input = !$input ? 'register_usericon' : $input;
                 $error = !$error ? 'DO_NOT_UPLOAD' : $error;
             }
         } else {
             // ปรับภาพตามขนาดที่กำหนด
             $save['icon'] = "{$user['id']}.jpg";
             if (!gcms::cropImage($register_usericon['tmp_name'], USERICON_FULLPATH . $save['icon'], $info, $config['user_icon_w'], $config['user_icon_h'])) {
                 $ret['ret_register_usericon'] = 'DO_NOT_UPLOAD';
                 $input = !$input ? 'register_usericon' : $input;
                 $error = !$error ? 'DO_NOT_UPLOAD' : $error;
             }
         }
         if (!$error) {
             // คืนค่า url ของรูปใหม่
             $ret['imgIcon'] = rawurlencode(WEB_URL . '/modules/member/usericon.php?w=70&id=' . $user['id'] . '&' . $mmktime);
             $ret['ret_register_usericon'] = '';
         }
     }
 }
 if (!$error) {
     if (!$isAdmin) {
         // ไม่ใช่แอดมิน ห้ามแก้ไข email,status,point
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:updateprofile.php

示例6: rawurlencode

     } else {
         // ชื่อไฟล์ใหม่
         $icon = DATA_FOLDER . "document/default-{$index['id']}";
         if ($info['width'] <= $icon_width && $info['height'] <= $icon_height) {
             // รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
             if (!@move_uploaded_file($default_icon['tmp_name'], ROOT_PATH . "{$icon}.{$info['ext']}")) {
                 $ret['error'] = 'DO_NOT_UPLOAD';
                 $ret['input'] = 'config_default_icon';
                 $ret['ret_config_default_icon'] = 'DO_NOT_UPLOAD';
             } else {
                 $cfg[] = "icon_w={$info['width']}";
                 $cfg[] = "icon_h={$info['height']}";
                 $cfg[] = "default_icon={$icon}.{$info['ext']}";
                 $ret['img_default_icon'] = rawurlencode(WEB_URL . "/{$icon}.{$info['ext']}?{$mmktime}");
             }
         } elseif (!gcms::cropImage($default_icon['tmp_name'], ROOT_PATH . "{$icon}.jpg", $info, $icon_width, $icon_height)) {
             $ret['error'] = 'DO_NOT_UPLOAD';
             $ret['input'] = 'config_default_icon';
             $ret['ret_config_default_icon'] = 'DO_NOT_UPLOAD';
         } else {
             $cfg[] = "icon_w={$icon_width}";
             $cfg[] = "icon_h={$icon_height}";
             $cfg[] = "default_icon={$icon}.jpg";
             $ret['img_default_icon'] = rawurlencode(WEB_URL . "/{$icon}.jpg?{$mmktime}");
             $ret['ret_config_default_icon'] = '';
         }
     }
 } else {
     // อ่านไอคอนเดิมมาใช้แทน
     $cfg[] = "icon_w={$index['icon_w']}";
     $cfg[] = "icon_h={$index['icon_h']}";
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_config_save.php

示例7: elseif

         $ret['ret_download_thumbnail'] = 'INVALID_FILE_TYPE';
         $error = true;
     } else {
         $thumb = "thumb-{$last_id}";
         if ($info['width'] <= $config['download_thumb_width'] && $info['height'] <= $config['download_thumb_width']) {
             // รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
             if (!@copy($thumbnail['tmp_name'], DATA_PATH . "download/{$thumb}.{$info['ext']}")) {
                 $ret['error'] = 'DO_NOT_UPLOAD';
                 $ret['ret_download_thumbnail'] = 'DO_NOT_UPLOAD';
                 $error = true;
             } else {
                 $save['thumb'] = "{$thumb}.{$info['ext']}";
                 $save['thumb_w'] = $info['width'];
                 $save['thumb_h'] = $info['height'];
             }
         } elseif (!gcms::cropImage($thumbnail['tmp_name'], DATA_PATH . "download/{$thumb}.jpg", $info, $config['download_thumb_width'], $config['download_thumb_width'])) {
             $ret['error'] = 'DO_NOT_UPLOAD';
             $error = true;
         } else {
             $save['thumb'] = "{$thumb}.jpg";
             $save['thumb_w'] = $config['download_thumb_width'];
             $save['thumb_h'] = $config['download_thumb_width'];
         }
     }
 }
 if (!$error) {
     $save['count'] = $id > 0 ? $file['count'] : 0;
     $save['last_update'] = $mmktime;
     // thumb
     if ($save['thumb'] != '') {
         $icon = DATA_URL . 'download/' . $save['thumb'];
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_setup_save.php

示例8: rawurlencode

             if (!$info) {
                 $ret["ret_{$key}"] = 'INVALID_FILE_TYPE';
                 $input = $key;
                 $error = 'INVALID_FILE_TYPE';
             } else {
                 $icon[$k] = "cat-{$k}-{$index['id']}.{$info['ext']}";
                 if ($info['width'] <= $index['icon_width'] && $info['height'] <= $index['icon_height']) {
                     // รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
                     if (!@move_uploaded_file($value['tmp_name'], DATA_PATH . "board/{$icon[$k]}")) {
                         $ret["ret_{$key}"] = 'DO_NOT_UPLOAD';
                         $input = $key;
                         $error = 'DO_NOT_UPLOAD';
                     } else {
                         $ret["icon_{$k}"] = rawurlencode(DATA_URL . "board/{$icon[$k]}?{$mmktime}");
                     }
                 } elseif (!gcms::cropImage($value['tmp_name'], DATA_PATH . "board/{$icon[$k]}", $info, $index['icon_width'], $index['icon_height'])) {
                     $ret["ret_{$key}"] = 'DO_NOT_UPLOAD';
                     $input = $key;
                     $error = 'DO_NOT_UPLOAD';
                 } else {
                     $ret["icon_{$k}"] = rawurlencode(DATA_URL . "board/{$icon[$k]}?{$mmktime}");
                 }
             }
         }
     }
     if (sizeof($icon) > 0) {
         $save['icon'] = gcms::array2Ser($icon);
     }
 }
 if (!$error) {
     $save['category_id'] = $category_id;
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:admin_categorywrite_save.php

示例9: elseif

     $ret['input'] = 'board_picture';
     $ret['ret_board_picture'] = 'INVALID_FILE_TYPE';
 } elseif ($picture['size'] > $index['img_upload_size'] * 1024) {
     $ret['error'] = 'FILE_TOO_BIG';
     $ret['input'] = 'board_picture';
     $ret['ret_board_picture'] = 'FILE_TOO_BIG';
 } else {
     // ชื่อไฟล์
     $save['picture'] = "{$mmktime}.{$info['ext']}";
     while (is_file(DATA_PATH . "board/{$save['picture']}")) {
         $mmktime++;
         $save['picture'] = "{$mmktime}.{$info['ext']}";
     }
     // อัปโหลดรูป
     $tw = max(32, (int) $index['thumb_width']);
     if (!gcms::cropImage($picture['tmp_name'], DATA_PATH . "board/thumb-{$save['picture']}", $info, $tw, $tw)) {
         $ret['error'] = 'DO_NOT_UPLOAD';
         $ret['input'] = 'board_picture';
         $ret['ret_board_picture'] = 'DO_NOT_UPLOAD';
     } elseif (!@move_uploaded_file($picture['tmp_name'], DATA_PATH . "board/{$save['picture']}")) {
         $ret['error'] = 'DO_NOT_UPLOAD';
         $ret['input'] = 'board_picture';
         $ret['ret_board_picture'] = 'DO_NOT_UPLOAD';
     } else {
         $save['pictureW'] = $info['width'];
         $save['pictureH'] = $info['height'];
         // ลบไฟล์เก่า
         if ($index['picture'] != '') {
             @unlink(DATA_PATH . "board/thumb-{$index['picture']}");
             @unlink(DATA_PATH . "board/{$index['picture']}");
         }
开发者ID:phannack,项目名称:GCMS,代码行数:31,代码来源:post.php


注:本文中的gcms::cropImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。