function setFile($src = null) { $this->ext = strtolower(pathinfo($src, PATHINFO_EXTENSION)); if (is_file($src) && ($this->ext == "jpg" or $this->ext == "jpeg")) { $this->img_r = ImageCreateFromjpeg($src); } elseif (is_file($src) && $this->ext == "png") { $this->img_r = ImageCreateFrompng($src); } elseif (is_file($src) && $this->ext == "gif") { $this->img_r = ImageCreateFromgif($src); } $this->img_w = imagesx($this->img_r); $this->img_h = imagesy($this->img_r); }
function Novo() { global $HTTP_POST_FILES; if (!empty($HTTP_POST_FILES['foto']['name'])) { $fotoOriginal = "tmp/" . $HTTP_POST_FILES['foto']['name']; if (file_exists($fotoOriginal)) { unlink($fotoOriginal); } copy($HTTP_POST_FILES['foto']['tmp_name'], $fotoOriginal); list($imagewidth, $imageheight, $img_type) = getImageSize($fotoOriginal); $src_img_original = ""; $fim_largura = $imagewidth; $fim_altura = $imageheight; $extensao = $img_type == "2" ? ".jpg" : ($img_type == "3" ? ".png" : ""); $nome_do_arquivo = date('Y-m-d-h-i') . "-" . substr(md5($fotoOriginal), 0, 10) . $extensao; $caminhoDaBig = "fotos/big/{$nome_do_arquivo}"; $caminhoDaSBig = "fotos/sbig/{$nome_do_arquivo}"; if ($imagewidth > 700 && $imageheight < $imagewidth) { $new_w = 500; $ratio = $imagewidth / $new_w; $new_h = ceil($imageheight / $ratio); if (!file_exists($caminhoDaBig)) { if ($img_type == "2") { $src_img_original = imagecreatefromjpeg($fotoOriginal); $dst_img = imagecreatetruecolor($new_w, $new_h); imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); imagejpeg($dst_img, $caminhoDaBig); } else { if ($img_type == "3") { $src_img_original = @ImageCreateFrompng($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original)); Imagepng($dst_img, $caminhoDaBig); } } } } elseif ($imagewidth > 400 && $imageheight > $imagewidth) { $new_w = 400; $ratio = $imagewidth / $new_w; $new_h = ceil($imageheight / $ratio); $fim_largura = $new_w; $fim_altura = $new_h; if (!file_exists($caminhoDaBig)) { if ($img_type == "2") { $src_img_original = @imagecreatefromjpeg($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); imagejpeg($dst_img, $caminhoDaBig); } else { if ($img_type == "3") { $src_img_original = @ImageCreateFrompng($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original)); Imagepng($dst_img, $caminhoDaBig); } } } } else { if (!file_exists($caminhoDaBig)) { copy($fotoOriginal, $caminhoDaBig); if ($img_type == "2") { $src_img_original = @imagecreatefromjpeg($fotoOriginal); } else { if ($img_type == "3") { $src_img_original = @imagecreatefrompng($fotoOriginal); } } } } $new_w = 100; $ratio = $imagewidth / $new_w; $new_h = round($imageheight / $ratio); $caminhoDaSmall = "fotos/small/{$nome_do_arquivo}"; if (!file_exists($caminhoDaSmall)) { if ($img_type == "2") { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); @imagejpeg($dst_img, $caminhoDaSmall); } else { if ($img_type == "3") { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original)); @imagepng($dst_img, $caminhoDaSmall); } } } copy($fotoOriginal, $caminhoDaSBig); if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) { die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>"); } } else { return false; } @session_start(); $this->id_pessoa = @$_SESSION['id_pessoa']; session_write_close(); $this->data_foto = str_replace("%2F", "/", $this->data_foto); $db = new clsBanco(); $db->Consulta("INSERT INTO foto_portal ( nm_credito, ref_cod_foto_secao, ref_ref_cod_pessoa_fj, data_foto, titulo, descricao, caminho, altura, largura ) VALUES ( '{$this->nm_credito}', '1', {$this->id_pessoa}, now(), '{$this->titulo}', '{$this->descricao}', '{$nome_do_arquivo}', {$fim_largura}, {$fim_altura} )"); echo "<script>document.location='fotos_lst.php';</script>"; return true; }
function createThumb($upfile, $dstfile, $max_width, $max_height) { $size = getimagesize($upfile); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if ($width <= $max_width && $height <= $max_height) { $tn_width = $width; $tn_height = $height; } elseif ($x_ratio * $height < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } if ($size['mime'] == "image/jpeg") { $src = ImageCreateFromJpeg($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); imageinterlace($dst, true); ImageJpeg($dst, $dstfile, 100); } else { if ($size['mime'] == "image/png") { $src = ImageCreateFrompng($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); // integer representation of the color black (rgb: 0,0,0) $background = imagecolorallocate($dst, 255, 255, 0); // removing the black from the placeholder imagecolortransparent($dst, $background); // turning off alpha blending (to ensure alpha channel information // is preserved, rather than removed (blending with the rest of the // image in the form of black)) imagealphablending($dst, false); // turning on alpha channel information saving (to ensure the full range // of transparency is preserved) imagesavealpha($dst, true); Imagepng($dst, $dstfile); } else { $src = ImageCreateFromGif($upfile); $dst = ImageCreateTrueColor($tn_width, $tn_height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height, $width, $height); imagegif($dst, $dstfile); } } }
function geraFotos($fotoOriginal) { list($imagewidth, $imageheight, $img_type) = @GetImageSize($fotoOriginal); $src_img_original = ""; $fim_largura = $imagewidth; $fim_altura = $imageheight; $extensao = $img_type == "2" ? ".jpg" : ($img_type == "3" ? ".png" : ""); $nome_do_arquivo = array_pop(explode("/", $fotoOriginal)); //date('Y-m-d')."-".substr(md5($fotoOriginal), 0, 10).$extensao; $caminhoDaBig = "arquivos/acoes/fotos/big/{$nome_do_arquivo}"; $caminhoDaFotoOriginal = "arquivos/acoes/fotos/original/{$nome_do_arquivo}"; if ($imagewidth > 700) { $new_w = 700; $ratio = $imagewidth / $new_w; $new_h = ceil($imageheight / $ratio); $fim_largura = $new_w; $fim_altura = $new_h; if (!file_exists($caminhaDaBig)) { if ($img_type == "2") { $src_img_original = @imagecreatefromjpeg($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); imagejpeg($dst_img, $caminhoDaBig); } else { if ($img_type == "3") { $src_img_original = @ImageCreateFrompng($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original)); Imagepng($dst_img, $caminhoDaBig); } } } } else { if (!file_exists($caminhoDaBig)) { copy($fotoOriginal, $caminhoDaBig); if ($img_type == "2") { $src_img_original = @imagecreatefromjpeg($fotoOriginal); } else { if ($img_type == "3") { $src_img_original = @imagecreatefrompng($fotoOriginal); } } } } $new_w = 100; $ratio = $imagewidth / $new_w; $new_h = round($imageheight / $ratio); $caminhoDaSmall = "arquivos/acoes/fotos/small/{$nome_do_arquivo}"; if (!file_exists($caminhaDaBig)) { if ($img_type == "2") { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); @imagejpeg($dst_img, $caminhoDaSmall); } else { if ($img_type == "3") { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original)); @imagepng($dst_img, $caminhoDaSmall); } } } copy($fotoOriginal, $caminhoDaFotoOriginal); if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) { die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>"); } }
public function func_resize_save($dst_file, $src_file, $save_path, $max_x, $max_y) { $img_size = getimagesize($src_file); $img_replace = basename($src_file); switch ($img_size[2]) { //gif case 1: $src_img = ImageCreateFromgif($src_file); $dst_img = ImageCreateTrueColor($max_x, $max_y); ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $max_x, $max_y, $img_size[0], $img_size[1]); Imagegif($dst_img, $save_path . $img_replace, 100); break; //jpeg or jpg //jpeg or jpg case 2: $src_img = ImageCreateFromjpeg($src_file); $dst_img = ImageCreateTrueColor($max_x, $max_y); ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $max_x, $max_y, $img_size[0], $img_size[1]); Imagejpeg($dst_img, $save_path . $img_replace, 100); break; //png //png case 3: $src_img = ImageCreateFrompng($src_file); $dst_img = ImageCreateTrueColor($max_x, $max_y); ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $max_x, $max_y, $img_size[0], $img_size[1]); Imagepng($dst_img, $save_path . $img_replace, 9); break; } ImageDestroy($dst_img); ImageDestroy($src_img); }
parse_str($stored_findings['resist_aerob'], $parsed_resist_aerob); parse_str($stored_findings['findings'], $parsed_findings); } } } } // end of if($child_img) $addr = explode("\r\n", $result['address']); if ($lang == "de") { $result['sex'] = strtr($result['sex'], "mfMF", "mwMW"); } /* Load the barcode img if it exists */ if (file_exists($root_path . 'cache/barcodes/pn_' . $fen . '.png')) { $bc = ImageCreateFrompng($root_path . 'cache/barcodes/pn_' . $fen . '.png'); } elseif (file_exists($root_path . 'cache/barcodes/en_' . $fen . '.png')) { $bc = ImageCreateFrompng($root_path . 'cache/barcodes/en_' . $fen . '.png'); } /* Dimensions of the patient's label */ $label_w = 282; $label_h = 178; // -- create label $label = ImageCreate($label_w, $label_h); $ewhite = ImageColorAllocate($label, 255, 255, 255); //white bkgrnd $elightgreen = ImageColorAllocate($label, 205, 225, 236); $eblue = ImageColorAllocate($label, 0, 127, 255); $eblack = ImageColorAllocate($label, 0, 0, 0); $egray = ImageColorAllocate($label, 127, 127, 127); //ImageFillToBorder($label,2,2,$egray,$ewhite); ImageRectangle($label, 0, 0, 281, 177, $egray); # Write the data on the label
} if (isset($_GET["square"])) { //正方形补白边 ImageCopyReSampled($thumb, $dest, $left, $top, 0, 0, $twidth, $theight, $nwidth, $nheight); } else { //长宽去白边 ImageCopyReSampled($thumb, $dest, $margin, $margin, 0, 0, $twidth, $theight, $nwidth, $nheight); } } ImageDestroy($dest); if (!$_GET["nomark"]) { if ($fwidth > 620 || $fheight > 620) { $logo = ImageCreateFrompng("./images/logo220.png"); $logosize = 220; } else { $logo = ImageCreateFrompng("./images/logo130.png"); $logosize = 130; } ImageSaveAlpha($logo, true); if (isset($_GET["square"])) { //正方形补白边 ImageCopy($thumb, $logo, $size - $logosize + $margin, $size - $logosize + $margin, 0, 0, $logosize, $logosize); } else { //长宽去白边 ImageCopy($thumb, $logo, $fwidth - $logosize - $margin, $fheight - $logosize - $margin, 0, 0, $logosize, $logosize); } ImageDestroy($logo); } if ($_GET["output"]) { Header("Content-type: image/png"); Imagepng($thumb);
mkdir("{$dest_project_dir}", 0777); chmod("{$dest_project_dir}", 0777); } $result = mysql_query("SELECT image FROM {$projectid}"); $numrows = mysql_num_rows($result); $rownum = 0; while ($rownum < $numrows) { //while ($row = mysql_fetch_row($result)) { $imagename = mysql_result($result, $rownum, "image"); //setup our source and destination images $image = "{$projects_dir}/{$projectid}/{$imagename}"; // name/location of original image. $new_image = "{$projects_dir}/{$projectid}/thumbs/{$imagename}"; // name/location of generated thumbnail. //'find' the source image $src_img = ImageCreateFrompng($image); //Get original image width and height $src_width = imagesx($src_img); $src_height = imagesy($src_img); //Our target output width $dest_width = 125; //width thumbnail (image will scale down completely to this width) //Calculate the aspect ratio of the original $aspect_ratio = $src_height / $src_width; //Calculate our output height to maintain the aspect ration of the original $dest_height = $dest_width * $aspect_ratio; //process the image //$dest_img = imagecreatetruecolor($dest_width,$dest_height); $dest_img = imagecreate($dest_width, $dest_height); imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); //write it out
/* The left border for drawing of blocks */ $top_border = 24; /* The top border for drawing of blocks */ $mark_v_offset = 1; /* Vertical offset of the marking blocks */ /* Load the violet phone icon */ if (file_exists($root_path . 'gui/img/common/default/violet_phone2.png')) { $v_phone = ImageCreateFrompng($root_path . 'gui/img/common/default/violet_phone2.png'); } /* Load the batch nr barcode */ if (file_exists($root_path . 'cache/barcodes/form_' . $batch_nr . '.png')) { $fbc = ImageCreateFrompng($root_path . 'cache/barcodes/form_' . $batch_nr . '.png'); } /* Load the label nr barcode */ if (file_exists($root_path . 'cache/barcodes/lab_' . $batch_nr . '.png')) { $lab_bc = ImageCreateFrompng($root_path . 'cache/barcodes/lab_' . $batch_nr . '.png'); } /* Set dimensions of the form */ $w = 745; $h = 1080; $im = @ImageCreate($w, $h); /* Allocate colors used for the form */ $white = ImageColorAllocate($im, 255, 255, 255); //white bkgrnd $blue = ImageColorAllocate($im, 0, 127, 255); $purple = ImageColorAllocate($im, 186, 124, 237); $light_violet = ImageColorAllocate($im, 243, 241, 254); $black = ImageColorAllocate($im, 00, 00, 00); $pink = ImageColorAllocate($im, 255, 206, 206); $light_pink = ImageColorAllocate($im, 255, 243, 243); $dark_pink = ImageColorAllocate($im, 238, 102, 102);
function GD2_make_thumb_new($max_x, $max_y, $dst_name, $src_file) { $img_info = @getimagesize($src_file); $sx = $img_info[0]; $sy = $img_info[1]; //썸네일 보다 큰가? if ($sx > $max_x && $sy > $max_y) { if ($sx > $sy) { $thumb_y = ceil($sy * $max_x / $sx); $thumb_x = $max_x; } else { $thumb_x = ceil($sx * $max_y / $sy); $thumb_y = $max_y; } } else { if ($sx > $max_x) { $thumb_y = ceil($sy * $max_x / $sx); $thumb_x = $max_x; } else { if ($sy > $max_y) { $thumb_x = ceil($sx * $max_y / $sy); $thumb_y = $max_y; } else { $thumb_y = $sy; $thumb_x = $sx; } } } // JPG 파일인가? if ($img_info[2] == "2" or 1) { $_dq_tempFile = basename($src_file); //파일명 추출 $_dq_tempDir = str_replace($_dq_tempFile, "", $src_file); //경로 추출 $_dq_tempFile = $dst_name; //경로 + 새 파일명 생성 $_create_thumb_file = true; /* if (file_exists($_dq_tempFile)) { //섬네일 파일이 이미 존제한다면 이미지의 사이즈 비교 $old_img=@getimagesize($_dq_tempFile); if($old_img[0] != $thumb_x) $_create_thumb_file = true; else $_create_thumb_file = false; if($old_img[1] != $thumb_y) $_create_thumb_file = true; else $_create_thumb_file = false; } */ if ($_create_thumb_file) { // 복제 if ($img_info[2] == "1") { $src_img = ImageCreateFromgif($src_file); } if ($img_info[2] == "2") { $src_img = ImageCreateFromjpeg($src_file); } if ($img_info[2] == "3") { $src_img = ImageCreateFrompng($src_file); } if ($img_info[2] == "16") { $src_img = imagecreatefromwxbm($src_file); } if ($img_info[2] == "5") { $src_img = imagecreatefromwbmp($src_file); } if ($img_info[2] == "6") { $src_img = ImageCreateFromBMP($src_file); } if (!$src_img) { $src_img = imagecreatefromjpeg($src_file); } $dst_img = ImageCreateTrueColor($thumb_x, $thumb_y); ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_x, $thumb_y, $sx, $sy); Imagejpeg($dst_img, $_dq_tempFile, 100); // 메모리 초기화 ImageDestroy($dst_img); ImageDestroy($src_img); } } }
function comprimirfoto($carpeta, $nombredestino, $extension, $BloquearImagenesSubidas) { global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsUser; $consulta2 = "SELECT ID, Carpeta, Imagen, Descripcion, Aleatorio, Bloque, MCatalogos, AnchoBloque, AltoBloque, AnchoImagenes, AltoImagenes, FotosAncho, FotosAlto, Anterior, Siguiente, InicioEncabezado, FinEncabezado, InicioPie, FinPie, InicioFoto, FinFoto, InicioMarcoFoto, FinMarcoFoto, EnviarFicheros, NombreFotoCarpeta, UsarBordes, BordesTema, BordeImagenPequenoIzquierda, BordeImagenPequenoDerecha, BordeImagenPequenoArriba, BordeImagenPequenoAbajo, UsarBordesGaleria, NombreFrameStyleGaleria, BloquearImagenesSubidas FROM " . $xoopsDB->prefix("uskolag_carpeta") . " Where Carpeta like '" . $carpeta . "'"; $myts = new MyTextSanitizer(); $result2 = $xoopsDB->query($consulta2); while ($tbCarpeta2 = $xoopsDB->fetchArray($result2)) { $BloquearImagenesSubidas = $tbCarpeta2['BloquearImagenesSubidas']; $ANCHOCARPETA = $tbCarpeta2['AnchoImagenes']; } switch ($extension) { case ".gif": $imagefile = "images/" . $carpeta . "/big/" . $nombredestino . $extension; $src_img = ImageCreateFromGif($imagefile); $image_stats = GetImageSize($imagefile); $imagewidth = $image_stats[0]; $imageheight = $image_stats[1]; $new_w = $ANCHOCARPETA; $porcentaje = $imagewidth / $new_w; $new_h = round($imageheight / $porcentaje); $dst_img = ImageCreate($new_w, $new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); ImageGif($dst_img, "images/" . $carpeta . "/small/" . $nombredestino . $extension); break; case ".jpg": $imagefile = "images/" . $carpeta . "/big/" . $nombredestino . $extension; $image_stats = GetImageSize($imagefile); $imagewidth = $image_stats[0]; $imageheight = $image_stats[1]; $new_w = $ANCHOCARPETA; $porcentaje = $imagewidth / $new_w; $new_h = round($imageheight / $porcentaje); $src_img = imagecreatefromjpeg($imagefile); $dst_img = imagecreate($new_w, $new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); imagejpeg($dst_img, "images/" . $carpeta . "/small/" . $nombredestino . $extension); break; case ".png": $imagefile = "images/" . $carpeta . "/big/" . $nombredestino . $extension; $src_img = ImageCreateFrompng($imagefile); $image_stats = GetImageSize($imagefile); $imagewidth = $image_stats[0]; $imageheight = $image_stats[1]; $new_w = $ANCHOCARPETA; $porcentaje = $imagewidth / $new_w; $new_h = round($imageheight / $porcentaje); $dst_img = imagecreate($new_w, $new_h); imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img), imagesy($src_img)); Imagepng($dst_img, "images/" . $carpeta . "/small/" . $nombredestino . $extension); break; default: die(_MI_USKOLAXGALLERY_ERROREXTENSION); exit; } }
*/ define('LANG_FILE', 'aufnahme.php'); define('NO_CHAIN', 1); require $root_path . 'include/inc_front_chain_lang.php'; if (!extension_loaded('gd')) { dl('php_gd.dll'); } /** * We will check again if gd is loaded, if yes create the image */ if (extension_loaded('gd')) { header('Content-type: image/png'); //header ('Content-type: image/jpeg'); //header ('Content-type: image/gif'); //$person=str_replace('+',' ',$person); $im = ImageCreateFrompng($root_path . 'gui/img/common/' . $theme_com_icon . '/cat-com5.png'); /* $im=ImageCreate(200,100); $background_color = ImageColorAllocate ($im, 255,102,102); $text_color = ImageColorAllocate ($im, 0, 170, 255); $background= ImageColorAllocate ($im, 205, 225, 236); $white = ImageColorAllocate ($im, 255, 255, 255); */ $blue = ImageColorAllocate($im, 0, 127, 255); $black = ImageColorAllocate($im, 0, 0, 0); $time = date(G); if ($time >= 0 && $time < 10) { $greet = $LDGoodMorning; } else { if ($time > 9 && $time < 13) { $greet = $LDGoodDay;
ImageCopy($im, $v_phone, $sx - 5, $sy - 1, 0, 0, 14, 10); } } /** * Initializations * Create the image $im and allocate colors */ $left_border = 4; /* The left border for drawing of blocks */ $top_border = 24; /* The top border for drawing of blocks */ $mark_v_offset = 1; /* Vertical offset of the marking blocks */ /* Load the batch nr barcode */ if (file_exists('../cache/barcodes/form_' . $batch_nr . '.png')) { $fbc = ImageCreateFrompng('../cache/barcodes/form_' . $batch_nr . '.png'); } /* Set dimensions of the form */ $w = 745; $h = 1080; $im = @ImageCreate($w, $h); /* Allocate colors used for the form */ $white = ImageColorAllocate($im, 255, 255, 255); //white bkgrnd $blue = ImageColorAllocate($im, 0, 127, 255); $purple = ImageColorAllocate($im, 186, 124, 237); $light_violet = ImageColorAllocate($im, 243, 241, 254); $black = ImageColorAllocate($im, 00, 00, 00); $pink = ImageColorAllocate($im, 255, 206, 206); $light_pink = ImageColorAllocate($im, 255, 243, 243); $dark_pink = ImageColorAllocate($im, 238, 102, 102);
function setThumbnail($file, $upload_dir = ".", $thumbnail_upload_dir = "./thumb", $filename = "", $thumbnail_size = 250, $thumbnail_quality = 76, $limit_size = 2, $type = 1, $check = 0, $image_type = 0, $image_width = 800, $image_height = 600, $limit_length = 30) { if ($filename == "") { $filename = $file[name]; } $img_size = $this->setFileUpload($file, $upload_dir, $filename, $limit_size, $type, $check, $image_type, $image_width, $image_height = 600, $limit_length = 30); //앨범에서의 썸네일 이미지를 위해 JPG GD를 사용하여 썸네일 이미지를 생성한다. if ($img_size[0] > $img_size[1]) { //가로방향 이미지 if ($img_size[0] > $thumbnail_size) { $img_width = $thumbnail_size; $img_height = $img_size[1] * $thumbnail_size / $img_size[0]; } else { $img_width = $img_size[0]; $img_height = $img_size[1]; } } else { //세로방향 이미지 if ($img_size[1] > $thumbnail_size) { $img_width = $img_size[0] * $thumbnail_size / $img_size[1]; $img_height = $thumbnail_size; } else { $img_width = $img_size[0]; $img_height = $img_size[1]; } } if ($file[type] == "image/pjpeg" && (eregi("\\.jpg\$", $file[name]) || eregi("\\.jpeg\$", $file[name])) && $this->varGDPermit[jpg] == 'Y') { $dst_img = ImageCreate($img_width, $img_height); // 위에서 계산한대로 빈 이미지 파일을 만듭니다. $src_img = ImageCreateFromjpeg("{$upload_dir}/{$filename}"); // 이미지파일을 읽어들입니다. ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img)); //빈 이미지에다 원본이미지를 줄여서 그립니다. $creat_file_name = "{$thumbnail_upload_dir}/{$filename}"; Imagejpeg($dst_img, $creat_file_name, $thumbnail_quality); // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다. } else { if ($file[type] == "image/x-png" && eregi("\\.png\$", $file[name]) && $this->varGDPermit[png] == 'Y') { $dst_img = ImageCreate($img_width, $img_height); // 위에서 계산한대로 빈 이미지 파일을 만듭니다. $src_img = ImageCreateFrompng("{$upload_dir}/{$filename}"); // 이미지파일을 읽어들입니다. ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img)); //빈 이미지에다 원본이미지를 줄여서 그립니다. $creat_file_name = "{$thumbnail_upload_dir}/{$filename}"; Imagepng($dst_img, $creat_file_name, $thumbnail_quality); // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다. } else { if ($file[type] == "image/gif" && eregi("\\.gif\$", $file[name]) && $this->varGDPermit[gif] == 'Y') { $dst_img = ImageCreate($img_width, $img_height); // 위에서 계산한대로 빈 이미지 파일을 만듭니다. $src_img = ImageCreateFromgif("{$upload_dir}/{$filename}"); // 이미지파일을 읽어들입니다. ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $img_width, $img_height, ImageSX($src_img), ImageSY($src_img)); //빈 이미지에다 원본이미지를 줄여서 그립니다. $creat_file_name = "{$thumbnail_upload_dir}/{$filename}"; Imagegif($dst_img, $creat_file_name, $thumbnail_quality); // thumb 디렉토리에 원본과 같은 이름의 jpeg으로 저장합니다. 76이라는 숫자는 퀄리티인데요, 높을수록 용량크고 질이 좋아집니다. } else { $this->errmsg("{$file['type']}은 GD를 지원하지 않습니다!!"); } } } ImageDestroy($dst_img); //로드한 메모리를 비워줍니다. gd는 꼭 이걸 해주어야 합니다. ImageDestroy($src_img); }
function reduit_fichier($fichier_image, $nomFinal, $max_v, $max_h, $source, $destination, $prefixe) { //if(call_user_func(array("Outils","extractExtension"),$fichier_image)!="jpg" && call_user_func(array("ajoutfichier","extractExtension"),$fichier_image)!="png") return; if ($this->extractExtension($fichier_image) != "jpg" && $this->extractExtension($fichier_image) != "jpeg" && $this->extractExtension($fichier_image) != "png") { return; } // MAX_V = HAUTEUR -- MAX_H = LARGEUR // le nom de l'image "scalée" commencera par ti_ et le nom du fichier original $ti_fichier_image = $prefixe . $nomFinal; if (file_exists($destination . $ti_fichier_image)) { $ti_fichier_image = $prefixe . time() . "_" . $nomFinal; } //global $nomfichier; if ($this->extractExtension($fichier_image) == "png") { $im = ImageCreateFrompng($source . $fichier_image); } else { $im = ImageCreateFromjpeg($source . $fichier_image); } $v = ImageSY($im); // $v prend la hauteur $h = ImageSX($im); // $h prend la largeur //Floor Arrondi à l'entier inférieur //ON GERE LA HAUTEUR if ($v > $max_v) { // Si la hauteur Img, est plus grand que le max, on reduit $taux_hauteur = $v / $max_v; // On recupere le taux necessaire pour retrecir $ti_v = (int) floor($max_v); // ti_v = taille final de la hauteur $ti_h = (int) floor($h / $taux_hauteur); // ti_h = taille final de la largeur } else { $ti_v = $v; } // Sinon on fixe la hauteur // Si il n'a pas deja subi une modification de la taille if ($ti_h != "") { $h_comp = $ti_h; } else { $h_comp = $h; } if ($ti_v != "") { $v_comp = $ti_v; } else { $v_comp = $v; } //ON GERE LA LARGEUR if ($h_comp > $max_h) { $taux_largeur = $h_comp / $max_h; $ti_h = (int) floor($max_h); $ti_v = (int) floor($v_comp / $taux_largeur); } else { $ti_h = $h_comp; } $ti_im = ImageCreateTrueColor($ti_h, $ti_v); imagecopyresampled($ti_im, $im, 0, 0, 0, 0, $ti_h, $ti_v, $h, $v); if ($this->extractExtension($fichier_image) == "png") { imagepng($ti_im, "{$destination}" . "{$ti_fichier_image}"); } else { imagejpeg($ti_im, "{$destination}" . "{$ti_fichier_image}"); } return $nomfichier = $ti_fichier_image; }
# Version History: # version 0.1 : First release. created on ( 22/01/2004) By Walid Fathalla # # Bug Report and Suggestion to: # Walid Fathalla # fathalla_w@hotmail.com # # Modifications by Elpidio 2004-02-07 include_once $root_path . 'include/inc_ttf_ar2uni.php'; /* Load the barcode image*/ $bc = ImageCreateFrompng($root_path . 'cache/barcodes/en_' . $full_en . '.png'); /* Load the wristband images */ $wb_lrg = ImageCreateFrompng('wristband_large.png'); $wb_med = ImageCreateFrompng('wristband_medium.png'); $wb_sml = ImageCreateFrompng('wristband_small.png'); $wb_bby = ImageCreateFrompng('wristband_baby.png'); /* Get the image sizes*/ $size_lrg = GetImageSize('wristband_large.png'); $size_med = GetImageSize('wristband_medium.png'); $size_sml = GetImageSize('wristband_small.png'); $size_bby = GetImageSize('wristband_baby.png'); $w = 1085; // The width of the image = equal to the DIN-A4 paper $h = 700; // The height of the image = egual to the DIN-A4 paper /* Create the main image */ $im = ImageCreate($w, $h); $white = ImageColorAllocate($im, 255, 255, 255); //white bkgrnd /* $background= ImageColorAllocate ($im, 205, 225, 236); $blue=ImageColorAllocate($im, 0, 127, 255);
function geraFotos($fotoOriginal) { if (!file_exists($fotoOriginal)) { return; } list($imagewidth, $imageheight, $img_type) = @GetImageSize($fotoOriginal); $src_img_original = ''; $fim_largura = $imagewidth; $fim_altura = $imageheight; $extensao = $img_type == 2 ? '.jpg' : ($img_type == 3 ? '.png' : ''); $nome_do_arquivo = array_pop(explode('/', $fotoOriginal)) . $extensao; $caminhoDaBig = 'arquivos/educar/aluno/big/' . $nome_do_arquivo; $caminhoDaFotoOriginal = 'arquivos/educar/aluno/original/' . $nome_do_arquivo; if ($imagewidth > 700) { $new_w = 700; $ratio = $imagewidth / $new_w; $new_h = ceil($imageheight / $ratio); $fim_largura = $new_w; $fim_altura = $new_h; if (!file_exists($caminhoDaBig)) { if ($img_type == 2) { $src_img_original = @imagecreatefromjpeg($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); imagejpeg($dst_img, $caminhoDaBig); } elseif ($img_type == 3) { $src_img_original = @ImageCreateFrompng($fotoOriginal); $dst_img = @imagecreatetruecolor($new_w, $new_h); ImageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), ImageSY($src_img_original)); Imagepng($dst_img, $caminhoDaBig); } } } else { if (!file_exists($caminhoDaBig)) { copy($fotoOriginal, $caminhoDaBig); if ($img_type == 2) { $src_img_original = @imagecreatefromjpeg($fotoOriginal); } elseif ($img_type == 3) { $src_img_original = @imagecreatefrompng($fotoOriginal); } } } $new_w = 100; $ratio = $imagewidth / $new_w; $new_h = round($imageheight / $ratio); $caminhoDaSmall = 'arquivos/educar/aluno/small/' . $nome_do_arquivo; if (file_exists($caminhoDaBig)) { if ($img_type == 2) { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imagecopyresized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, imagesx($src_img_original), imagesy($src_img_original)); @imagejpeg($dst_img, $caminhoDaSmall); } elseif ($img_type == 3) { $dst_img = @imagecreatetruecolor($new_w, $new_h); @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original)); @imagepng($dst_img, $caminhoDaSmall); } elseif ($img_type == 1) { $dst_img = @imagecreatefromgif($src_img_original); @imageCopyResized($dst_img, $src_img_original, 0, 0, 0, 0, $new_w, $new_h, ImageSX($src_img_original), imageSY($src_img_original)); @imagegif($dst_img, $caminhoDaSmall); } } copy($fotoOriginal, $caminhoDaFotoOriginal); if (!(file_exists($fotoOriginal) && file_exists($caminhoDaSmall) && file_exists($caminhoDaBig))) { die("<center><br>Um erro ocorreu ao inserir a foto.<br>Por favor tente novamente.</center>"); } if (file_exists($fotoOriginal)) { unlink($fotoOriginal); } return $nome_do_arquivo; }
function InitializeGump(&$img, $width, $height) { $img = ImageCreateFrompng("images/paperdoll.png") or die("couldnt create image"); imagealphablending($img, TRUE); imagecolortransparent($img, imagecolorallocate($img, 0, 0, 0)); }
function img_rotate() { $degree = I('get.degree'); $url = I('get.url'); //$url=dirname(__FILE__)."/verify.jpeg"; $source_info = getimagesize($url); $source_mime = $source_info['mime']; switch ($source_mime) { case 'image/gif': header('Content-type: image/gif'); $source = ImageCreateFromgif($url); $rotate = imagerotate($source, $degree, 0xffffff); imagegif($rotate); break; case 'image/jpeg': header('Content-type: image/jpeg'); $source = ImageCreateFromjpeg($url); $rotate = imagerotate($source, $degree, 0xffffff); imagejpeg($rotate); break; case 'image/png': header('Content-type: image/png'); $source = ImageCreateFrompng($url); $rotate = imagerotate($source, $degree, 0xffffff); imagepng($rotate); break; default: return false; break; } }