function sum($a, $b) { if (scale($a) > 3 || scale($b) > 3) { throw new UnderflowException("Input scale exceeded"); } return $a + $b; }
$error2 = "file is too large"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { if ($HTTP_POST_FILES['file']['type'] != "image/pjpeg" && $HTTP_POST_FILES['file']['type'] != "image/jpeg") { $error2 = "This file type is not allowed"; unlink($HTTP_POST_FILES['file']['tmp_name']); // assign error message, remove uploaded file, redisplay form. } else { //File has passed all validation, copy it to the final destination and remove the temporary file: $filename = $HTTP_POST_FILES['file']['name']; copy($HTTP_POST_FILES['file']['tmp_name'], "images/{$id}.jpg"); unlink($HTTP_POST_FILES['file']['tmp_name']); require "functions/image_resize.php"; $img = "images/{$id}.jpg"; scale($img, '480', '360'); echo "The file {$filename} has been successfully uploaded!"; include "approval_email.php"; } } } } ?> <p> <?php $im = "images/approved/{$id}.jpg"; $im2 = getimagesize($im); $im = "https://www.benfund.com/images/approved/{$id}.jpg"; if (isset($im2[0])) { ?> <img SRC="<?php
// Translation cycle $transevents = array(); $tprev = 0; foreach ($events as $event) { $tdiff = $event['t'] - $tprev; $tprev = $event['t']; switch ($event['action']) { case 'mv': $transevents[] = "program.push(['\$(\\'#wrapmouse\\').css({left:" . scale($event['xc']) . ", top:" . scale($event['yc']) . "});', {$tdiff}]);"; break; case 'm-ent': case 'm-lev': $transevents[] = "program.push(['\$(\\'#inmsg\\').html(\\'" . ($event['action'] == 'm-ent' ? $event['xtra1'] : '') . "\\');', {$tdiff}]);"; break; case 'm-clk': $transevents[] = "program.push(['\$(\\'#wrapmouse\\').css({left:" . scale($event['xc']) . ", top:" . scale($event['yc']) . "});', {$tdiff}])"; $transevents[] = "program.push(['\$(\\'#inmsg\\').css(\\'color\\', \\'red\\');', 0])"; $transevents[] = "program.push(['\$(\\'#inmsg\\').html(\\'<" . $event['xtra1'] . "><br/>\\');', 0])"; $transevents[] = "program.push(['\$(\\'#wrapcursor\\').effect(\\'pulsate\\', {times:3}, 300);', 0])"; $transevents[] = "program.push(['\$(\\'#inmsg\\').css(\\'color\\', \\'black\\');', 301])"; break; } } // Final preparations. $c->common->addOnload(implode("\n", $transevents)); // |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| } else { $c->displayMsg("I did not receive an id for the record I'm supposed to play."); } /*
function main() { global $input; $matrix = get_indexed_matrix($input); complete_input_matrix($matrix); $result = compute_values($matrix); scale($result); print_result_vector($result, array_keys($input)); }
function create_album($id, $sizes) { global $params; $album_path = album_dir($id); if (is_dir(album_dir($id))) { //--Create configuration file if (!file_exists(album_dir($id) . "info.yml")) { // There could be more parameters if necessary $info_yaml = Spyc::YAMLDump(array('album_title' => $params['album'], 'album_description' => '')); if (!($fp = fopen(album_dir($id) . 'info.yml', 'a'))) { $params['flash'] = 'Album info file could not be created in <code>' . album_dir($id) . 'info.yml</code>.'; render('error'); } if (!fwrite($fp, $info_yaml)) { $params['flash'] = 'Could not write to file <code>' . album_dir($id) . 'info.yml</code>.'; render('error'); } fclose($fp); } $originals = get_images(album_dir($id)); //--Create ZIP-Archive to download //$zip = new PclZip('archive.zip'); foreach ($originals as $image) { $images[] = album_dir($id) . $image; } $zip = new PclZip(album_dir($id) . 'archive.zip'); $test = $zip->create($images, PCLZIP_OPT_REMOVE_ALL_PATH); if ($test == 0) { die("Error: " . $zip->errorInfo(true)); } //--Resize images foreach ($sizes as $size_name => $size_pixels) { $resized_album_path = album_dir($id, $size_name); if (!is_dir($resized_album_path)) { mkdir($resized_album_path, 0755); } foreach ($originals as $photo) { scale(album_dir($id) . $photo, "{$resized_album_path}/{$photo}", $size_pixels); } } } else { $params['flash'] = "Resizing the images in <code>{$album_path}</code> failed. Could there be a permission problem?"; render('error'); exit; } }
$res = imagecreatefromjpeg($src); break; case 3: $res = imagecreatefrompng($src); break; } return $res; } } } if (fsexists($src)) { $image = new Gmagick(); $image->readImage($src); $scale = array("tw" => $tw, "th" => $th, "w" => $image->getImageWidth(), "h" => $image->getImageHeight()); if ($tw > 0 && $th > 0) { $im = scale($scale); $image->resizeImage($im['w'], $im['h'], null, 1); $x = $y = 0; $im['w'] > $im['tw'] && ($x = ceil(($im['w'] - $im['tw']) / 3)); $im['h'] > $im['th'] && ($y = ceil(($im['h'] - $im['th']) / 3)); $image->cropImage($tw, $th, $x, $y); } else { empty($scale['th']) && ($scale['th'] = 9999999); $im = bitscale($scale); $image->resizeImage($im['w'], $im['h'], null, 1); } $expires = 31536000; header("Cache-Control: maxage=" . $expires); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME']) . ' GMT'); header('Expires: ' . gmdate('D, d M Y H:i:s', $_SERVER['REQUEST_TIME'] + $expires) . ' GMT'); $srcData = $image->current();
/** * * @param array $a A box group to transform * @param array $transforms the transforms from the database offx,offy,centroidx,centroidy,scalex,scaley,costheta,sintheta */ function applytransforms($a, $transforms) { $b = array(); $scale = array($transforms['scalex'], $transforms['scaley']); $offsetxy = array($transforms['offx'], $transforms['offy']); $centroid = array($transforms['centroidx'], $transforms['centroidy']); list($b['tlx'], $b['tly']) = validatepixel(rotate(false, scale($scale, offsetxy(array($a['tlx'], $a['tly']), $offsetxy), $centroid), $centroid, $transforms['costheta'], $transforms['sintheta']), $transforms['width'], $transforms['height']); list($b['brx'], $b['bry']) = validatepixel(rotate(false, scale($scale, offsetxy(array($a['brx'], $a['bry']), $offsetxy), $centroid), $centroid, $transforms['costheta'], $transforms['sintheta']), $transforms['width'], $transforms['height']); return $b; }