$imgMenor = @$values[5] ? $values[5] : false;
 $limitName = 100;
 $pastaDestino = '../../../imagens/fotos/';
 $imageTemp = $pastaDestino . '_temp/' . $img['imagem'];
 $thumbTemp = $pastaDestino . '_temp/thumbs/' . $img['imagem'];
 $animal = mysql_fetch_assoc(mysql_query("SELECT * FROM `animais` WHERE `id` = '{$idanimal}' LIMIT 1"));
 $newName = $animal['nome'] . '_' . $animal['cientifico'] . '_' . $animal['maisnomes'];
 $newName = Strings::stringToUrl($newName);
 $newName = strtolower(substr($newName, 0, $limitName - 8) . '.' . $extensao);
 $newName = NWD::autoRename($pastaDestino . 'imgs', $newName);
 $altaOutput = $pastaDestino . 'alta/' . $newName;
 $imageOutput = $pastaDestino . 'imgs/' . $newName;
 $thumbOutput = $pastaDestino . 'thumbs/' . $newName;
 $copy = copy($imageTemp, $altaOutput);
 $imagem = NwdGD::imgResize($altaOutput, $imageOutput, $values[0], $values[1], $values[2], $corBg, $imgQualidade, $imgMenor);
 $thumb = NwdGD::imgResize($altaOutput, $thumbOutput, $values[6], $values[7], $values[8], $corBg, $imgQualidade, $imgMenor);
 if ($imagem != false) {
     $lastPos = mysql_fetch_assoc(mysql_query("SELECT `pos` FROM `fotos` WHERE `id_animal` = '{$idanimal}' ORDER BY `pos` DESC LIMIT 1"));
     $pos = $lastPos['pos'] + 1;
     $data = implode('-', array_reverse(explode('/', $data))) . ' ' . $time;
     $insert = mysql_query("INSERT INTO `fotos` (`pos`, `id_animal`, `id_cidade`, `id_autor`, `imagem`, `data`, `tecnica`, `descricao`, `ativo`) \n\t\t\t\t\t\t\t\t\t\t\t\t\tVALUES ('{$pos}', '{$idanimal}', '{$cidade}', '{$idautor}', '{$newName}', '{$data}', '{$tecnica}', '{$descricao}', '1')");
 }
 if (@$insert) {
     if (@$tempClear) {
         $clear = mysql_query("DELETE FROM fotos_temp WHERE id = '{$idItem}' LIMIT 1");
         @unlink($imageTemp);
         @unlink($thumbTemp);
     } else {
         $clear = mysql_query("UPDATE `fotos_temp` SET `id_publicado` = '" . mysql_insert_id() . "' WHERE `id` = '{$idItem}' LIMIT 1");
     }
     if ($clear) {
示例#2
0
<?php

require_once '../libs/NWD/NwdGD.2.class.php';
$file = $_FILES['foto_field'];
$imgName = $file['name'];
$extensao = strtolower(strrchr($imgName, '.'));
$anexoNb = $_POST['anexoNb'];
if (strstr('*.jpg;*.jpeg;*.gif;*.png', $extensao)) {
    //if($anexoNb == '01'){ $imgName = 'PRINCIPAL_'.$imgName; }
    $nImageName = preg_replace('/[^a-z0-9.]/i', '_', utf8_decode($imgName));
    if (move_uploaded_file($file['tmp_name'], '../_temp/' . $nImageName)) {
        NwdGD::imgResize('../_temp/' . $nImageName, '../_temp/' . $nImageName, 800, 600, 'proporc', 'ffffff', 100, true);
        echo '<script>window.top.window.finishUploadImages02(\'' . $nImageName . '\')</script>';
    }
}
 public static function copyResize($file, $pastaDestino, $values, $limitName = 20, $imgName = '', $watermark = '')
 {
     $result = false;
     if (is_file($file)) {
         $largImg = $values[0];
         $altImg = $values[1];
         $imgProporc = $values[2];
         $corBg = @$values[3] ? $values[3] : 'ffffff';
         $imgQualidade = @$values[4] ? $values[4] : 100;
         $imgMenor = @$values[5] ? $values[5] : false;
         $largThumb = @$values[6];
         $altThumb = @$values[7];
         $thumbProporc = @$values[8];
         $geraThumb = $largThumb && $altThumb && $thumbProporc ? true : false;
         // se possuir todas as especificações, gera a miniatura
         $fileName = basename($file);
         $extensao = strtolower(strrchr($fileName, '.'));
         if (strstr('*.jpg;*.jpeg;*.gif;*.png', $extensao)) {
             $newName = $imgName ? $imgName : str_replace($extensao, '', $fileName);
             $newName = Strings::stringToUrl($newName);
             $newName = strtolower(substr($newName, 0, $limitName - 8) . $extensao);
             $newName = NwdGD::autoRename($pastaDestino, $newName);
             if (!is_dir('_temp')) {
                 mkdir('_temp', 0755);
                 sleep(1);
             }
             $imageOutput = $pastaDestino . $newName;
             $imageResize = NwdGD::imgResize($file, $imageOutput, $largImg, $altImg, $imgProporc, $corBg, $imgQualidade, $imgMenor, $watermark);
             if ($geraThumb) {
                 if (!is_dir($pastaDestino . 'thumbs')) {
                     mkdir($pastaDestino . 'thumbs', 0755);
                 }
                 $thumbOutput = $pastaDestino . 'thumbs/' . $newName;
                 $thumbResize = NwdGD::imgResize($file, $thumbOutput, $largThumb, $altThumb, $thumbProporc, $corBg, $imgQualidade, $imgMenor);
             }
             if ($imageResize) {
                 $result = $newName;
             }
         }
     }
     return $result;
 }