示例#1
0
 public function getSubirfoto($idPersona)
 {
     if (!Input::hasFile('file')) {
         return Response::json(array('error' => 'No hay ningun archivo'), 400);
     }
     $persona = Persona::findOrFail($idPersona);
     $file = Input::file('file');
     if (!in_array(strtolower($file->getClientOriginalExtension()), Persona::$extensionesImagenes)) {
         return Response::json(array('mensaje' => 'Archivo no permitido'), 400);
     }
     if ($file->getSize() > 1048576) {
         return Response::json(array('mensaje' => 'Archivo demasiado pesado, no puede superar 1MB de tamaño'), 400);
     }
     $fileName = 'Foto.' . $file->getClientOriginalExtension();
     $base_path = 'documentos' . DIRECTORY_SEPARATOR . 'PER' . $persona->id;
     $file->move($base_path, $fileName);
     $foto = PHPImageWorkshop\ImageWorkshop::initFromPath($base_path . DIRECTORY_SEPARATOR . $fileName);
     $foto->cropMaximumInPixel(0, 0, "MM");
     $foto->resizeInPixel(160, 160);
     $foto->save($base_path, $fileName);
     if ($persona->foto != "") {
         File::delete($base_path . $persona->foto);
     }
     $persona->foto = $fileName;
     $persona->save();
     return Response::json(array('url' => url($base_path . DIRECTORY_SEPARATOR . $fileName)));
 }
示例#2
0
 public function store()
 {
     $file = Input::file('uploader');
     $destinationPath = app_path() . '/storage/uploads/';
     $filename = $file->getClientOriginalName();
     $destinationPath = app_path() . '/storage/uploads/';
     $filename = $file->getClientOriginalName();
     $file->move($destinationPath, $filename);
     if (exif_imagetype($destinationPath . $filename) == 2) {
         $layer = PHPImageWorkshop\ImageWorkshop::initFromPath($destinationPath . $filename);
         $exif = exif_read_data($destinationPath . $filename);
         if (isset($exif['Orientation']) && $exif['Orientation'] == '6') {
             $layer->rotate(90);
         }
         if (isset($exif['Orientation']) && $exif['Orientation'] == '3') {
             $layer->rotate(180);
         }
         $layer->save($destinationPath, $filename, false, null, 95);
     }
     if (ImageModel::getImgTypeByExtension($filename) == ImageModel::IMGTYPE_PDF) {
         return array();
     }
     list($width, $height, $type, $attr) = getimagesize($destinationPath . $filename);
     if ($width < 500 || $height < 500 || filesize($destinationPath . $filename) > 5242880) {
         return array('error' => "Picture width and height must be at least 500px. Please select a larger image or limit the photo size to 5MB.");
     } else {
         return array();
     }
 }
示例#3
0
 /**
  *
  * @param type $image
  * @return type
  */
 private static function imagemExtrairCamadaDoRecurso($image)
 {
     return PHPImageWorkshop\ImageWorkshop::initFromResourceVar($image);
 }
示例#4
0
文件: img.php 项目: vsk-d/Watermark
	$quality   = 100;               // качество изображения создаваемого коллажа
*/
// Создание базового слоя с фоном
if (isset($_POST)) {
    $mainLayer = PHPImageWorkshop\ImageWorkshop::initFromPath($uploadDir . $_SESSION['main-image']);
    $width = $mainLayer->getWidth();
    $height = $mainLayer->getHeight();
    if ($width > $primary_width or $heiht > $primary_height) {
        if ($width >= $height) {
            $mainLayer->resizeInPixel($primary_width, null, true);
        } else {
            $mainLayer->resizeInPixel(null, $primary_height, true);
        }
    }
    // Создание слоя с первым изображением
    $imageLayer1 = PHPImageWorkshop\ImageWorkshop::initFromPath($uploadDir . $_SESSION['water-image']);
    $imageLayer1->opacity($_POST['opacity']);
    if ($_POST['single-mod'] == 1) {
        $mainLayer->addLayerOnTop($imageLayer1, $_POST['axis-x'], $_POST['axis-y'], "LT");
    } else {
        $x = $_POST['axis-x'];
        $y = $_POST['axis-y'];
        $width_w = $imageLayer1->getWidth();
        $height_w = $imageLayer1->getHeight();
        $axis_width = $_POST['axis-width'];
        $axis_height = $_POST['axis-height'];
        while ($y < $height) {
            while ($x < $width) {
                $mainLayer->addLayerOnTop($imageLayer1, $x, $y, "LT");
                $x = $x + ($width_w + $axis_width);
            }
示例#5
0
$imageQuality = 100;
// useless for GIF, usefull for PNG and JPEG (0 to 100%)
$mainLayer = PHPImageWorkshop\ImageWorkshop::initFromPath($file['tmp_name'][0]);
$width = $mainLayer->getWidth();
$height = $mainLayer->getHeight();
if ($_POST['type'] == 'main-image') {
    if ($width > $primary_width or $heiht > $primary_height) {
        if ($width >= $height) {
            $mainLayer->resizeInPixel($primary_width, null, true);
        } else {
            $mainLayer->resizeInPixel(null, $primary_height, true);
        }
    }
} else {
    if (isset($_SESSION['main-image'])) {
        $basicLayer = PHPImageWorkshop\ImageWorkshop::initFromPath($uploadDir . $_SESSION['main-image']);
        $basic_width = $basicLayer->getWidth();
        $basic_height = $basicLayer->getHeight();
        if ($width > $basic_width or $height > $basic_height) {
            if ($width > $basic_width / $basic_height * $height) {
                if ($width > $basic_width) {
                    $k = $width / $basic_width;
                    $width = $basic_width;
                    $height = $height / $k;
                }
            } else {
                if ($height > $basic_height) {
                    $k = $height / $basic_height;
                    $height = $basic_height;
                    $width = $width / $k;
                }
示例#6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $service = Service::find($id);
     $file = Input::file('image');
     // your file upload input field in the form should be named 'file'
     $destinationPath = public_path() . '/uploads';
     $filename = $file->getClientOriginalName();
     //$extension =$file->getClientOriginalExtension(); //if you need extension of the file
     $uploadSuccess = Input::file('image')->move($destinationPath, $filename);
     $RandNumber = rand(0, 9999999999.0);
     if ($uploadSuccess) {
         require_once 'PHPImageWorkshop/ImageWorkshop.php';
         chmod($destinationPath . "/" . $filename, 0777);
         $layer = PHPImageWorkshop\ImageWorkshop::initFromPath(public_path() . '/uploads/' . $filename);
         unlink(public_path() . '/uploads/' . $filename);
         $layer->resizeInPixel(400, null, true);
         $layer->applyFilter(IMG_FILTER_CONTRAST, -16, null, null, null, true);
         $layer->applyFilter(IMG_FILTER_BRIGHTNESS, 9, null, null, null, true);
         $dirPath = public_path() . '/uploads/' . "service";
         $filename = "_" . $RandNumber . ".png";
         $createFolders = true;
         $backgroundColor = null;
         // transparent, only for PNG (otherwise it will be white if set null)
         $imageQuality = 100;
         // useless for GIF, usefull for PNG and JPEG (0 to 100%)
         $layer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
         chmod($dirPath . "/" . $filename, 0777);
     }
     //connect & insert file record in database
     $service->image = $filename;
     $service->name = Input::get('name');
     $service->descriptions = Input::get('descriptions');
     $service->save();
 }
示例#7
0
 /**
  * Action to serve an error image
  */
 public function error_on_image()
 {
     $err = intval($this->EE->input->get('err'));
     if ($err > 0 && $this->EE->config->item('wda_img_debug') == 'y' && isset($this->errors[$err])) {
         $width = intval($this->EE->input->get('w'));
         $height = intval($this->EE->input->get('h'));
         if ($width == 0) {
             $width = 100;
         }
         if ($height == 0) {
             $height = 100;
         }
         $error_string = $this->errors[$err];
         $img = new \PHPImageWorkshop\ImageWorkshop(array('width' => $width, 'height' => $height));
         $textLayer = new \PHPImageWorkshop\ImageWorkshop(array("text" => $error_string, "fontSize" => 22, "fontColor" => "000000", "width" => $width, "height" => $height));
         $img->addLayer(1, $textLayer, 10, 10, 'LB');
         $image = $img->getResult();
         header('Content-type: image/jpeg');
         imagejpeg($image, null, 95);
     }
 }