thumbnail() 공개 메소드

This function attempts to get the image to as close to the provided dimensions as possible, and then crops the remaining overflow (from the center) to get the image to be the size specified. Useful for generating thumbnails.
public thumbnail ( integer $width, integer | null $height = null ) : SimpleImage
$width integer
$height integer | null If omitted - assumed equal to $width
리턴 SimpleImage
예제 #1
0
파일: index.php 프로젝트: salomay/refreshin
         $imgx->load($src_img);
         #-- check orientation ------------
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 3:
                     $imgx->rotate(180);
                     break;
                 case 6:
                     $imgx->rotate(90);
                     break;
                 case 8:
                     $imgx->rotate(-90);
                     break;
             }
         }
         $imgx->thumbnail(500, 300);
         $imgx->save($app['data_path'] . "/konfig/gmb_header_" . $id . ".jpg");
         $data['gmb_header'] = "gmb_header_" . $id . ".jpg";
     } catch (Exception $e) {
         $_SESSION['msg'] = "gambar header gagal di unggah/upload ....";
         $_SESSION['alt'] = "warning";
         header("location: " . $urlx->get_referer());
         exit;
     }
 }
 $appx->mq_encode('p_headline,p_slogan');
 $sql = "update " . $app['table']["konfig_bahasa"] . "\n\t\t\t\tset headline = '{$p_headline}', \n\t\t\t\t    id_bahasa = '{$p_bahasa}',\n\t\t\t\t    slogan = '{$p_slogan}',\n\t\t\t\t\tmeta_description = '{$p_metades}',\n\t\t\t\t\tmeta_keyword = '{$p_metakey}',\n\t\t\t\t\tgmb_header  = '{$data['gmb_header']}',\n\t\t\t\t\ttgl_modif = now()\n\t\t\t\twhere id = '{$p_id}'";
 // echo $sql;exit;
 $dbu->qry($sql);
 $_SESSION['msg'] = "Data Provinsi {$p_nama} Berhasil Di Update ....";
 $_SESSION['alt'] = "success";
예제 #2
0
 /**
  * Загрузка фото в профиль
  */
 public function image()
 {
     if (!Request::ajax() || !User::check()) {
         App::redirect('/');
     }
     // Удаление и размер
     $image = Request::file('image');
     if ($image->isValid()) {
         $ext = $image->getClientOriginalExtension();
         if (in_array($ext, ['jpeg', 'jpg', 'png', 'gif'])) {
             $filename = uniqid(mt_rand()) . '.' . $ext;
             $user = User::get();
             $user->deleteImages();
             $img = new SimpleImage($image->getPathName());
             $img->best_fit(1280, 1280)->save('uploads/users/photos/' . $filename);
             $img->best_fit(200, 200)->save('uploads/users/thumbs/' . $filename);
             $img->thumbnail(48, 48)->save('uploads/users/avatars/' . $filename);
             $user->avatar = $filename;
             if ($user->save()) {
                 exit(json_encode(['status' => 'uploaded']));
             } else {
                 exit(json_encode(['status' => 'nosave']));
             }
         } else {
             exit(json_encode(['status' => 'invalid']));
         }
     }
 }
예제 #3
0
파일: index.php 프로젝트: salomay/refreshin
         $imgx->load($src_img);
         #-- check orientation ------------
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 3:
                     $imgx->rotate(180);
                     break;
                 case 6:
                     $imgx->rotate(90);
                     break;
                 case 8:
                     $imgx->rotate(-90);
                     break;
             }
         }
         $imgx->thumbnail(55, 55);
         $imgx->save($app['data_path'] . "/berita/icon/icon_" . $id . ".png");
         $data['icon'] = "icon_" . $id . ".png";
     } catch (Exception $e) {
         $_SESSION['msg'] = "icon kategori {$p_kategori} gagal di unggah/upload ....";
         $_SESSION['alt'] = "warning";
         header("location: " . $urlx->get_referer());
         exit;
     }
 }
 /*
 		//---- nearby icon
 		$data[nicon]= $dbu->lookup("nicon","berita_kategori","id='".$p_id."'");
 			if ($p_nicon_size){
 				$id = rand(1, 100).date("dmYHis");
 				
예제 #4
0
파일: index.php 프로젝트: salomay/refreshin
         $imgx->load($src_img);
         #-- check orientation ------------
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 3:
                     $imgx->rotate(180);
                     break;
                 case 6:
                     $imgx->rotate(90);
                     break;
                 case 8:
                     $imgx->rotate(-90);
                     break;
             }
         }
         $imgx->thumbnail(100, 100);
         $imgx->save($app['data_path'] . "/berita/gambar/gambar_" . $id . ".jpg");
         $data['gambar'] = "gambar_" . $id . ".jpg";
     } catch (Exception $e) {
         $_SESSION['msg'] = "gambar berita {$p_judul} gagal di unggah/upload ....";
         $_SESSION['alt'] = "warning";
         header("location: " . $urlx->get_referer());
         exit;
     }
 }
 $appx->mq_encode('p_judul,p_desk,p_sinopsis');
 $sql = "update " . $app[table][berita_bahasa] . " a join " . $app[table][berita] . " b on a.id_berita=b.id\n\t\t\t\tset b.id_kat = '" . $p_kat . "',\n\t\t\t\t    a.judul = '" . $p_judul . "',\n\t\t\t\t    a.sinopsis = '" . $p_sinopsis . "',\n\t\t\t\t\ta.isi = '" . $p_desk . "',\n\t\t\t\t\tthumb  = '" . $data[thumb] . "',\n\t\t\t\t\tgambar  = '" . $data[gambar] . "',\n\t\t\t\t\tb.tgl_modif = now()\n\t\t\t\twhere a.id_berita = '" . $p_id . "'";
 // echo $sql;exit;
 $dbu->qry($sql);
 $_SESSION['msg'] = "Data destinasi {$p_judul} Berhasil Di Update ....";
 $_SESSION['alt'] = "success";
예제 #5
0
파일: index.php 프로젝트: salomay/refreshin
         $imgx->load($src_img);
         #-- check orientation ------------
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 3:
                     $imgx->rotate(180);
                     break;
                 case 6:
                     $imgx->rotate(90);
                     break;
                 case 8:
                     $imgx->rotate(-90);
                     break;
             }
         }
         $imgx->thumbnail(80, 80);
         $imgx->save($app['data_path'] . "/pengguna/avatar/avatar_" . $id . ".jpg");
         $data['avatar'] = "avatar_" . $id . ".jpg";
     } catch (Exception $e) {
         $_SESSION['msg'] = "Avatar Failed To Upload ....";
         $_SESSION['alt'] = "warning";
         header("location: " . $urlx->get_referer());
         exit;
     }
 }
 if ($p_id == $app['me']['id']) {
     $app['me']['id'] = $p_username;
 }
 $appx->mq_encode('p_username,p_name');
 $sql = "update " . $app['table']['pengguna'] . "\n\t\t\t\tset nama = '{$p_name}', \n\t\t\t\t    aplikasi = '{$application}',\n\t\t\t\t    username = '******',\n\t\t\t\t\temail = '{$p_email}',\n\t\t\t\t\tavatar  = '{$data['avatar']}',\n\t\t\t\t\tdibuat_oleh = '" . $app['me']['id'] . "',\n\t\t\t\t\ttgl_modif = now()\n\t\t\t\twhere id = '{$p_id}'";
 // echo $sql;exit;
예제 #6
0
파일: index.php 프로젝트: salomay/refreshin
         $imgx->load($src_img);
         #-- check orientation ------------
         if (!empty($exif['Orientation'])) {
             switch ($exif['Orientation']) {
                 case 3:
                     $imgx->rotate(180);
                     break;
                 case 6:
                     $imgx->rotate(90);
                     break;
                 case 8:
                     $imgx->rotate(-90);
                     break;
             }
         }
         $imgx->thumbnail(320, 320);
         $imgx->save($app['data_path'] . "/komunitas/logo/logo_" . $id . ".png");
         $data['logo'] = "logo_" . $id . ".png";
     } catch (Exception $e) {
         $_SESSION['msg'] = "logo komunitas {$p_nama} gagal di unggah/upload ....";
         $_SESSION['alt'] = "warning";
         header("location: " . $urlx->get_referer());
         exit;
     }
 }
 $appx->mq_encode('p_nama,p_lokasi');
 $sql = "update " . $app['table']["komunitas"] . "\n\t\t\t\tset id_kota = '{$p_destinasi}', \n\t\t\t\t    id_user = '******',\n\t\t\t\t    nama = '" . $p_nama . "',\n\t\t\t\t    lokasi = '" . $p_lokasi . "',\n\t\t\t\t    logo ='" . $data[logo] . "',\n\t\t\t\t    tgl_modif =now()    \n\t\t\t\twhere id = '{$p_id}'";
 // echo $sql;exit;
 $dbu->qry($sql);
 $_SESSION['msg'] = "Data omunitas Berhasil Di Update ....";
 $_SESSION['alt'] = "success";
예제 #7
0
<?php

require_once 'class/SimpleImage.class.php';
$sampleImage = 'image/sample3.jpg';
if (file_exists($sampleImage)) {
    $sImage = new SimpleImage();
    $sImage->load($sampleImage);
    $sImage->rotateDegrees = (int) $_GET['r'];
    //        $sImage->resize(350);  //  800px width
    //        $sImage->resize(null, 350);  //  800px width
    //        $sImage->resize(350, 350);  //  800px width
    //        $sImage->thumbnail(120);
    //        $sImage->thumbnail(null,120);
    $sImage->thumbnail(120, 120);
    $sR = $sImage->saveThumbnail('image/resized.jpg');
    $error = $sImage->error();
    var_dump($error);
}