コード例 #1
0
 /**
  * Add a Water Mark to the image
  * (filigrana)
  *
  * @param string $from
  * @param string $waterMark
  */
 public function addWaterMarkImage($waterMark, $opacity = 35, $x = 5, $y = 5)
 {
     // set data
     $size = $this->info;
     $im = $this->gdID;
     // set WaterMark's data
     $waterMarkSM = new SmartImage($waterMark);
     $imWM = $waterMarkSM->getGDid();
     // Add it!
     // In png watermark images we ignore the opacity (you have to set it in the watermark image)
     if ($waterMarkSM->info[2] == 3) {
         imageCopy($im, $imWM, $x, $y, 0, 0, imagesx($imWM), imagesy($imWM));
     } else {
         imageCopyMerge($im, $imWM, $x, $y, 0, 0, imagesx($imWM), imagesy($imWM), $opacity);
     }
     $waterMarkSM->close();
     $this->gdID = $im;
 }
コード例 #2
0
ファイル: albums.admin.php プロジェクト: billcreswell/plucke
function albums_page_admin_editalbum()
{
    global $cont1, $cont2, $cont3, $lang, $var1;
    //Let's process the image...
    if (isset($_POST['submit'])) {
        //If file is jpeg, pjpeg, png or gif: Accept.
        if (in_array($_FILES['imagefile']['type'], array('image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'))) {
            //Define some variables
            $extpos = strrpos($_FILES['imagefile']['name'], '.');
            if ($extpos === false) {
                $extpos = strlen($_FILES['imagefile']['name']);
            }
            $image_filename = substr($_FILES['imagefile']['name'], 0, $extpos);
            $ext = substr($_FILES['imagefile']['name'], $extpos + 1);
            $image_filename = seo_url($image_filename);
            $fullimage = ALBUMS_DIR . '/' . $var1 . '/' . $image_filename . '.' . strtolower($ext);
            $thumbimage = ALBUMS_DIR . '/' . $var1 . '/thumb/' . $image_filename . '.' . strtolower($ext);
            //Check if the image name already exists.
            $images = read_dir_contents(ALBUMS_DIR . '/' . $var1 . '/thumb', 'files');
            if ($images) {
                foreach ($images as $image) {
                    $extpos = strrpos($image, '.');
                    if ($extpos === false) {
                        $extpos = strlen($image);
                    }
                    $namepart = substr($image, 0, $extpos);
                    if ($namepart == $image_filename) {
                        $name_exist = true;
                        break;
                    }
                }
            }
            //Don't do anything, if the name already exists.
            if (isset($name_exist)) {
                $error = show_error($lang['albums']['image_exist'], 1, true);
            } elseif (!copy($_FILES['imagefile']['tmp_name'], $fullimage) || !copy($_FILES['imagefile']['tmp_name'], $thumbimage)) {
                $error = show_error($lang['general']['upload_failed'], 1, true);
            } else {
                //Compress the big image.
                $image_width = module_get_setting('albums', 'resize_image_width');
                $image = new SmartImage($fullimage);
                //Only resize if resize_image_width is not disabled (or set to 1, which would produce errors).
                if ($image_width != '0' && $image_width != '1') {
                    list($width, $height) = getimagesize($fullimage);
                    $imgratio = $width / $height;
                    if ($imgratio > 1) {
                        $newwidth = $image_width;
                        $newheight = $image_width / $imgratio;
                    } else {
                        $newheight = $image_width;
                        $newwidth = $image_width * $imgratio;
                    }
                    $image->resize($newwidth, $newheight);
                }
                $image->saveImage($fullimage, $cont3);
                $image->close();
                chmod($fullimage, 0777);
                //Then make a thumb from the image.
                $thumb_width = module_get_setting('albums', 'resize_thumb_width');
                //If resize_thumb_width is set to 0 or 1, we need to grab the default width (otherwise it would produce errors).
                if ($thumb_width == '0' || $thumb_width == '1') {
                    $albums_default_settings = albums_settings_default();
                    $thumb_width = $albums_default_settings['resize_thumb_width'];
                }
                //Resize thumb.
                $thumb = new SmartImage($thumbimage);
                list($width, $height) = getimagesize($thumbimage);
                $imgratio = $width / $height;
                if ($imgratio > 1) {
                    $newwidth = $thumb_width;
                    $newheight = $thumb_width / $imgratio;
                } else {
                    $newheight = $thumb_width;
                    $newwidth = $thumb_width * $imgratio;
                }
                $thumb->resize($newwidth, $newheight);
                $thumb->saveImage($thumbimage, $cont3);
                $thumb->close();
                chmod($thumbimage, 0777);
                //Find the number.
                $images = read_dir_contents(ALBUMS_DIR . '/' . $var1 . '/thumb', 'files');
                if ($images) {
                    $number = count($images);
                } else {
                    $number = 1;
                }
                //Sanitize data.
                $cont1 = sanitize($cont1);
                $cont2 = sanitize($cont2);
                $cont2 = nl2br($cont2);
                //Compose the data.
                $data['name'] = $cont1;
                $data['info'] = $cont2;
                //Then save the image information.
                save_file(ALBUMS_DIR . '/' . $var1 . '/' . $number . '.' . $image_filename . '.' . strtolower($ext) . '.php', $data);
            }
        } else {
            //FIXME: Maybe a better error message?
            $error = show_error($lang['general']['upload_failed'], 1, true);
        }
    }
    //Check if album exists.
    if (file_exists(ALBUMS_DIR . '/' . $var1)) {
        //Introduction text.
        ?>
			<p>
				<strong><?php 
        echo $lang['albums']['album_message1'];
        ?>
</strong>
			</p>
			<p>
				<span class="kop2"><?php 
        echo $lang['albums']['new_image'];
        ?>
</span>
				<span class="kop4"><?php 
        echo $lang['albums']['album_message2'];
        ?>
</span>
			</p>
			<?php 
        if (isset($error)) {
            echo $error;
        }
        ?>
			<form method="post" action="" enctype="multipart/form-data">
				<p>
					<label class="kop2" for="cont1"><?php 
        echo $lang['general']['title'];
        ?>
</label>
					<input required='required' name="cont1" id="cont1" type="text" />
				</p>
				<p>
					<label class="kop2" for="cont2"><?php 
        echo $lang['general']['description'];
        ?>
</label>
					<textarea required='required' cols="50" rows="5" name="cont2" id="cont2"></textarea>
				</p>
				<p>
					<input type="file" name="imagefile" id="imagefile" />
					<label class="kop4" for="cont3"><?php 
        echo $lang['albums']['quality'];
        ?>
</label>
					<input name="cont3" id="cont3" type="text" size="3" value="85" />
				</p>
				<input type="submit" name="submit" value="<?php 
        echo $lang['general']['save'];
        ?>
" />
			</form>
			<br />
		<?php 
        //Edit images.
        ?>
		<span class="kop2"><?php 
        echo $lang['albums']['edit_images'];
        ?>
</span>
		<?php 
        albums_admin_show_images($var1);
    }
    ?>
		<br />
		<p>
			<a href="?module=albums">&lt;&lt;&lt; <?php 
    echo $lang['general']['back'];
    ?>
</a>
		</p>
	<?php 
}
コード例 #3
0
ファイル: uploadImage.php プロジェクト: pezzabros/Loki
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * @author      Media Integration and Communication Center http://www.micc.unifi.it (Micc) <*****@*****.**>
 * @license     Apache License https://github.com/miccunifi/Loki/LICENSE.txt
 * @link        Official page and description: http://www.micc.unifi.it/vim/opensource/loki-a-cross-media-search-engine/
 *              GitHub Repository: https://github.com/miccunifi/Loki
 * 
*/
include 'SmartImage.class.php';
include '../config.php';
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if (in_array($extension, $allowedExts)) {
    if (isset($_FILES['file'])) {
        if ($_FILES["file"]["error"] > 0) {
            echo "Error";
        } else {
            $src = $_FILES["file"]["tmp_name"];
            $img = new SmartImage($src);
            $img->resize(200, 200, true);
            $src = '../img/temp/' . $_FILES["file"]["name"];
            $img->saveImage($src, 90);
            $avatar = $interfacePath . 'img/temp/' . $_FILES["file"]["name"];
            echo $avatar;
        }
    }
} else {
    echo "Error";
}
コード例 #4
0
ファイル: Process.php プロジェクト: naveengamage/okaydrive
 public function setimages($name, $path)
 {
     $file_name = $name;
     $full_path = '/home/mfs/Downloads/transmission/completed/' . $path;
     $file_path_thumb = '/opt/nginx/html/laravel/public/snaps/' . $file_name;
     if (file_exists($file_path_thumb)) {
         unlink($file_path_thumb);
     }
     try {
         $img = new SmartImage($full_path);
         $img->resize(130, 130, true);
         $img->saveImage($file_path_thumb, 85);
     } catch (Exception $e) {
         $full_path = '/home/mfs/Downloads/transmission/image.png';
         $img = new SmartImage($full_path);
         $img->saveImage($file_path_thumb, 85);
     }
 }
コード例 #5
0
                         case "image/png":
                             $extens = '.png';
                             break;
                     }
                 } else {
                     $errored = 1;
                     $txterror = $this->lang('global_post_txterror3') . ': ' . $images_post['name'][$i];
                     break;
                 }
                 $tmp_photos[] = $images_post['tmp_name'][$i];
                 $photos[] = $codep . '-' . $i . $extens;
             }
             if ($errored == 0) {
                 foreach ($photos as $key => $fname) {
                     move_uploaded_file($tmp_photos[$key], '../' . $C->FOLDER_PHOTOS . $fname);
                     $thumbnail = new SmartImage('../' . $C->FOLDER_PHOTOS . $fname, true);
                     $thumbnail->mycrop($C->widthPhotoThumbail, $C->widthPhotoThumbail, 'center');
                     $thumbnail->saveImage('../' . $C->FOLDER_PHOTOS . 'min1/' . $fname);
                     $thumbnail->close();
                 }
                 unset($mythumb);
                 $txttypeattach = 'photo';
             }
             $endtxtatach = implode(',', $photos);
         }
     }
     break;
 case 2:
     // is video attached
     if (!empty($txtvalueatach)) {
         if (substr($txtvalueatach, 0, 20) == "https://youtube.com/" || substr($txtvalueatach, 0, 24) == "https://www.youtube.com/" || substr($txtvalueatach, 0, 16) == "www.youtube.com/" || substr($txtvalueatach, 0, 12) == "youtube.com/" || substr($txtvalueatach, 0, 19) == "http://youtube.com/" || substr($txtvalueatach, 0, 23) == "http://www.youtube.com/" || substr($txtvalueatach, 0, 16) == "http://youtu.be/") {
     $finalphoto = $this->user->info->code . '.' . $ext[count($ext) - 1];
     $this->db1->query("UPDATE users SET cover='" . $finalphoto . "' WHERE iduser="******"1: " . $txtreturn;
         return;
     } else {
         $txtreturn = $this->lang('dashboard_mi_mcov_form_msg9');
         echo "0: " . $txtreturn;
         return;
     }
 } else {
     $txtreturn = $this->leng('dashboard_1_mi_form_mi_msg5');