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


PHP ImageHandler类代码示例

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


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

示例1: __construct

 /**
  * 
  *
  * @param int $width
  * @param int $height
  * @param ImageHandler $imageHandler
  */
 public function __construct($width, $height, ImageHandler $imageHandler)
 {
     $img = $imageHandler->createImage($width, $height);
     $color = imagecolorallocate($img, self::$backgroundColor['r'], self::$backgroundColor['g'], self::$backgroundColor['b']);
     imagefilledrectangle($img, 0, 0, $width, $height, $color);
     $crossColor = imagecolorallocate($img, self::$crossColor['r'], self::$crossColor['g'], self::$crossColor['b']);
     imageline($img, 0, 0, $width, $height, $crossColor);
     imageline($img, 0, $height, $width, 0, $crossColor);
     imageline($img, 0, 0, $width - 1, 0, $crossColor);
     imageline($img, $width - 1, 0, $width - 1, $height, $crossColor);
     imageline($img, $width - 1, $height - 1, 0, $height - 1, $crossColor);
     imageline($img, 0, $height - 1, 0, 0, $crossColor);
     $stringColor = imagecolorallocate($img, self::$stringColor['r'], self::$stringColor['g'], self::$stringColor['b']);
     imagestring($img, 2, 0, 0, self::$string, $stringColor);
     parent::__construct($img);
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:23,代码来源:EmptyTile.php

示例2: update

 public function update($username)
 {
     $input = array_except(Input::all(), '_method');
     $input['username'] = str_replace('.', '-', $input['username']);
     $user = User::where('username', '=', $username)->first();
     if (Auth::user()->id == $user->id) {
         if (Input::hasFile('avatar')) {
             $input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
         } else {
             $input['avatar'] = $user->avatar;
         }
         if ($input['password'] == '') {
             $input['password'] = $user->password;
         } else {
             $input['password'] = Hash::make($input['password']);
         }
         if ($user->username != $input['username']) {
             $username_exist = User::where('username', '=', $input['username'])->first();
             if ($username_exist) {
                 return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Sorry That Username is already in Use', 'note_type' => 'error'));
             }
         }
         $user->update($input);
         return Redirect::to('user/' . $user->username . '/edit')->with(array('note' => 'Successfully Updated User Info', 'note_type' => 'success'));
     }
     return Redirect::to('user/' . Auth::user()->username . '/edit ')->with(array('note' => 'Sorry, there seems to have been an error when updating the user info', 'note_type' => 'error'));
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:27,代码来源:ThemeUserController.php

示例3: normaliseParams

 function normaliseParams($image, &$params)
 {
     global $wgMaxThumbnailArea;
     wfProfileIn(__METHOD__);
     if (!ImageHandler::normaliseParams($image, $params)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     // Video files can be bigger than usuall images. We are alowing them to stretch up to WikiaFileHelper::maxWideoWidth px.
     if ($params['physicalWidth'] > WikiaFileHelper::maxWideoWidth) {
         $srcWidth = $image->getWidth($params['page']);
         $srcHeight = $image->getHeight($params['page']);
         $params['physicalWidth'] = WikiaFileHelper::maxWideoWidth;
         $params['physicalHeight'] = round($params['physicalWidth'] * $srcHeight / $srcWidth);
     }
     # Same as srcWidth * srcHeight above but:
     # - no free pass for jpeg
     # - thumbs should be smaller
     if ($params['physicalWidth'] * $params['physicalHeight'] > $wgMaxThumbnailArea) {
         wfProfileOut(__METHOD__);
         return false;
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:VideoHandler.class.php

示例4: save_settings

 public function save_settings()
 {
     $input = Input::all();
     $settings = Setting::first();
     $demo_mode = Input::get('demo_mode');
     $enable_https = Input::get('enable_https');
     if (empty($demo_mode)) {
         $input['demo_mode'] = 0;
     }
     if (empty($enable_https)) {
         $input['enable_https'] = 0;
     }
     if (Input::hasFile('logo')) {
         $input['logo'] = ImageHandler::uploadImage(Input::file('logo'), 'settings');
     } else {
         $input['logo'] = $settings->logo;
     }
     if (Input::hasFile('favicon')) {
         $input['favicon'] = ImageHandler::uploadImage(Input::file('favicon'), 'settings');
     } else {
         $input['favicon'] = $settings->favicon;
     }
     $settings->update($input);
     return Redirect::to('admin/settings')->with(array('note' => 'Successfully Updated Site Settings!', 'note_type' => 'success'));
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:25,代码来源:AdminSettingsController.php

示例5: doFakeTransform

 /**
  * Override BitmapHandler::doTransform() making sure we do not generate
  * a thumbnail at all. That is merely returning a ThumbnailImage that
  * will be consumed by the unit test.  There is no need to create a real
  * thumbnail on the filesystem.
  * @param ImageHandler $that
  * @param File $image
  * @param string $dstPath
  * @param string $dstUrl
  * @param array $params
  * @param int $flags
  * @return ThumbnailImage
  */
 static function doFakeTransform($that, $image, $dstPath, $dstUrl, $params, $flags = 0)
 {
     # Example of what we receive:
     # $image: LocalFile
     # $dstPath: /tmp/transform_7d0a7a2f1a09-1.jpg
     # $dstUrl : http://example.com/images/thumb/0/09/Bad.jpg/320px-Bad.jpg
     # $params:  width: 320,  descriptionUrl http://trunk.dev/wiki/File:Bad.jpg
     $that->normaliseParams($image, $params);
     $scalerParams = ['physicalWidth' => $params['physicalWidth'], 'physicalHeight' => $params['physicalHeight'], 'physicalDimensions' => "{$params['physicalWidth']}x{$params['physicalHeight']}", 'clientWidth' => $params['width'], 'clientHeight' => $params['height'], 'comment' => isset($params['descriptionUrl']) ? "File source: {$params['descriptionUrl']}" : '', 'srcWidth' => $image->getWidth(), 'srcHeight' => $image->getHeight(), 'mimeType' => $image->getMimeType(), 'dstPath' => $dstPath, 'dstUrl' => $dstUrl];
     # In some cases, we do not bother generating a thumbnail.
     if (!$image->mustRender() && $scalerParams['physicalWidth'] == $scalerParams['srcWidth'] && $scalerParams['physicalHeight'] == $scalerParams['srcHeight']) {
         wfDebug(__METHOD__ . ": returning unscaled image\n");
         // getClientScalingThumbnailImage is protected
         return $that->doClientImage($image, $scalerParams);
     }
     return new ThumbnailImage($image, $dstUrl, false, $params);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:30,代码来源:MockImageHandler.php

示例6: addImageFromUrl

 /**
  * Add an image to the file.
  *
  * @param string $url Url to the image
  *
  * @return int The reference of the image, false if the image couldn't be downloaded
  */
 public function addImageFromUrl($url)
 {
     $image = ImageHandler::DownloadImage($url);
     if ($image === false) {
         return false;
     }
     return $this->addImage($image);
 }
开发者ID:wallabag,项目名称:php-mobi,代码行数:15,代码来源:MultipleFileHandler.php

示例7: _chooseLogoFile

 /**
  * return the logo image which fits the best to the size of the map
  *
  * @return resource
  */
 private function _chooseLogoFile()
 {
     $mapWidth = imagesx($this->_img);
     $mapHeight = imagesy($this->_img);
     foreach ($this->_logoFiles as $logoFile) {
         $logoImageHandler = ImageHandler::createImageHandlerFromFileExtension($logoFile);
         $logoImage = $logoImageHandler->loadImage($logoFile);
         $logoWidth = imagesx($logoImage);
         $logoHeight = imagesy($logoImage);
         if ($logoWidth < $mapWidth && $logoHeight < $mapHeight) {
             return $logoImage;
         }
     }
     return $logoImage;
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:20,代码来源:LogoMap.php

示例8: process

 public function process($imageResource = null, $imageUrl = null)
 {
     // Check if post has a suitable image
     try {
         $imageUrl = (new ImageExtractor($this->post->url))->get(399);
     } catch (\Exception $e) {
         $imageUrl = (new ImageExtractor($this->post->url, $this->post->content))->get(399);
     }
     if ($imageUrl) {
         $imageResource = \ImageHandler::make($imageUrl);
         // store it
         (new StoreImage($this->post))->process($imageResource, $imageUrl);
         // cache it
         (new CacheImage($this->post))->process($imageResource);
     }
 }
开发者ID:aboustayyef,项目名称:deprecated_lb_l5,代码行数:16,代码来源:MainProcessor.php

示例9: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update()
 {
     $data = Input::all();
     $id = $data['id'];
     $post = Post::findOrFail($id);
     $validator = Validator::make($data, Post::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if (empty($data['image'])) {
         unset($data['image']);
     } else {
         $data['image'] = ImageHandler::uploadImage($data['image'], 'images');
     }
     $post->update($data);
     return Redirect::to('admin/posts/edit' . '/' . $id)->with(array('note' => 'Successfully Updated Post!', 'note_type' => 'success'));
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:23,代码来源:AdminPostController.php

示例10: execute

 public function execute()
 {
     $this->_configure();
     try {
         $mapRequest = new MapRequest($this->_get);
         $leftUpCorner = $mapRequest->getLeftUpCornerPoint();
         $rightDownCorner = $mapRequest->getRightDownCornerPoint();
         $mapProcessor = MapProcessor::factory($mapRequest);
         // create map object
         $bboxRespons = BboxRespons::factory($mapRequest->getBboxReturnType());
         $mapProcessor->getTileSource()->useImages($bboxRespons == null);
         $map = $mapProcessor->createMap($bboxRespons);
         if ($bboxRespons != null) {
             $bboxRespons->setData($map);
             $bboxRespons->send();
             die;
         }
         $map->setImageHandler(ImageHandler::factory($mapRequest->getImageType()));
         $drawHandle = new DrawHandle($map);
         $drawRequest = new DrawRequest($mapRequest);
         $drawHandle->draw($drawRequest);
         $mapWithLogo = new LogoMap($map, $this->_conf);
         $mapWithLogo->setLogoLayout(LogoLayout::factoryFromUrl($mapRequest->getLogoLayoutName()));
         $scaleBar = new ScaleBar($mapWithLogo, $this->_conf);
         $scaleBar->setUnit($mapRequest->getScaleBarUnit());
         $scaleBar->putOnMap(ScaleBarLayout::factoryFromUrl($mapRequest->getScaleBarLayoutName()));
         // send output image
         $mapWithLogo->send();
         die;
     } catch (NoMapProcessorException $e) {
         $map = new WrongRequestMap($this->_conf->get('wrong_map_request_file'));
         $map->send();
         die;
     } catch (WrongMapRequestDataException $e) {
         $map = new WrongRequestMap($this->_conf->get('wrong_map_request_file'));
         $map->send();
         die;
     }
     /*
     		 header('Content-Type: image/png');
     		 $img = imagecreatefrompng('http://tile.openstreetmap.org/12/2048/1362.png');
     
     		 imagepng($img);*/
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:44,代码来源:MapModule.php

示例11: update

 public function update()
 {
     $input = Input::all();
     $id = $input['id'];
     $user = User::find($id);
     if (Input::hasFile('avatar')) {
         $input['avatar'] = ImageHandler::uploadImage(Input::file('avatar'), 'avatars');
     } else {
         $input['avatar'] = $user->avatar;
     }
     if (empty($input['active'])) {
         $input['active'] = 0;
     }
     if ($input['password'] == '') {
         $input['password'] = $user->password;
     } else {
         $input['password'] = Hash::make($input['password']);
     }
     $user->update($input);
     return Redirect::to('admin/user/edit/' . $id)->with(array('note' => 'Successfully Updated User Settings', 'note_type' => 'success'));
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:21,代码来源:AdminUsersController.php

示例12: draw

 /**
  * draw point on map
  *
  * @param Map $map
  */
 public function draw(Map $map)
 {
     $image = $map->getImage();
     $color = $this->_getDrawColor($image);
     $pointImage = false;
     if ($this->hasImageUrl()) {
         $size = HelpClass::getSizeOfRemoteFile($this->_imageUrl->getUrl());
         if ($size <= self::$maxSizeOfPointImage) {
             try {
                 $imageHandler = ImageHandler::createImageHandlerFromFileExtension($this->_imageUrl->getUrl());
                 $pointImage = $imageHandler->loadImage($this->_imageUrl->getUrl());
             } catch (ImageHandlerException $e) {
             }
         }
     }
     if ($pointImage !== false) {
         $map->putImage($pointImage, $this->getLon(), $this->getLat());
     } else {
         $color = $this->_getDrawColor($image);
         $point = $map->getPixelPointFromCoordinates($this->getLon(), $this->getLat());
         $vertices = array($point['x'], $point['y'], $point['x'] - 10, $point['y'] - 20, $point['x'] + 10, $point['y'] - 20);
         imagefilledpolygon($map->getImage(), $vertices, 3, $color);
     }
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:29,代码来源:MarkPoint.php

示例13: handleImages

 /**
  *
  * @param DOMElement $dom
  * @return array
  */
 private function handleImages($dom, $url)
 {
     $images = array();
     $parts = parse_url($url);
     $savedImages = array();
     $imgElements = $dom->getElementsByTagName('img');
     foreach ($imgElements as $img) {
         $src = $img->getAttribute("src");
         $is_root = false;
         if (substr($src, 0, 1) == "/") {
             $is_root = true;
         }
         $parsed = parse_url($src);
         if (!isset($parsed["host"])) {
             if ($is_root) {
                 $src = http_build_url($url, $parsed, HTTP_URL_REPLACE);
             } else {
                 $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH);
             }
         }
         $img->setAttribute("src", "");
         if (isset($savedImages[$src])) {
             $img->setAttribute("recindex", $savedImages[$src]);
         } else {
             $image = ImageHandler::DownloadImage($src);
             if ($image !== false) {
                 $images[$this->imgCounter] = new FileRecord(new Record($image));
                 $img->setAttribute("recindex", $this->imgCounter);
                 $savedImages[$src] = $this->imgCounter;
                 $this->imgCounter++;
             }
         }
     }
     return $images;
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:40,代码来源:OnlineArticle.php

示例14: addTile

 /**
  * saves image file for given tile
  *
  * @param resource $image
  * @param int $x
  * @param int $y
  * @param int $zoom
  */
 public function addTile($image, $x, $y, $zoom)
 {
     $this->_imageHandler->saveImage($image, $this->_getFileName($x, $y, $zoom));
     if ($this->_getSizeOfCache() > $this->_cacheSize) {
         $this->_cleanCache();
     }
 }
开发者ID:pafciu17,项目名称:gsoc-os-static-maps-api,代码行数:15,代码来源:TileCache.php

示例15: normaliseParams

 function normaliseParams($image, &$params)
 {
     global $wgMaxImageArea;
     if (!parent::normaliseParams($image, $params)) {
         return false;
     }
     $mimeType = $image->getMimeType();
     $srcWidth = $image->getWidth($params['page']);
     $srcHeight = $image->getHeight($params['page']);
     # Don't thumbnail an image so big that it will fill hard drives and send servers into swap
     # JPEG has the handy property of allowing thumbnailing without full decompression, so we make
     # an exception for it.
     if ($mimeType !== 'image/jpeg' && $srcWidth * $srcHeight > $wgMaxImageArea) {
         return false;
     }
     # Don't make an image bigger than the source
     $params['physicalWidth'] = $params['width'];
     $params['physicalHeight'] = $params['height'];
     if ($params['physicalWidth'] >= $srcWidth) {
         $params['physicalWidth'] = $srcWidth;
         $params['physicalHeight'] = $srcHeight;
         return true;
     }
     return true;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:25,代码来源:Bitmap.php


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