function fillInfo() { if(!$this->isLoaded()) { echo " : ERREUR : non chargé."; } else { echo " : OK : chargé."; } if($this->isLoaded()) { $this->width = imageSx($this->image); $this->height = imageSy($this->image); echo "Taille : " . $this->width . " x " . $this->height; } }
function Cartoonfy($p_image, $p_triplevel, $p_diffspace) { $this->triplevel = (int) (2000.0 + 5000.0 * $p_triplevel); $this->diffspace = (int) ($p_diffspace * 32.0); $this->i0 = imageCreateFromString(file_get_contents($p_image)); if ($this->i0) { $this->i1 = imageCreateTrueColor(imageSx($this->i0), imageSy($this->i0)); for ($x = (int) $this->diffspace; $x < imageSx($this->i0) - (1 + (int) $this->diffspace); $x++) { for ($y = (int) $this->diffspace; $y < imageSy($this->i0) - (1 + (int) $this->diffspace); $y++) { $t = Cartoonfy::GetMaxContrast($x, $y); if ($t > $this->triplevel) { imageSetPixel($this->i1, $x, $y, 0); } else { imageSetPixel($this->i1, $x, $y, Cartoonfy::FlattenColor(imageColorAt($this->i0, $x, $y))); } } //usleep(1000); } imageDestroy($this->i0); } else { print "<b>" . $p_image . "</b> is not supported image format!"; exit; } }
/** * Generate images of alternate sizes. */ function resizeImage($cnvrt_arry) { global $platform, $imgs, $cnvrt_path, $reqd_image, $convert_writable, $convert_magick, $convert_GD, $convert_cmd, $cnvrt_alt, $cnvrt_mesgs, $compat_quote; if (empty($imgs) || $convert_writable == FALSE) { return; } if ($convert_GD == TRUE && !($gd_version = gdVersion())) { return; } if ($cnvrt_alt['no_prof'] == TRUE) { $strip_prof = ' +profile "*"'; } else { $strip_prof = ''; } if ($cnvrt_alt['mesg_on'] == TRUE) { $str = ''; } foreach ($imgs as $img_file) { if ($cnvrt_alt['indiv'] == TRUE && $img_file != $reqd_image['file']) { continue; } $orig_img = $reqd_image['pwd'] . '/' . $img_file; $cnvrtd_img = $cnvrt_path . '/' . $cnvrt_arry['prefix'] . $img_file; if (!is_file($cnvrtd_img)) { $img_size = GetImageSize($orig_img); $height = $img_size[1]; $width = $img_size[0]; $area = $height * $width; $maxarea = $cnvrt_arry['maxwid'] * $cnvrt_arry['maxwid'] * 0.9; $maxheight = $cnvrt_arry['maxwid'] * 0.75 + 1; if ($area > $maxarea || $width > $cnvrt_arry['maxwid'] || $height > $maxheight) { if ($width / $cnvrt_arry['maxwid'] >= $height / $maxheight) { $dim = 'W'; } if ($height / $maxheight >= $width / $cnvrt_arry['maxwid']) { $dim = 'H'; } if ($dim == 'W') { $cnvt_percent = round(0.9375 * $cnvrt_arry['maxwid'] / $width * 100, 2); } if ($dim == 'H') { $cnvt_percent = round(0.75 * $cnvrt_arry['maxwid'] / $height * 100, 2); } // convert it if ($convert_magick == TRUE) { // Image Magick image conversion if ($platform == 'Win32' && $compat_quote == TRUE) { $winquote = '"'; } else { $winquote = ''; } exec($winquote . $convert_cmd . ' -geometry ' . $cnvt_percent . '%' . ' -quality ' . $cnvrt_arry['qual'] . ' -sharpen ' . $cnvrt_arry['sharpen'] . $strip_prof . ' "' . $orig_img . '"' . ' "' . $cnvrtd_img . '"' . $winquote); $using = $cnvrt_mesgs['using IM']; } elseif ($convert_GD == TRUE) { // GD image conversion if (eregi('\\.jpg$|\\.jpeg$', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { $src_img = imageCreateFromJpeg($orig_img); } elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { $src_img = imageCreateFromPng($orig_img); } elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { $src_img = imageCreateFromGif($orig_img); } else { continue; } $src_width = imageSx($src_img); $src_height = imageSy($src_img); $dest_width = $src_width * ($cnvt_percent / 100); $dest_height = $src_height * ($cnvt_percent / 100); if ($gd_version >= 2) { $dst_img = imageCreateTruecolor($dest_width, $dest_height); imageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } else { $dst_img = imageCreate($dest_width, $dest_height); imageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height); } imageDestroy($src_img); if (eregi('\\.jpg$|\\.jpeg$/i', $img_file) == TRUE && (imageTypes() & IMG_JPG) == TRUE) { imageJpeg($dst_img, $cnvrtd_img, $cnvrt_arry['qual']); } elseif (eregi('\\.gif$', $img_file) == TRUE && (imageTypes() & IMG_PNG) == TRUE) { imagePng($dst_img, $cnvrtd_img); } elseif (eregi('\\.gif$/i', $img_file) == TRUE && (imageTypes() & IMG_GIF) == TRUE) { imageGif($dst_img, $cnvrtd_img); } imageDestroy($dst_img); $using = $cnvrt_mesgs['using GD'] . $gd_version; } if ($cnvrt_alt['mesg_on'] == TRUE && is_file($cnvrtd_img)) { $str .= " <small>\n" . ' ' . $cnvrt_mesgs['generated'] . $cnvrt_arry['txt'] . $cnvrt_mesgs['converted'] . $cnvrt_mesgs['image_for'] . $img_file . $using . ".\n" . " </small>\n <br />\n"; } } } } if (isset($str)) { return $str; } }
} $wh = imageSx($orig); if (imageSy($orig) < $wh) { $wh = imageSy($orig); } if ($img['i_set'] > 0 && isset($_GET['set'])) { imagecopyresampled($im, $orig, 0 + $W / 8, 0 + $W / 8, imageSx($orig) / 2 - $wh / 2, imageSy($orig) / 2 - $wh / 2, $W - $W / 4, $W - $W / 4, $wh, $wh); } else { imagecopyresampled($im, $orig, 0, 0, imageSx($orig) / 2 - $wh / 2, imageSy($orig) / 2 - $wh / 2, $W, $W, $wh, $wh); } if ((int) $img['i_rotation'] != 0) { $im = imagerotate($im, $img['i_rotation'] * -90, 0); } if ($img['i_set'] > 0 && isset($_GET['set'])) { $stack = imageCreateFromPng(projectPath . '/resources/stack.png'); imagecopyresampled($im, $stack, 0, 0, 0, 0, $W, $W, imageSx($stack), imageSy($stack)); } if (me() != $img['i_u_fk']) { $own->addWatermark($im); } if ($img['i_set'] > 0 && isset($_GET['set'])) { header("content-type: image/png"); imagePng($im); } else { header("content-type: image/jpeg"); imageJpeg($im, NULL, 90); } exit; break; if (me() <= 0 || getS('user', 'u_email') != ownStaGramAdmin) { jump2();
public function addWatermark(&$im) { if (trim($this->settings['s_watermark']) == "") { return; } $size = 5; do { $size += 2; $bbox = $this->imagettfbbox_fixed($size, 0, projectPath . '/resources/KunKhmer.ttf', $this->settings['s_watermark']); $w = $bbox[4] - $bbox[0]; $h = $bbox[5] - $bbox[1]; } while ($w < imageSx($im) * 0.9 && $size < 100); $color = "CCCCCC"; $opacity = 30; $alpha_color = imagecolorallocatealpha($im, hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)), 127 * (100 - $opacity) / 100); imagettftext($im, $size, 0, imageSx($im) / 2 - $w / 2, imageSy($im) / 2 - $h / 2, $alpha_color, projectPath . '/resources/KunKhmer.ttf', $this->settings['s_watermark']); imageLine($im, 0, 0, imageSx($im), imageSy($im), $alpha_color); imageLine($im, imageSx($im), 0, 0, imageSy($im), $alpha_color); imageLine($im, 0, 0, imageSx($im), imageSy($im) / 2, $alpha_color); imageLine($im, 0, 0, imageSx($im) / 2, imageSy($im), $alpha_color); }