当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::destroy方法代码示例

本文整理汇总了PHP中Image::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::destroy方法的具体用法?PHP Image::destroy怎么用?PHP Image::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Image的用法示例。


在下文中一共展示了Image::destroy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: destroy

 /**
  * Remove the specified resource from storage.
  * DELETE /adminimages/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $file = Input::get('image');
     $path = public_path() . '/assets/uploads/img/';
     if (!File::delete($path . $file)) {
         Session::flash('flash_message', 'Error deleting image!');
     } else {
         Session::flash('flash_message', 'Image has been deleted');
     }
     //
     Image::destroy($id);
     return Redirect::route('admin.images');
 }
开发者ID:syafdia,项目名称:PAS,代码行数:20,代码来源:AdminImagesController.php

示例2: destroy

 public function destroy($projectId, $imageId)
 {
     $image = Image::find($imageId);
     $destinationPath = public_path() . '/uploads/images/';
     if ($image->project_id == $projectId) {
         if (Image::destroy($imageId)) {
             File::delete($destinationPath . $image->path);
             return Response::json(['alert' => Messages::$deleteSuccess . 'image']);
         } else {
             return Response::json(['alert' => Messages::$deleteFail . 'image'], 404);
         }
     }
 }
开发者ID:perinikhil,项目名称:rmm-backend,代码行数:13,代码来源:ImageController.php

示例3: benchmark

function benchmark($method)
{
    global $config, $file, $extension, $out, $count;
    $config['thumb_method'] = $method;
    printf("Method: %s\nThumbnailing %d times... ", $method, $count);
    $start = microtime(true);
    for ($i = 0; $i < $count; $i++) {
        $image = new Image($file, $extension);
        $thumb = $image->resize($config['thumb_ext'] ? $config['thumb_ext'] : $extension, $config['thumb_width'], $config['thumb_height']);
        $thumb->to($out);
        $thumb->_destroy();
        $image->destroy();
    }
    $end = microtime(true);
    printf("Took %.2f seconds (%.2f/second; %.2f ms)\n", $end - $start, $rate = $count / ($end - $start), 1000 / $rate);
    unlink($out);
}
开发者ID:0151n,项目名称:vichan,代码行数:17,代码来源:benchmark.php

示例4: handleUpload

 /**
  * Handles the uploading and image post-processing if needed.
  *
  * @param array $fd
  * @return array
  */
 protected function handleUpload(array $fd)
 {
     try {
         $uploader = new Uploader('media_file', $this->_zula->getDir('uploads') . '/media/' . $fd['cid'] . '/{CATEGORY}');
         $uploader->subDirectories()->allowedMime($this->allowedMime)->maxFileSize($this->_config->get('media/max_fs'))->extractArchives();
         $file = $uploader->getFile();
         if ($file->upload() === false) {
             throw new Media_Exception(t('Please select a file to upload'));
         }
         // Upload the thumbail image if one has been provided and resize it
         $thumbnailWH = $this->_config->get('media/thumb_dimension');
         $thumbUploader = new Uploader('media_thumb', $file->dirname);
         $thumbUploader->subDirectories(false)->allowImages();
         $thumbnail = $thumbUploader->getFile();
         if ($thumbnail->upload() !== false) {
             $thumbImage = new Image($thumbnail->path);
             $thumbImage->mime = 'image/png';
             $thumbImage->thumbnail($thumbnailWH, $thumbnailWH);
             // Remove the original uploaded file
             unlink($thumbnail->path);
         }
         /**
          * Get details of all the images (could have been an archive containing
          * multiple media files
          */
         $uploadedItems = array();
         while ($details = $file->getDetails()) {
             if (isset($details['path'])) {
                 // Get the directory name where the files are stored (just the name, not path)
                 $dirname = substr($details['dirname'], strrpos($details['dirname'], DIRECTORY_SEPARATOR) + 1);
                 /**
                  * Use uploaded thumbnail, or attempt to create one from the uploaded image
                  */
                 $thumbname = $details['filename'] . '_thumb.png';
                 if (isset($thumbImage)) {
                     $thumbImage->save($details['dirname'] . '/' . $thumbname, false);
                 } else {
                     if ($details['category'] == 'image') {
                         $tmpThumb = new Image($details['path']);
                         $tmpThumb->mime = 'image/png';
                         $tmpThumb->thumbnail($thumbnailWH, $thumbnailWH)->save($details['dirname'] . '/' . $thumbname);
                     } else {
                         unset($thumbname);
                     }
                 }
                 // Generate a title from the filename automatically
                 $title = str_replace(array('-', '_', '+'), ' ', pathinfo($details['name'], PATHINFO_FILENAME));
                 $uploadedItems[] = array('title' => trim(ucfirst(strtolower($title))), 'desc' => '', 'type' => $details['category'], 'file' => $dirname . '/' . $details['basename'], 'thumbnail' => isset($thumbname) ? $dirname . '/' . $thumbname : '');
             }
         }
         if (isset($thumbImage)) {
             $thumbImage->destroy();
         }
         return $uploadedItems;
     } catch (Uploader_NotEnabled $e) {
         $msg = t('Sorry, it appears file uploads are disabled within your PHP configuration');
     } catch (Uploader_MaxFileSize $e) {
         $msg = sprintf(t('Selected file exceeds the maximum allowed file size of %s'), zula_human_readable($e->getMessage()));
     } catch (Uploader_InvalidMime $e) {
         $msg = t('Sorry, the uploaded file is of the wrong file type');
     } catch (Uploader_Exception $e) {
         $logMsg = $e->getMessage();
         $msg = t('Oops, an error occurred while uploading your files');
     } catch (Image_Exception $e) {
         $logMsg = $e->getMessage();
         $msg = t('Oops, an error occurred while processing an image');
     }
     // Cleanup and end processing, it failed.
     if (isset($file->dirname)) {
         zula_full_rmdir($file->dirname);
     }
     if (isset($logMsg)) {
         $this->_log->message($logMsg, Log::L_WARNING);
     }
     throw new Media_Exception($msg);
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:82,代码来源:add.php

示例5: error

         $thumb->to($file['thumb']);
         $file['thumbwidth'] = $thumb->width;
         $file['thumbheight'] = $thumb->height;
         $thumb->_destroy();
     }
     if ($config['redraw_image'] || !@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg')) {
         if (!$config['redraw_image'] && $config['use_exiftool']) {
             if ($error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' . escapeshellarg($file['tmp_name']))) {
                 error(_('Could not strip EXIF metadata!'), null, $error);
             }
         } else {
             $image->to($file['file']);
             $dont_copy_file = true;
         }
     }
     $image->destroy();
 } else {
     // not an image
     //copy($config['file_thumb'], $post['thumb']);
     $file['thumb'] = 'file';
     $size = @getimagesize(sprintf($config['file_thumb'], isset($config['file_icons'][$file['extension']]) ? $config['file_icons'][$file['extension']] : $config['file_icons']['default']));
     $file['thumbwidth'] = $size[0];
     $file['thumbheight'] = $size[1];
 }
 if (!isset($dont_copy_file) || !$dont_copy_file) {
     if (isset($file['file_tmp'])) {
         if (!@rename($file['tmp_name'], $file['file'])) {
             error($config['error']['nomove']);
         }
         chmod($file['file'], 0644);
     } elseif (!@move_uploaded_file($file['tmp_name'], $file['file'])) {
开发者ID:fugeris,项目名称:8chan,代码行数:31,代码来源:post.php

示例6: mkdir_deep

            file_put_contents($originPath, $data);
            $isNotExists = false;
            break;
        }
    }
    if ($isNotExists) {
        error404();
    }
}
if ($params['type'] !== 'origin') {
    $Image = new Image();
    $Image->set($originPath);
    $Image->{$params['type']}(intval($params['width']), intval($params['height']));
    mkdir_deep($requestUrl);
    $Image->output($requestUrl, intval($params['quality']));
    $Image->destroy();
}
header('Content-type: image/jpeg');
@readfile($requestUrl);
/*
 * ディレクトリ作成
 */
function mkdir_deep($path)
{
    $dirs = explode('/', dirname($path));
    $path = '';
    foreach ($dirs as $dir) {
        $path .= $dir;
        if (!is_dir($path)) {
            @mkdir($path);
            @chmod($path, 0777);
开发者ID:slywalker,项目名称:image_kit,代码行数:31,代码来源:index.php

示例7: watermark

 /**
  * Copies the provided image into the current open image at set locations
  * which is mainly used for watermarks
  *
  * @param string $file
  * @param string $position
  * @return object
  */
 public function watermark($file, $position = 'bl')
 {
     $wmImage = new Image($file);
     if (!in_array($position, array('t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl'))) {
         trigger_error('Image_Base::watermark() invalid value for argument 2, reverting to "bl"', E_USER_NOTICE);
         $position = 'bl';
     }
     // Work out position
     $posX = $posY = 0;
     if (substr($position, -1, 1) == 'r') {
         $posX = $this->width - $wmImage->width;
     } else {
         if ($position == 't' || $position == 'b') {
             $posX = ($this->width - $wmImage->width) / 2;
         }
     }
     if ($position[0] == 'b') {
         $posY = $this->height - $wmImage->height;
     } else {
         if ($position == 'l' || $position == 'r') {
             $posY = ($this->height - $wmImage->height) / 2;
         }
     }
     imagecopymerge($this->resource, $wmImage->getResource(), $posX, $posY, 0, 0, $wmImage->width, $wmImage->height, 100);
     $wmImage->destroy();
     return $this;
 }
开发者ID:jinshana,项目名称:tangocms,代码行数:35,代码来源:Base.php

示例8: destroy

 public function destroy($id)
 {
     Image::destroy($id);
     return Redirect::back();
 }
开发者ID:ZJScapstone,项目名称:capstone.dev,代码行数:5,代码来源:ImagesController.php

示例9: watermark

 /**
  * @param int $position
  * @param string $fileName
  * @param int $width
  * @param int $height
  * @return void
  */
 public function watermark($fileName, $position = self::WM_POS_BOTTOM_RIGHT, $width = null, $height = null)
 {
     if (!$this->sourceImage) {
         $this->error('NotLoaded');
     }
     $watermark = new Image($fileName);
     if ($width || $height) {
         $watermark->resize($width, $height, self::RESIZE_TYPE_STRICT);
     }
     $this->workingImage = $this->createImage($this->originalSize[0], $this->originalSize[1]);
     imagealphablending($this->workingImage, true);
     switch ($position) {
         case self::WM_POS_TOP_LEFT:
             $x = $y = $this->watermarkOffset;
             break;
         case self::WM_POS_TOP_RIGHT:
             $x = $this->originalSize[0] - $watermark->getWidth() - $this->watermarkOffset;
             $y = $this->watermarkOffset;
             break;
         case self::WM_POS_BOTTOM_RIGHT:
             $x = $this->originalSize[0] - $watermark->getWidth() - $this->watermarkOffset;
             $y = $this->originalSize[1] - $watermark->getHeight() - $this->watermarkOffset;
             break;
         case self::WM_POS_BOTTOM_LEFT:
             $x = $y = $this->watermarkOffset;
             $y = $this->originalSize[1] - $watermark->getHeight() - $this->watermarkOffset;
             break;
         case self::WM_POS_CENTER:
             $x = ($this->originalSize[0] - $watermark->getWidth()) / 2;
             $y = ($this->originalSize[1] - $watermark->getHeight()) / 2;
             break;
         default:
             $x = 0;
             $y = 0;
             break;
     }
     imagecopy($this->workingImage, $this->sourceImage, 0, 0, 0, 0, $this->originalSize[0], $this->originalSize[1]);
     imagecopy($this->workingImage, $watermark->getSourceImage(), $x, $y, 0, 0, $watermark->getWidth(), $watermark->getHeight());
     $this->replaceAndReset($this->originalSize[0], $this->originalSize[1]);
     $watermark->destroy();
 }
开发者ID:prappo,项目名称:Biddaloy,代码行数:48,代码来源:Image_resize.php

示例10: deleteImage

 public function deleteImage()
 {
     $id = Input::get('id');
     Image::destroy($id);
     return $this->success(null, null);
 }
开发者ID:jcstrandburg,项目名称:portfoliowriter,代码行数:6,代码来源:ApiController.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Image::destroy($id);
     return Redirect::route("projects.index");
 }
开发者ID:jcstrandburg,项目名称:portfoliowriter,代码行数:11,代码来源:ImageController.php

示例12: destroy

 /**
  * {@inheritdoc}
  *
  * @return Watermark
  */
 public function destroy()
 {
     $this->size = $this->position = null;
     $this->margin = [0, 0];
     return parent::destroy();
 }
开发者ID:elboletaire,项目名称:watimage,代码行数:11,代码来源:Watermark.php

示例13: destroy

 /**
  * Remove the specified project from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Image::destroy($id);
     return Response::json(['data' => [], 'message' => "Image Deleted"], 200);
 }
开发者ID:jboz62,项目名称:cms,代码行数:11,代码来源:ImagesContoller.php


注:本文中的Image::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。