function onlineresize($subor, $NovaSirka, $NovaVyska) { $urli = getimagesize($subor); if ($urli["mime"] == "image/jpg") { $image = imagecreatefromjpg($subor); } elseif ($urli["mime"] == "image/png") { $image = imagecreatefrompng($subor); } elseif ($urli["mime"] == "image/gif") { $image = imagecreatefromgif($subor); } elseif ($urli["mime"] == "image/jpeg") { $image = imagecreatefromjpeg($subor); } $sirka = imagesx($image); $vyska = imagesy($image); if ($NovaVyska == 0) { $pomer = $sirka / $vyska; $NovaVyska = $NovaSirka / $pomer; } else { $NovaSirka = $NovaSirka; $NovaVyska = $NovaVyska; } $image_zmenseny = imagecreatetruecolor($NovaSirka, $NovaVyska); imagecopyresampled($image_zmenseny, $image, 0, 0, 0, 0, $NovaSirka, $NovaVyska, $sirka, $vyska); // Zobraz�me zmen�eninu if ($urli["mime"] == "image/jpg") { header('Content-type: image/jpg'); imagejpg($image_zmenseny); } elseif ($urli["mime"] == "image/png") { header('Content-type: image/png'); imagepng($image_zmenseny); } elseif ($urli["mime"] == "image/gif") { header('Content-type: image/gif'); imagegif($image_zmenseny); } elseif ($urli["mime"] == "image/jpeg") { header('Content-type: image/jpeg'); imagejpeg($image_zmenseny); } }
/** * This generates the forum signature of a pilot which * can be used wherever. It's dynamic, and adjusts it's * size, etc based on the background image. * * Each image is output into the /lib/signatures directory, * and is named by the pilot code+number (ie, VMA0001.png) * * This is called whenever a PIREP is accepted by an admin, * as not to burden a server with image generation * * Also requires GD to be installed on the server * * @param int The pilot ID for which to generate a signature for * @return bool Success */ public static function generateSignature($pilotid) { $pilot = self::getPilotData($pilotid); $pilotcode = self::getPilotCode($pilot->code, $pilot->pilotid); if (Config::Get('TRANSFER_HOURS_IN_RANKS') === true) { $totalhours = $pilot->totalhours + $pilot->transferhours; } else { $totalhours = $pilot->totalhours; } # Configure what we want to show on each line $output = array(); $output[] = $pilotcode . ' ' . $pilot->firstname . ' ' . $pilot->lastname; $output[] = $pilot->rank . ', ' . $pilot->hub; $output[] = 'Total Flights: ' . $pilot->totalflights; $output[] = 'Total Hours: ' . $totalhours; if (Config::Get('SIGNATURE_SHOW_EARNINGS') == true) { $output[] = 'Total Earnings: ' . $pilot->totalpay; } # Load up our image # Get the background image the pilot selected if (empty($pilot->bgimage)) { $bgimage = SITE_ROOT . '/lib/signatures/background/background.png'; } else { $bgimage = SITE_ROOT . '/lib/signatures/background/' . $pilot->bgimage; } if (!file_exists($bgimage)) { # Doesn't exist so use the default $bgimage = SITE_ROOT . '/lib/signatures/background/background.png'; if (!file_exists($bgimage)) { return false; } } $img = @imagecreatefrompng($bgimage); if (!$img) { $img = imagecreatetruecolor(300, 50); } $height = imagesy($img); $width = imagesx($img); $txtcolor = str_replace('#', '', Config::Get('SIGNATURE_TEXT_COLOR')); $color = sscanf($txtcolor, '%2x%2x%2x'); $textcolor = imagecolorallocate($img, $color[0], $color[1], $color[2]); $font = 3; // Set the font-size $xoffset = Config::Get('SIGNATURE_X_OFFSET'); # How many pixels, from left, to start $yoffset = Config::Get('SIGNATURE_Y_OFFSET'); # How many pixels, from top, to start $font = Config::Get('SIGNATURE_FONT_PATH'); $font_size = Config::Get('SIGNATURE_FONT_SIZE'); if (function_exists('imageantialias')) { imageantialias($img, true); } /* Font stuff */ if (!function_exists('imagettftext')) { Config::Set('SIGNATURE_USE_CUSTOM_FONT', false); } # The line height of each item to fit nicely, dynamic if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { $stepsize = imagefontheight($font); $fontwidth = imagefontwidth($font); } else { // get the font width and step size $bb = imagettfbbox($font_size, 0, $font, 'A'); $stepsize = $bb[3] - $bb[5] + Config::Get('SIGNATURE_FONT_PADDING'); $fontwidth = $bb[2] - $bb[0]; } $currline = $yoffset; $total = count($output); for ($i = 0; $i < $total; $i++) { if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { imagestring($img, $font, $xoffset, $currline, $output[$i], $textcolor); } else { // Use TTF $tmp = imagettftext($img, $font_size, 0, $xoffset, $currline, $textcolor, $font, $output[$i]); // Flag is placed at the end of of the first line, so have that bounding box there if ($i == 0) { $flag_bb = $tmp; } } $currline += $stepsize; } # Add the country flag, line it up with the first line, which is the # pilot code/name $country = strtolower($pilot->location); if (file_exists(SITE_ROOT . '/lib/images/countries/' . $country . '.png')) { $flagimg = imagecreatefrompng(SITE_ROOT . '/lib/images/countries/' . $country . '.png'); if (Config::Get('SIGNATURE_USE_CUSTOM_FONT') == false) { $ret = imagecopy($img, $flagimg, strlen($output[0]) * $fontwidth, $yoffset + $stepsize / 2 - 5.5, 0, 0, 16, 11); } else { # figure out where it would go $ret = imagecopy($img, $flagimg, $flag_bb[4] + 5, $flag_bb[5] + 2, 0, 0, 16, 11); } } # Add the Rank image if (Config::Get('SIGNATURE_SHOW_RANK_IMAGE') == true && $pilot->rankimage != '' && file_exists($pilot->rankimage)) { $ext = substr($pilot->rankimage, strlen($pilot->rankimage) - 3, 3); # Get the rank image type, just jpg, gif or png if ($ext == 'png') { $rankimg = @imagecreatefrompng($pilot->rankimage); } elseif ($ext == 'gif') { $rankimg = @imagecreatefromgif($pilot->rankimage); } else { $rankimg = @imagecreatefromjpg($pilot->rankimage); } if (!$rankimg) { echo ''; } else { $r_width = imagesx($rankimg); $r_height = imagesy($rankimg); imagecopy($img, $rankimg, $width - $r_width - $xoffset, $yoffset, 0, 0, $r_width, $r_height); } } if (Config::Get('SIGNATURE_SHOW_COPYRIGHT') == true) { # # DO NOT remove this, as per the phpVMS license $font = 1; $text = 'powered by phpvms, ' . SITE_NAME . ' '; imagestring($img, $font, $width - strlen($text) * imagefontwidth($font), $height - imagefontheight($font), $text, $textcolor); } imagepng($img, SITE_ROOT . SIGNATURE_PATH . '/' . $pilotcode . '.png', 1); imagedestroy($img); }
switch ($ext) { case "png": $im = imagecreatefrompng($file); header('Content-type: image/png'); imagepng($im); imagedestroy($im); break; case "gif": $im = imagecreatefromgif($file); header('Content-type: image/gif'); //imagegif($im); echo file_get_contents($image); imagedestroy($im); break; case "jpg": $im = imagecreatefromjpg($file); header('Content-type: image/jpg'); imagejpg($im); imagedestroy($im); break; case "wmv": header('Content-type: video/x-ms-wmv'); readfile($file); break; case "ogv": header('Content-type: video/ogg'); readfile($file); break; case "ogg": header('Content-type: video/ogg'); readfile($file);
<?php $imgSrc = htmlspecialchars($_GET['i']); list($width, $height) = getimagesize($imgSrc); $urli = getimagesize($imgSrc); if ($urli["mime"] == "image/jpg") { $myImage = imagecreatefromjpg($imgSrc); } elseif ($urli["mime"] == "image/png") { $myImage = imagecreatefrompng($imgSrc); } elseif ($urli["mime"] == "image/gif") { $myImage = imagecreatefromgif($imgSrc); } elseif ($urli["mime"] == "image/jpeg") { $myImage = imagecreatefromjpeg($imgSrc); } if ($width > $height) { $y = 0; $x = ($width - $height) / 1000000000; $smallestSide = $height; } else { $x = 0; $y = ($height - $width) / 1000000000; $smallestSide = $width; } $thumbSize = 700; $thumbSize2 = 300; $thumb = imagecreatetruecolor($thumbSize, $thumbSize2); imagecopyresampled($thumb, $myImage, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide); if ($urli["mime"] == "image/jpg") { header('Content-type: image/jpg'); imagejpg($thumb); } elseif ($urli["mime"] == "image/png") {
$pathparts = pathinfo($image); $ext = strtolower($pathparts['extension']); switch ($ext) { case "png": $im = imagecreatefrompng($image); header('Content-type: image/png'); imagepng($im); break; case "gif": $im = imagecreatefromgif($image); header('Content-type: image/gif'); //imagegif($im); echo file_get_contents($image); break; case "jpg": $im = imagecreatefromjpg($image); header('Content-type: image/jpg'); imagejpg($im); break; } imagedestroy($im); } } if ($movement != "") { if (file_exists($movement)) { $filecontents = file($movement); $i = 0; $maxx = $maxy = $maxz = $maxpitch = $maxroll = $maxyaw = 0.0; foreach ($filecontents as $line) { $line = trim($line); list($pi, $ro, $ya, $x, $y, $z) = preg_split('/\\s+/', $line);
public function drawDirectGraphic($xPos = 0, $yPos = 0, $graphic = '') { if (is_file($graphic)) { $graphic = file_get_contents($graphic); } $type = exif_imagetype($graphic); //1 IMAGETYPE_GIF //2 IMAGETYPE_JPEG //3 IMAGETYPE_PNG //4 IMAGETYPE_SWF //5 IMAGETYPE_PSD //6 IMAGETYPE_BMP //7 IMAGETYPE_TIFF_II (intel byte order) //8 IMAGETYPE_TIFF_MM (motorola byte order) //9 IMAGETYPE_JPC //10 IMAGETYPE_JP2 //11 IMAGETYPE_JPX //12 IMAGETYPE_JB2 //13 IMAGETYPE_SWC //14 IMAGETYPE_IFF //15 IMAGETYPE_WBMP //16 IMAGETYPE_XBM switch ($type) { case 1: $image = imagecreatefromgif($graphic); break; case 2: $image = imagecreatefromjpg($graphic); break; case 3: $image = imagecreatefrompng($graphic); break; case 4: break; case 5: break; case 6: $image = imagecreatefrombmp($graphic); break; default: $image = null; } if (!isset($image)) { return ''; } $width = imagesx($image); $heigth = imagesy($image); //Multiply the width in bytes (p3) by the number of print lines (p4) //for the total amount of graphic data $len = strlen($graphic); $calc = $width / 8 * $heigth; if ($len != $calc) { echo "ERRRO"; exit; } $command = 'GW' . self::zMm2dots($xPos) . ',' . self::zMm2dots($yPos) . ',' . $width / 8 . ',' . $heigth . ',' . $graphic . self::CRLF; $this->device->buffer .= $command; return $command; }