Example #1
0
 function scissors_supports_imagetype($mime_type)
 {
     if (function_exists('imagetypes')) {
         switch ($mime_type) {
             case 'image/jpeg':
                 return (imagetypes() & IMG_JPG) != 0;
             case 'image/png':
                 return (imagetypes() & IMG_PNG) != 0;
             case 'image/gif':
                 return (imagetypes() & IMG_GIF) != 0;
             default:
                 return FALSE;
         }
     } else {
         switch ($mime_type) {
             case 'image/jpeg':
                 return function_exists('imagecreatefromjpeg');
             case 'image/png':
                 return function_exists('imagecreatefrompng');
             case 'image/gif':
                 return function_exists('imagecreatefromgif');
             default:
                 return FALSE;
         }
     }
 }
function check_php()
{
    $data = array();
    $data['errors'] = array();
    $data['caninstall'] = true;
    $ver = explode('.', PHP_VERSION);
    $ver_num = $ver[0] . $ver[1] . $ver[2];
    if ($ver_num < 500) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_version', 'message' => 'Votre version de PHP est trop vieille. Installez PHP 5.');
    } elseif ($ver_num < 529) {
        $data['errors'][] = array('level' => 'warning', 'code' => 'php_version', 'message' => 'Vous utilisez PHP ' . PHP_VERSION . ' !<br />Il est conseill&eacute; d\'utiliser au moins la version 5.2.9 de PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_version', 'message' => 'Votre version de PHP (' . PHP_VERSION . ') est support&eacute;e par Iconito.');
    }
    if (ini_get('session.auto_start')) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'session_autostart', 'message' => 'Vous devez d&eacute;sactiver la cr&eacute;ation de session automatique. Pour cela, modifiez la directive "session.auto_start" dans votre php.ini (pour tous vos sites), dans la configuration de votre virtualhost dans la configuration d\'Apache (pour ce site sp&eacute;cifiquement), ou dans le .htaccess d\'Iconito (dans le r&eacute;pertoire "Iconito/www").');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'session_autostart', 'message' => 'La cr&eacute;ation de session automatique est d&eacute;sactiv&eacute;e.');
    }
    $php_extensions = get_loaded_extensions();
    if (!in_array('xml', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_xml', 'message' => 'Vous devez activer l\'extension "xml" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_xml', 'message' => 'L\'extension "xml" est activ&eacute;e.');
    }
    if (!in_array('session', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_session', 'message' => 'Vous devez activer l\'extension "session" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_session', 'message' => 'L\'extension "session" est activ&eacute;e.');
    }
    if (!in_array('mysql', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_mysql', 'message' => 'Vous devez activer l\'extension "mysql" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_mysql', 'message' => 'L\'extension "mysql" est activ&eacute;e.');
    }
    if (!in_array('gd', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_gd', 'message' => 'Vous devez activer l\'extension "gd" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_gd', 'message' => 'L\'extension "gd" est activ&eacute;e.');
        if (!(imagetypes() & IMG_GIF)) {
            $data['caninstall'] = true;
            $data['errors'][] = array('level' => 'warning', 'code' => 'php_gd_gif', 'message' => 'Votre version de "gd" ne supporte pas l\'&eacute;criture du format GIF. Il est pr&eacute;f&eacute;rable de mettre &agrave; jour cette extension.');
        } else {
            $data['errors'][] = array('level' => 'good', 'code' => 'php_gd_gif', 'message' => 'Votre version de "gd" supporte le format GIF.');
        }
    }
    if (!in_array('zlib', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_zlib', 'message' => 'Vous devez activer l\'extension "zlib" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_zlib', 'message' => 'L\'extension "zlib" est activ&eacute;e.');
    }
    return $data;
}
Example #3
0
/**
* Get supported image types
*/
function get_supported_image_types($type)
{
    if (@extension_loaded('gd')) {
        $format = imagetypes();
        $new_type = 0;
        switch ($type) {
            case 1:
                $new_type = $format & IMG_GIF ? IMG_GIF : 0;
                break;
            case 2:
            case 9:
            case 10:
            case 11:
            case 12:
                $new_type = $format & IMG_JPG ? IMG_JPG : 0;
                break;
            case 3:
                $new_type = $format & IMG_PNG ? IMG_PNG : 0;
                break;
            case 6:
            case 15:
                $new_type = $format & IMG_WBMP ? IMG_WBMP : 0;
                break;
        }
        return array('gd' => $new_type ? true : false, 'format' => $new_type, 'version' => function_exists('imagecreatetruecolor') ? 2 : 1);
    }
    return array('gd' => false);
}
Example #4
0
 /**
  * Save the image as the image type the original image was
  *
  * @param  string $savePath     - The path to store the new image
  * @param  string $imageQuality - The qulaity level of image to create
  *
  * @param bool    $download
  *
  * @return null Saves the image
  */
 public function saveImage($savePath, $imageQuality = "100", $download = false)
 {
     if (!$this->newImage) {
         return;
     }
     switch ($this->ext) {
         case 'image/jpg':
         case 'image/jpeg':
             // Check PHP supports this file type
             if (imagetypes() & IMG_JPG) {
                 imagejpeg($this->newImage, $savePath, $imageQuality);
             }
             break;
         case 'image/gif':
             // Check PHP supports this file type
             if (imagetypes() & IMG_GIF) {
                 imagegif($this->newImage, $savePath);
             }
             break;
         case 'image/png':
             $invertScaleQuality = 9 - round($imageQuality / 100 * 9);
             // Check PHP supports this file type
             if (imagetypes() & IMG_PNG) {
                 imagepng($this->newImage, $savePath, $invertScaleQuality);
             }
             break;
     }
     if ($download) {
         header('Content-Description: File Transfer');
         header("Content-type: application/octet-stream");
         header("Content-disposition: attachment; filename= " . $savePath . "");
         readfile($savePath);
     }
     imagedestroy($this->newImage);
 }
 public function welcome()
 {
     /* 系统信息 */
     $conn = mysql_connect(C('DB_HOST'), C('DB_USER'), C('DB_PWD'));
     $gd = gd_version();
     $sys_info['os'] = PHP_OS;
     $sys_info['ip'] = $_SERVER['SERVER_ADDR'];
     $sys_info['web_server'] = $_SERVER['SERVER_SOFTWARE'];
     $sys_info['php_ver'] = PHP_VERSION;
     $sys_info['mysql_ver'] = mysql_get_server_info($conn);
     $sys_info['zlib'] = function_exists('gzclose') ? L('yes') : L('no');
     $sys_info['safe_mode'] = (boolean) ini_get('safe_mode') ? L('yes') : L('no');
     $sys_info['safe_mode_gid'] = (boolean) ini_get('safe_mode_gid') ? L('yes') : L('no');
     $sys_info['timezone'] = function_exists("date_default_timezone_get") ? date_default_timezone_get() : L('no_timezone');
     $sys_info['socket'] = function_exists('fsockopen') ? L('yes') : L('no');
     
     if ($gd == 0) {
         $sys_info['gd'] = 'N/A';
     } else {
         if ($gd == 1) {
             $sys_info['gd'] = 'GD1';
         } else {
             $sys_info['gd'] = 'GD2';
         }
         
         $sys_info['gd'] .= ' (';
         
         /* 检查系统支持的图片类型 */
         if ($gd && (imagetypes() & IMG_JPG) > 0) {
             $sys_info['gd'] .= ' JPEG';
         }
         
         if ($gd && (imagetypes() & IMG_GIF) > 0) {
             $sys_info['gd'] .= ' GIF';
         }
         
         if ($gd && (imagetypes() & IMG_PNG) > 0) {
             $sys_info['gd'] .= ' PNG';
         }
         
         $sys_info['gd'] .= ')';
     }
     
     /* IP库版本 */
     $sys_info['ip_version'] = ecs_geoip('255.255.255.0');
     
     /* 允许上传的最大文件大小 */
     $sys_info['max_filesize'] = ini_get('upload_max_filesize');
     $this->assign('sys_info', $sys_info);
     
     $this->assign('ecs_version', VERSION);
     $this->assign('ecs_release', RELEASE);
     $this->assign('ecs_charset', strtoupper(EC_CHARSET));
     $this->assign('install_date', local_date(C('date_format'), C('install_date')));
     // 检测是否授权
     $data = array('appid' => ECTOUCH_AUTH_KEY);
     $empower = $this->cloud->data($data)->act('get.license');
     $this->assign('empower', $empower);
     $this->display('welcome');
 }
Example #6
0
 /**
  * Constructor
  *
  * @access  public
  * @return  mixed   True on success or Jaws_Error on failure
  */
 function Jaws_Image_GD()
 {
     if (!extension_loaded('gd')) {
         return Jaws_Error::raiseError('GD library is not available.', __FUNCTION__);
     }
     $types = imagetypes();
     if ($types & IMG_PNG) {
         $this->_supported_image_types['png'] = 'rw';
     }
     if ($types & IMG_GIF || function_exists('imagegif') || function_exists('imagecreatefromgif')) {
         $this->_supported_image_types['gif'] = 'rw';
     }
     if ($types & IMG_JPG) {
         $this->_supported_image_types['jpeg'] = 'rw';
     }
     if ($types & IMG_WBMP) {
         $this->_supported_image_types['wbmp'] = 'rw';
     }
     if ($types & IMG_XPM) {
         $this->_supported_image_types['xpm'] = 'r';
     }
     if (empty($this->_supported_image_types)) {
         return Jaws_Error::raiseError('No supported image types available.', __FUNCTION__);
     }
     return true;
 }
Example #7
0
function gerar_tumbs_real($t_x, $t_y, $qualidade, $c_original, $c_final)
{
    $thumbnail = imagecreatetruecolor($t_x, $t_y);
    $original = $c_original;
    $igInfo = getImageSize($c_original);
    switch ($igInfo['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                $originalimage = imageCreateFromGIF($original);
            } else {
                $ermsg = MSG_GIF_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $originalimage = imageCreateFromJPEG($original);
            } else {
                $ermsg = MSG_JPG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $originalimage = imageCreateFromPNG($original);
            } else {
                $ermsg = MSG_PNG_NOT_COMPATIBLE . '<br />';
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $originalimage = imageCreateFromWBMP($original);
            } else {
                $ermsg = MSG_WBMP_NOT_COMPATIBLE . '<br />';
            }
            break;
        default:
            $ermsg = $igInfo['mime'] . MSG_FORMAT_NOT_COMPATIBLE . '<br />';
            break;
    }
    $nLargura = $igInfo[0];
    $nAltura = $igInfo[1];
    if ($nLargura > $t_x and $nAltura > $t_y) {
        if ($t_x <= $t_y) {
            $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
            $nAltura = $t_y;
        } else {
            $nLargura = $t_x;
            $nAltura = (int) ($igInfo[1] * $t_x / $igInfo[0]);
            if ($nAltura < $t_y) {
                $nLargura = (int) ($igInfo[0] * $t_y / $igInfo[1]);
                $nAltura = $t_y;
            }
        }
    }
    $x_pos = $t_x / 2 - $nLargura / 2;
    $y_pos = $t_y / 2 - $nAltura / 2;
    imagecopyresampled($thumbnail, $originalimage, $x_pos, $y_pos, 0, 0, $nLargura, $nAltura, $igInfo[0], $igInfo[1]);
    imagejpeg($thumbnail, $c_final, $qualidade);
    imagedestroy($thumbnail);
    return 'ok';
}
Example #8
0
    public static function hasGDSupport() {
      if ( imagetypes() & ( IMG_JPG || IMG_GIF || IMG_PNG ) ) {
        return true;
      }

      return false;
    }
Example #9
0
 public function run($file)
 {
     $res = $this->open_image($file);
     if ($res != TRUE) {
         return FALSE;
     }
     $this->image_progressive = isset($this->settings['field_settings']['progressive_jpeg']) === TRUE && $this->settings['field_settings']['progressive_jpeg'] == 'yes' ? TRUE : FALSE;
     $width = $this->EE->channel_images->image_dim['width'];
     $height = $this->EE->channel_images->image_dim['height'];
     $imgdest = imagecreatetruecolor($width, $height);
     if (imagetypes() & IMG_PNG) {
         imagesavealpha($imgdest, true);
         imagealphablending($imgdest, false);
     }
     for ($x = 0; $x < $width; $x++) {
         for ($y = 0; $y < $height; $y++) {
             if ($this->settings['axis'] == 'both') {
                 imagecopy($imgdest, $this->EE->channel_images->image, $width - $x - 1, $height - $y - 1, $x, $y, 1, 1);
             } else {
                 if ($this->settings['axis'] == 'horizontal') {
                     imagecopy($imgdest, $this->EE->channel_images->image, $width - $x - 1, $y, $x, $y, 1, 1);
                 } else {
                     if ($this->settings['axis'] == 'vertical') {
                         imagecopy($imgdest, $this->EE->channel_images->image, $x, $height - $y - 1, $x, $y, 1, 1);
                     }
                 }
             }
         }
     }
     $this->EE->channel_images->image = $imgdest;
     $this->save_image($file);
     return TRUE;
 }
Example #10
0
 public function run($file)
 {
     $progressive = isset($this->settings['field_settings']['progressive_jpeg']) === TRUE && $this->settings['field_settings']['progressive_jpeg'] == 'yes' ? TRUE : FALSE;
     $this->size = getimagesize($file);
     $width = $this->size[0];
     $height = $this->size[1];
     if (isset($this->settings['only_if']) === TRUE) {
         // Do we need to rotate?
         if ($this->settings['only_if'] == 'width_bigger' && $width < $height) {
             return TRUE;
         } elseif ($this->settings['only_if'] == 'height_bigger' && $height < $width) {
             return TRUE;
         }
     }
     switch ($this->size[2]) {
         case 1:
             if (imagetypes() & IMG_GIF) {
                 $this->im = imagecreatefromgif($file);
             } else {
                 return 'No GIF Support!';
             }
             break;
         case 2:
             if (imagetypes() & IMG_JPG) {
                 $this->im = imagecreatefromjpeg($file);
             } else {
                 return 'No JPG Support!';
             }
             break;
         case 3:
             if (imagetypes() & IMG_PNG) {
                 $this->im = imagecreatefrompng($file);
             } else {
                 return 'No PNG Support!';
             }
             break;
         default:
             return 'File Type??';
     }
     $this->settings['background_color'];
     $this->settings['degrees'];
     $this->im = imagerotate($this->im, 360 - $this->settings['degrees'], hexdec($this->settings['background_color']));
     switch ($this->size[2]) {
         case 1:
             imagegif($this->im, $file);
             break;
         case 2:
             if ($progressive === TRUE) {
                 @imageinterlace($this->im, 1);
             }
             imagejpeg($this->im, $file, 100);
             break;
         case 3:
             imagepng($this->im, $file);
             break;
     }
     imagedestroy($this->im);
     return TRUE;
 }
Example #11
0
 public function create()
 {
     //набор символов
     $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'q', 'j', 'k', 'm', 'n', 'p', 'z', 'x', 'y', 's', 'u', 't', '2', '4', '5', '6', '7', '8', '9', '%', '+', '@', '#', '=', '?');
     //цвета
     $colors = array('90', '110', '130', '150', '170', '190', '210');
     $src = imagecreatetruecolor($this->width, $this->height);
     //создаем изображение
     $fon = imagecolorallocate($src, 255, 255, 255);
     //создаем фон
     imagefill($src, 0, 0, $fon);
     //заливаем изображение фоном
     for ($i = 0; $i < $this->fon_let_amount; $i++) {
         //случайный цвет
         $color = imagecolorallocatealpha($src, rand(0, 255), rand(0, 255), rand(0, 255), 100);
         //случайный символ
         $letter = $letters[rand(0, sizeof($letters) - 1)];
         //случайный размер
         $size = rand($this->font_size - 2, $this->font_size + 2);
         imagettftext($src, $size, rand(0, 45), rand($this->width * 0.1, $this->width - $this->width * 0.1), rand($this->height * 0.2, $this->height), $color, $this->font, $letter);
     }
     $code = array();
     for ($i = 0; $i < $this->let_amount; $i++) {
         $color = imagecolorallocatealpha($src, $colors[rand(0, sizeof($colors) - 1)], $colors[rand(0, sizeof($colors) - 1)], $colors[rand(0, sizeof($colors) - 1)], rand(20, 40));
         $letter = $letters[rand(0, sizeof($letters) - 1)];
         $size = rand($this->font_size * 2 - 2, $this->font_size * 2 + 2);
         $x = ($i + 1) * $this->font_size + rand(1, 5);
         //даем каждому символу случайное смещение
         $y = $this->height * 2 / 3 + rand(0, 5);
         $code[] = $letter;
         //запоминаем код
         imagettftext($src, $size, rand(0, 15), $x, $y, $color, $this->font, $letter);
     }
     $code = implode('', $code);
     //переводим код в строку
     // Обработка вывода
     if (imagetypes() & IMG_JPG) {
         // для JPEG
         header('Content-Type: image/jpeg');
         imagejpeg($src, NULL, 100);
     } elseif (imagetypes() & IMG_PNG) {
         // для PNG
         header('Content-Type: image/png');
         imagepng($src);
     } elseif (imagetypes() & IMG_GIF) {
         // для GIF
         header('Content-Type: image/gif');
         imagegif($src);
     } elseif (imagetypes() & IMG_PNG) {
         // для WBMP
         header('Content-Type: image/vnd.wap.wbmp');
         imagewbmp($src);
     } else {
         imagedestroy($src);
         return;
     }
     Session::set_server_data(array('captcha' => $code));
 }
Example #12
0
 /**
  * Constructor of Image handler
  *
  * @param string $file Path to the file
  * @param array $config Configure array
  */
 public function __construct($file, array &$config = array())
 {
     $this->setting = $config;
     $this->setting['SupportedImageTypes'] = imagetypes();
     if ($image = $this->openImage($file)) {
         $this->imageRes = $image['Res'];
         $this->imageInfo = $image['Info'];
     }
 }
Example #13
0
 function ReadSourceFile($image_file_name)
 {
     $this->DestroyImage();
     $this->ImageStatsSRC = @getimagesize($image_file_name);
     if ($this->ImageStatsSRC[2] == 3) {
         $this->ImageStatsSRC[2] = IMG_PNG;
     }
     $this->ImageMimeType = $this->ImageStatsSRC['mime'];
     $this->ImageTypeNo = $this->ImageStatsSRC[2];
     switch ($this->ImageTypeNo) {
         case IMG_GIF:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             $this->ImageTypeExt = '.gif';
             $image_read_func = 'imagecreatefromgif';
             break;
         case IMG_JPG:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             if (function_exists('exif_read_data')) {
                 $this->exif_get_data($image_file_name);
             }
             $this->ImageTypeExt = '.jpg';
             $image_read_func = 'imagecreatefromjpeg';
             break;
         case IMG_PNG:
             if (!(imagetypes() & $this->ImageTypeNo)) {
                 return false;
             }
             $this->ImageTypeExt = '.png';
             $image_read_func = 'imagecreatefrompng';
             break;
         default:
             return false;
     }
     $this->ImageID = $image_read_func($image_file_name);
     if (function_exists('imageistruecolor')) {
         if (imageistruecolor($this->ImageID)) {
             if (function_exists('imageantialias')) {
                 imageantialias($this->ImageID, true);
             }
             imagealphablending($this->ImageID, false);
             if (function_exists('imagesavealpha')) {
                 $this->Alpha = true;
                 imagesavealpha($this->ImageID, true);
             }
         }
     }
     $this->ChangeFlag = true;
     if ($this->ImageID) {
         return true;
     } else {
         return false;
     }
 }
Example #14
0
function create_thumb($path, $thumb_path, $width = THUMB_WIDTH, $height = THUMB_HEIGHT)
{
    $image_info = getImageSize($path);
    // see EXIF for faster way
    switch ($image_info['mime']) {
        case 'image/gif':
            if (imagetypes() & IMG_GIF) {
                // not the same as IMAGETYPE
                $o_im = @imageCreateFromGIF($path);
            } else {
                throw new Exception('GIF images are not supported');
            }
            break;
        case 'image/jpeg':
            if (imagetypes() & IMG_JPG) {
                $o_im = @imageCreateFromJPEG($path);
            } else {
                throw new Exception('JPEG images are not supported');
            }
            break;
        case 'image/png':
            if (imagetypes() & IMG_PNG) {
                $o_im = @imageCreateFromPNG($path);
            } else {
                throw new Exception('PNG images are not supported');
            }
            break;
        case 'image/wbmp':
            if (imagetypes() & IMG_WBMP) {
                $o_im = @imageCreateFromWBMP($path);
            } else {
                throw new Exception('WBMP images are not supported');
            }
            break;
        default:
            throw new Exception($image_info['mime'] . ' images are not supported');
            break;
    }
    list($o_wd, $o_ht, $html_dimension_string) = $image_info;
    $ratio = $o_wd / $o_ht;
    $t_ht = $width;
    $t_wd = $height;
    if (1 > $ratio) {
        $t_wd = round($o_wd * $t_wd / $o_ht);
    } else {
        $t_ht = round($o_ht * $t_ht / $o_wd);
    }
    $t_wd = $t_wd < 1 ? 1 : $t_wd;
    $t_ht = $t_ht < 1 ? 1 : $t_ht;
    $t_im = imageCreateTrueColor($t_wd, $t_ht);
    imageCopyResampled($t_im, $o_im, 0, 0, 0, 0, $t_wd, $t_ht, $o_wd, $o_ht);
    imagejpeg($t_im, $thumb_path, 85);
    chmod($thumb_path, 0664);
    imageDestroy($o_im);
    imageDestroy($t_im);
    return array($t_wd, $t_ht);
}
Example #15
0
 function supportedTypes()
 {
     $t = array();
     $t['image/jpeg'] = 'jpg';
     if (imagetypes() & IMG_PNG) {
         $t['image/png'] = 'png';
     }
     return $t;
 }
Example #16
0
 /**
  * Bild oeffnen
  */
 public function load()
 {
     // Evtl. geoeffnetes Bild schliessen
     $this->close();
     // Bildinformationen ermitteln
     $imageInfo = $this->getImageInfo();
     $this->imageType = $imageInfo['gdType'];
     // Je nach Bildtyp das Bild oeffnen
     switch ($imageInfo['gdType']) {
         case IMAGETYPE_JPEG:
             if (imagetypes() & IMG_JPG && function_exists('imagecreatefromjpeg')) {
                 // Typ setzen
                 $this->imageType = self::TYPE_JPG;
                 // JPG oeffnen
                 $this->image = imagecreatefromjpeg($this->imageFile);
             }
             break;
         case IMAGETYPE_GIF:
             if (imagetypes() & IMG_GIF && function_exists('imagecreatefromgif')) {
                 // Typ setzen
                 $this->imageType = self::TYPE_GIF;
                 // GIF oeffnen
                 $this->image = imagecreatefromgif($this->imageFile);
             }
             break;
         case IMAGETYPE_PNG:
             if (imagetypes() & IMG_PNG && function_exists('imagecreatefrompng')) {
                 // Typ setzen
                 $this->imageType = self::TYPE_PNG;
                 // PNG oeffnen
                 $this->image = imagecreatefrompng($this->imageFile);
                 imagealphablending($this->image, true);
                 imagesavealpha($this->image, true);
             }
             break;
         case IMAGETYPE_WBMP:
             if (imagetypes() & IMG_WBMP && function_exists('imagecreatefromwbmp')) {
                 // Typ setzen
                 $this->imageType = self::TYPE_WBMP;
                 // WBMP oeffnen
                 $this->image = imagecreatefromwbmp($this->imageFile);
             }
             break;
         default:
             // Fehler! Bild-Type nicht unterstuetzt
             return false;
     }
     // Bild geoeffnet?
     if ($this->image) {
         $this->_loaded = true;
         return true;
     }
     // Bild nicht geladen
     return false;
 }
Example #17
0
 /**
  * Check if system could make thumbnail for current file.
  * @param (string) path to file
  * @return (boolean)
  */
 public function file_support_thumbnail($file)
 {
     $info = getimagesize($file);
     $type = isset($info['type']) ? $info['type'] : $info[2];
     // Check support of file type
     if (!(imagetypes() & $type)) {
         // Server does not support file type
         return false;
     }
     return true;
 }
/**
 * 获得系统的信息
 *
 * @access  public
 * @return  array     系统各项信息组成的数组
 */
function get_system_info($_LANG = array())
{
    $system_info = array();
    /* 检查系统基本参数 */
    $system_info[] = array($_LANG['php_os'], PHP_OS);
    $system_info[] = array($_LANG['php_ver'], PHP_VERSION);
    /* 检查MYSQL支持情况 */
    $mysql_enabled = function_exists('mysql_connect') ? $_LANG['support'] : $_LANG['not_support'];
    $system_info[] = array($_LANG['does_support_mysql'], $mysql_enabled);
    /* 检查图片处理函数库 */
    $gd_ver = get_gd_version();
    $gd_ver = empty($gd_ver) ? $_LANG['not_support'] : $gd_ver;
    if ($gd_ver > 0) {
        if (PHP_VERSION >= '4.3' && function_exists('gd_info')) {
            $gd_info = gd_info();
            $jpeg_enabled = $gd_info['JPEG Support'] === true ? $_LANG['support'] : $_LANG['not_support'];
            $gif_enabled = $gd_info['GIF Create Support'] === true ? $_LANG['support'] : $_LANG['not_support'];
            $png_enabled = $gd_info['PNG Support'] === true ? $_LANG['support'] : $_LANG['not_support'];
        } else {
            if (function_exists('imagetypes')) {
                $jpeg_enabled = (imagetypes() & IMG_JPG) > 0 ? $_LANG['support'] : $_LANG['not_support'];
                $gif_enabled = (imagetypes() & IMG_GIF) > 0 ? $_LANG['support'] : $_LANG['not_support'];
                $png_enabled = (imagetypes() & IMG_PNG) > 0 ? $_LANG['support'] : $_LANG['not_support'];
            } else {
                $jpeg_enabled = $_LANG['not_support'];
                $gif_enabled = $_LANG['not_support'];
                $png_enabled = $_LANG['not_support'];
            }
        }
    } else {
        $jpeg_enabled = $_LANG['not_support'];
        $gif_enabled = $_LANG['not_support'];
        $png_enabled = $_LANG['not_support'];
    }
    $system_info[] = array($_LANG['gd_version'], $gd_ver);
    $system_info[] = array($_LANG['jpeg'], $jpeg_enabled);
    $system_info[] = array($_LANG['gif'], $gif_enabled);
    $system_info[] = array($_LANG['png'], $png_enabled);
    /* 检查系统是否支持以dwt,lib,dat为扩展名的文件 */
    //    $file_types = array(
    //            'dwt' => ROOT_PATH . 'themes/default/index.dwt',
    //            'lbi' => ROOT_PATH . 'themes/default/library/member.lbi',
    //            'dat' => ROOT_PATH . 'includes/codetable/ipdata.dat'
    //        );
    //    $exists_info = file_types_exists($file_types);
    //    $exists_info = empty($exists_info) ? $_LANG['support_dld'] : $exists_info;
    //    $system_info[] = array($_LANG['does_support_dld'], $exists_info);
    /* 服务器是否安全模式开启 */
    $safe_mode = ini_get('safe_mode') == '1' ? $_LANG['safe_mode_on'] : $_LANG['safe_mode_off'];
    $system_info[] = array($_LANG['safe_mode'], $safe_mode);
    return $system_info;
}
 /**
  * Checks to see if editor supports the mime-type specified.
  *
  * @since 3.5.0
  * @access public
  *
  * @param string $mime_type
  * @return boolean
  */
 public static function supports_mime_type($mime_type)
 {
     $image_types = imagetypes();
     switch ($mime_type) {
         case 'image/jpeg':
             return ($image_types & IMG_JPG) != 0;
         case 'image/png':
             return ($image_types & IMG_PNG) != 0;
         case 'image/gif':
             return ($image_types & IMG_GIF) != 0;
     }
     return false;
 }
Example #20
0
function gd_capabilities()
{
    if (function_exists("imageCreate")) {
        define("_JB_GD_INSTALLED", true);
        /*	Note on shorthands:
         *	($foo == "bar") ? true : false
         */
        define("_JB_GD_GIF", imagetypes() & IMG_GIF ? true : false);
        define("_JB_GD_PNG", imagetypes() & IMG_PNG ? true : false);
        define("_JB_GD_JPEG", imagetypes() & IMG_JPG ? true : false);
    } else {
        define("_JB_GD_INSTALLED", false);
    }
}
Example #21
0
 private function outputImg()
 {
     if (imagetypes() & IMG_PNG) {
         header('Content-type:image/png');
         imagejpeg($this->im);
     } elseif (imagetypes() & IMG_GIF) {
         header('Content-type: image/gif');
         imagegif($this->im);
     } elseif (imagetype() & IMG_JPG) {
         header('Content-type: image/jpeg');
         imagepng($this->im);
     } else {
         die("Don't support image type!");
     }
 }
Example #22
0
 private function printimg()
 {
     if (imagetypes() & IMG_GIF) {
         header("Content-type: image/gif");
         imagegif($this->img);
     } elseif (function_exists("imagejpeg")) {
         header("Content-type: image/jpeg");
         imagegif($this->img);
     } elseif (imagetypes() & IMG_PNG) {
         header("Content-type: image/png");
         imagegif($this->img);
     } else {
         die("No image support in this PHP server");
     }
 }
 public function __construct()
 {
     // check if we have gd installed
     if (function_exists('imagecreatetruecolor')) {
         $this->isAvailable = true;
         foreach ($this->supportedTypeMap as $gd_bit => $imagetype) {
             if (imagetypes() & $gd_bit) {
                 // swap gd_bit & imagetype
                 $this->imageTypes[$imagetype] = $gd_bit;
             }
         }
     }
     if (function_exists('logThis') && isset($GLOBALS['path'])) {
         $this->writeToUpgradeLog = true;
     }
 }
Example #24
0
function monoslideshow_can_resize($ext)
{
    if ($ext != 'jpg' && $ext != 'jpeg') {
        return false;
    }
    if (!@is_writeable(site_docroot() . '/inc/app/monoslideshow/pix')) {
        return false;
    }
    if (!extension_loaded('gd')) {
        return false;
    }
    if (@imagetypes() & IMG_JPG) {
        return true;
    }
    return false;
}
Example #25
0
function sitegallery_can_resize($ext)
{
    if ($ext != 'jpg' && $ext != 'jpeg') {
        return false;
    }
    if (!@is_writeable(site_docroot() . '/inc/app/sitegallery/pix/thumbnails')) {
        return false;
    }
    if (!extension_loaded('gd')) {
        return false;
    }
    if (@imagetypes() & IMG_JPG) {
        return true;
    }
    return false;
}
Example #26
0
function thumbnail($inputFileName, $outputFileName, $maxSize = 100)
{
    $info = getimagesize($inputFileName);
    $type = isset($info['type']) ? $info['type'] : $info[2];
    if (!(imagetypes() & $type)) {
        return false;
    }
    $width = isset($info['width']) ? $info['width'] : $info[0];
    $height = isset($info['height']) ? $info['height'] : $info[1];
    $wRatio = $maxSize / $width;
    $hRatio = $maxSize / $height;
    $sourceImage = imagecreatefromstring(file_get_contents($inputFileName));
    if ($width <= $maxSize && $height <= $maxSize) {
        return $sourceImage;
    } elseif ($wRatio * $height < $maxSize) {
        $tHeight = ceil($wRatio * $height);
        $tWidth = $maxSize;
    } else {
        $tWidth = ceil($hRatio * $width);
        $tHeight = $maxSize;
    }
    $thumb = imagecreatetruecolor($tWidth, $tHeight);
    if ($sourceImage === false) {
        return false;
    }
    imagecopyresampled($thumb, $sourceImage, 0, 0, 0, 0, $tWidth, $tHeight, $width, $height);
    imagedestroy($sourceImage);
    $ext = strtolower(substr($outputFileName, strrpos($outputFileName, '.')));
    switch ($ext) {
        case '.gif':
            imagegif($thumb, $outputFileName);
            break;
        case '.jpg':
        case '.jpeg':
            imagejpeg($thumb, $outputFileName, 80);
            break;
        case '.png':
            imagepng($thumb, $outputFileName);
            break;
        case '.bmp':
            imagewbmp($thumb, $outputFileName);
            break;
        default:
            return false;
    }
    return true;
}
Example #27
0
 /**
  * supported mimetypes and corresponding file extensions
  */
 static function supportedTypes()
 {
     if (class_exists('Imagick')) {
         /**
          * Imagick::queryFormats won't help us a lot there...
          * At least, not yet, other parts of friendica uses this array
          */
         $t = array('image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif');
     } else {
         $t = array();
         $t['image/jpeg'] = 'jpg';
         if (imagetypes() & IMG_PNG) {
             $t['image/png'] = 'png';
         }
     }
     return $t;
 }
Example #28
0
 /**
  * Constructor of Gd
  *
  * @param string $file
  * @throws Exception
  */
 public function __construct($file)
 {
     if (!file_exists($file)) {
         throw new Exception("Image `{$file}` file not found");
     }
     $this->file = $file;
     // Retrieve image information
     list($this->width, $this->height, $type) = getimagesize($file);
     // Check support of file type
     if (!(imagetypes() & $type)) {
         throw new Exception("Server does not support `{$type}` image type");
     }
     // Using imagecreatefromstring will automatically detect the file type
     $this->image = imagecreatefromstring(file_get_contents($file));
     if (!$this->image) {
         throw new Exception("Could not load image");
     }
 }
Example #29
0
 public function __construct(array $params = null)
 {
     if (!($info = @gd_info())) {
         throw new BakedCarrotImageException('GD extension not installed');
     }
     if (imagetypes() & IMG_PNG) {
         $this->format_supported[] = IMAGETYPE_PNG;
     }
     if (imagetypes() & IMG_JPG) {
         $this->format_supported[] = IMAGETYPE_JPEG;
     }
     if (imagetypes() & IMG_GIF) {
         $this->format_supported[] = IMAGETYPE_GIF;
     }
     $this->setLoaderPrefix('image');
     $this->dir_mask = $this->loadParam('dir_mask', $params, $this->dir_mask);
     $this->file_mask = $this->loadParam('file_mask', $params, $this->file_mask);
 }
Example #30
0
 function PrepareImgFormat()
 {
     $format = strtolower($this->iImgFormat);
     if ($format == 'jpg') {
         $format = 'jpeg';
     }
     $tst = true;
     $supported = imagetypes();
     if ($format == "auto") {
         if ($supported & IMG_PNG) {
             $this->iImgFormat = "png";
         } elseif ($supported & IMG_JPG) {
             $this->iImgFormat = "jpeg";
         } elseif ($supported & IMG_GIF) {
             $this->iImgFormat = "gif";
         } elseif ($supported & IMG_WBMP) {
             $this->iImgFormat = "wbmp";
         } else {
             $this->iError = -15;
             return false;
         }
     } else {
         if ($format == "jpeg" || $format == "png" || $format == "gif") {
             if ($format == "jpeg" && !($supported & IMG_JPG)) {
                 $tst = false;
             } elseif ($format == "png" && !($supported & IMG_PNG)) {
                 $tst = false;
             } elseif ($format == "gif" && !($supported & IMG_GIF)) {
                 $tst = false;
             } elseif ($format == "wbmp" && !($supported & IMG_WBMP)) {
                 $tst = false;
             } else {
                 $this->iImgFormat = $format;
             }
         } else {
             $tst = false;
         }
         if (!$tst) {
             $this->iError = -15;
             return false;
         }
     }
     return true;
 }