static function Thumbnail($image_file, $thumb_file, $width = 48, $height = 48) { $ctype = FSS_Helper::datei_mime("png"); // thumb file exists if (file_exists($thumb_file) && filesize($thumb_file) > 0) { header("Content-Type: " . $ctype); header('Cache-control: max-age=' . 60 * 60 * 24 * 365); header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365)); @readfile($thumb_file); exit; } require_once JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'helper' . DS . 'third' . DS . 'simpleimage.php'; $im = new SimpleImage(); $im->load($image_file); if (!$im->image) { // return a blank thumbnail of some sort! $im->load(JPATH_SITE . DS . 'components' . DS . 'com_fss' . DS . 'assets' . DS . 'images' . DS . 'blank_16.png'); } $im->resize($width, $height); $im->output(); $im_data = ob_get_clean(); if (strlen($im_data) > 0) { // if so use JFile to write the thumbnail image JFile::write($thumb_file, $im_data); } else { // it failed for some reason, try doing a direct write of the thumbnail $im->save($thumb_file); } header('Cache-control: max-age=' . 60 * 60 * 24 * 365); header('Expires: ' . gmdate(DATE_RFC1123, time() + 60 * 60 * 24 * 365)); header("Content-Type: " . $ctype); if (file_exists($thumb_file && filesize($thumb_file) > 0)) { @readfile($thumb_file); } else { $im->output(); } exit; }
public function get_file($modelID = '', $id = '', $filetype = '', $filename = '') { if ($id != '') { $fileinfo = $this->file_model->get_fileinfo($modelID, $id, $filetype); if ($fileinfo['Status']) { if (file_exists(absolute_path() . APPPATH . 'files/' . $fileinfo['LocalFileName'])) { switch (strtolower($filetype)) { case "thumbnails": $size = explode('_', $filename); if (!is_numeric($size[0]) or $size[0] <= 0) { show_404(); } if (!is_numeric($size[1]) or $size[0] <= 0) { show_404(); } $img = new SimpleImage(); $img->load(absolute_path() . APPPATH . 'files/' . $fileinfo['LocalFileName'])->best_fit($size[0], $size[1]); $img->output('jpg'); break; default: $mm_type = mime_content_type($fileinfo['FileName']); header('Content-Description: File Transfer'); header('Content-Type: ' . $mm_type); header('Content-Disposition: ' . $fileinfo['DispositionType'] . '; filename=' . basename($fileinfo['FileName'])); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize(APPPATH . 'files/' . $fileinfo['LocalFileName'])); ob_clean(); flush(); readfile(APPPATH . 'files/' . $fileinfo['LocalFileName']); } } } else { show_404(); } } else { show_404(); } }
<?php if (isset($_POST['submit'])) { ?> <?php include 'classSimpleImage.php'; $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(150); $image->output(); } else { ?> ?> <form action="upload.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_image" /> <input type="submit" name="submit" value="Upload" /> </form> <?php }
function thumbnail($img) { ob_end_clean(); header('Content-Type: image/png'); kernel::loadLib("simpleimage"); $image = new SimpleImage(); $image->load($img); $image->resizeToWidth(480); $image->output(); exit; }
$equipment = EquipmentDao::getEquipmentByID($_GET['equipId']); if (!$equipment) { $image = new SimpleImage(); $image->load("./images/notfound.png"); header('Content-Type: image/png'); echo $image->output(); Database::Close(); exit; } else { if (file_exists("./images/" . $equipment->picture)) { $image_info = getimagesize("./images/" . $equipment->picture); $image_type = $image_info[2]; if ($image_type == IMAGETYPE_JPEG) { header('Content-Type: image/jpeg'); } elseif ($image_type == IMAGETYPE_GIF) { header('Content-Type: image/gif'); } elseif ($image_type == IMAGETYPE_PNG) { header('Content-Type: image/png'); } echo file_get_contents("./images/" . $equipment->picture); } else { $image = new SimpleImage(); $image->load("./images/notfound.png"); header('Content-Type: image/png'); echo $image->output(); Database::Close(); exit; } } } Database::Close();
$id_personagem = intval($_POST['id_personagem']); $personagem = Personagem::pegar($id_personagem); if (array_key_exists('imagem_content', $_POST)) { $targ_w = $targ_h = 72; $jpeg_quality = 90; $img_r = imagecreatefromstring(base64_decode($_POST['imagem_content'])); $dst_r = ImageCreateTrueColor($targ_w, $targ_h); imagecopyresampled($dst_r, $img_r, 0, 0, $_POST['x'], $_POST['y'], $targ_w, $targ_h, $_POST['w'], $_POST['h']); $personagem->setImagem($dst_r); } elseif (array_key_exists('imagem_principal_url', $_POST) && $_POST['imagem_principal_url'] != '') { $imagem_content = file_get_contents($_POST['imagem_principal_url']); $regraImage = new SimpleImage(); $regraImage->image = imagecreatefromstring($imagem_content); $regraImage->resizeToWidth(400); ob_start(); $regraImage->output(IMAGETYPE_JPEG); $imagem_content = ob_get_contents(); ob_end_clean(); $imagem_content = base64_encode($imagem_content); } else { header("Location: personagem.php?personagem=" . $personagem->getId()); exit; } } require 'header.php'; ?> <form method="POST" onsubmit="return checkCoords();"> <input type="hidden" name="acao" value="gravar" /> <?php if (!is_null($imagem_content)) { ?>
public function exibeThumbnail($size = 20) { $query = "\n SELECT imagem\n FROM jogador\n WHERE id_jogador = '" . do_escape($this->id_jogador) . "'\n "; $base64 = get_value($query, 'imagem'); $image = new SimpleImage(); $image->image = imagecreatefromstring(base64_decode($base64)); $image->image_type = IMAGETYPE_JPEG; $image->resize($size, $size); header('content-type: image/jpeg'); $image->output(); exit; }
public function exibeThumbnail($size = 20) { $id_personagem = $this->id_personagem; if (!is_null($this->id_original)) { $id_personagem = $this->id_original; } $query = "\n SELECT foto\n FROM personagem\n WHERE id_personagem = '" . do_escape($id_personagem) . "'\n "; $base64 = get_value($query, 'foto'); $image = new SimpleImage(); $image->image = imagecreatefromstring(base64_decode($base64)); $image->image_type = IMAGETYPE_JPEG; $image->resize($size, $size); header('content-type: image/jpeg'); $image->output(); exit; }
} else { $mid = "ST"; $end = healthToState($health) . rand(0, 2); } } } } } } } $filename = "faces/" . $stub . $mid . $end . ".png"; $image = new SimpleImage(); $image->load($filename); if ($scale >= 5) { $image->scale($scale); } else { if ($width != "" && $height != "") { $image->resize($width, $height); } else { if ($width != "") { $image->resizeToWidth($width); } else { if ($height != "") { $image->resizeToHeight($height); } } } } header('Content-Type: image/png'); $image->output(IMAGETYPE_PNG);
function getImageData($name, $maxHeight = 300, $maxWidth = 300) { if (!defined('MAX_FILE_SIZE')) { define('MAX_FILE_SIZE', 1024 * 500); } $imageid = 0; // make sure it's a genuine file upload if (is_uploaded_file($_FILES[$name]['tmp_name'])) { // replace any spaces in original filename with underscores $filename = str_replace(' ', '_', $_FILES[$name]['name']); // get the MIME type $mimetype = $_FILES[$name]['type']; if ($mimetype == 'image/pjpeg') { $mimetype = 'image/jpeg'; } // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/png', 'image/x-png'); // upload if file is OK if (in_array($mimetype, $permitted)) { switch ($_FILES[$name]['error']) { case 0: // get the file contents // Temporary file name stored on the server // $tmpName = $_FILES[$name]['tmp_name']; // // // Read the file // $fp = fopen($tmpName, 'r'); // $image = fread($fp, filesize($tmpName)); // fclose($fp); // get the width and height $size = getimagesize($_FILES[$name]['tmp_name']); $width = $size[0]; $height = $size[1]; if ($width > $maxWidth || $height > $maxHeight) { $image = new SimpleImage(); $image->load($_FILES[$name]['tmp_name']); if ($width - $maxWidth > $height - $maxHeight) { $image->resizeToWidth($maxWidth); } else { $image->resizeToHeight($maxHeight); } ob_start(); $image->output(); $binimage = ob_get_clean(); } else { $binimage = file_get_contents($_FILES[$name]['tmp_name']); } $image = mysql_real_escape_string($binimage); $filename = mysql_escape_string($_FILES[$name]['name']); $description = mysql_escape_string($_POST['description']); $result = mysql_query("INSERT INTO {$_SESSION['DB_PREFIX']}images " . "(description, name, mimetype, image, imgwidth, imgheight, metacreateddate, metacreateduserid, metamodifieddate, metamodifieduserid) " . "VALUES " . "('{$description}', '{$filename}', '{$mimetype}', '{$image}', {$width}, {$height}, NOW(), " . getLoggedOnMemberID() . ", NOW(), " . getLoggedOnMemberID() . ")"); if (!$result) { throw new Exception("Cannot persist image data ['{$filename}']:" . mysql_error()); } $imageid = mysql_insert_id(); break; case 3: case 6: case 7: case 8: throw new Exception("Error uploading {$filename}. Please try again."); break; case 4: throw new Exception("You didn't select a file to be uploaded."); } } else { throw new Exception("{$filename} is not an image."); } } return $imageid; }