/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var Imagick $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['threshold' => 80], $options); return $resource->sepiaToneImage($options['threshold']); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var \Imagick $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['brightness' => 100, 'saturation' => 50, 'hue' => 100], $options); return $resource->modulateimage($options['brightness'], $options['saturation'], $options['hue']); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var \Imagick $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['color' => 'blue'], $options); return $resource->colorizeimage($options['color'], 1); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var resource $resource */ $resource = $imanee->getResource()->getResource(); imagefilter($resource, IMG_FILTER_GRAYSCALE); imagefilter($resource, IMG_FILTER_COLORIZE, 100, 50, 0); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var \Imagick $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['radius' => 2, 'sigma' => 2], $options); return $resource->gaussianBlurImage($options['radius'], $options['sigma']); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var resource $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['brightness' => 50, 'contrast' => -10], $options); imagefilter($resource, IMG_FILTER_BRIGHTNESS, $options['brightness']); imagefilter($resource, IMG_FILTER_CONTRAST, $options['saturation']); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var resource $resource */ $resource = $imanee->getResource()->getResource(); $options = array_merge(['color' => 'blue'], $options); $pixel = new GDPixel($options['color']); imagefilter($resource, IMG_FILTER_COLORIZE, $pixel->channelR, $pixel->channelG, $pixel->channelB); }
public function run() { //user id of 1 $roger = new User(); $roger->email = '*****@*****.**'; $roger->password = '******'; $roger->password_confirmation = 'password'; $roger->first_name = 'Roger'; $roger->last_name = 'Chin'; $roger->birthday = '1991-01-11'; $roger->zip = '78230'; $roger->gender = 'M'; $image = new Imanee(__DIR__ . '/../../../public/images/users/roger_headshot.jpg'); $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/roger_headshot.jpg'); $roger->image = 'roger_headshot.jpg'; $roger->confirmation_code = md5(uniqid(mt_rand(), true)); $roger->confirmed = 1; $roger->save(); //user id of 2 $jerald = new User(); $jerald->email = '*****@*****.**'; $jerald->password = '******'; $jerald->password_confirmation = 'password'; $jerald->first_name = 'Jerald'; $jerald->last_name = 'Saenz'; $jerald->birthday = '1971-01-18'; $jerald->zip = '78258'; $jerald->gender = 'M'; $image = new Imanee(__DIR__ . '/../../../public/images/users/jerald_headshot.jpg'); $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/jerald_headshot.jpg'); $jerald->image = 'jerald_headshot.jpg'; $jerald->confirmation_code = md5(uniqid(mt_rand(), true)); $jerald->confirmed = 1; $jerald->save(); //user id of 3 $sakib = new User(); $sakib->email = '*****@*****.**'; $sakib->password = '******'; $sakib->password_confirmation = 'password'; $sakib->first_name = 'Sakib'; $sakib->last_name = 'Shaikh'; $sakib->birthday = '1984-09-02'; $sakib->zip = '78015'; $sakib->gender = 'M'; $image = new Imanee(__DIR__ . '/../../../public/images/users/sakib_headshot.jpg'); $image->resize(200, 150)->write(__DIR__ . '/../../../public/images/users/sakib_headshot.jpg'); $sakib->image = 'sakib_headshot.jpg'; $sakib->confirmation_code = md5(uniqid(mt_rand(), true)); $sakib->confirmed = 1; $sakib->save(); }
/** * {@inheritdoc} */ public function animate(array $frames, $delay = 20) { $gif = new \Imagick(); $gif->setFormat('gif'); foreach ($frames as $im) { if ($im instanceof Imanee) { $frame = $im->getResource()->getResource(); } else { $frame = new \Imagick($im); } $frame->setImageDelay($delay); $gif->addImage($frame); } $imagickResource = new ImagickResource(); $imagickResource->setResource($gif); $imanee = new Imanee(); $imanee->setResource($imagickResource); $imanee->setFormat('gif'); return $imanee; }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = array()) { /** @var \Imagick $resource */ $resource = $imanee->getResource()->getResource(); return $resource->modulateimage(100, 0, 100); }
/** * Convenient method for generating text-only images * * @param string $text * @param Drawer $drawer * @param string $format * @param string $background * @return Imanee */ public static function textGen($text, Drawer $drawer = null, $format = 'png', $background = 'transparent', ImageResourceInterface $resource = null) { $imanee = new Imanee(null, $resource); if ($drawer !== null) { $imanee->setDrawer($drawer); } $size = $imanee->resource->getTextGeometry($text, $imanee->getDrawer()); $imanee->newImage($size['width'], $size['height'], $background); $imanee->setFormat($format); $imanee->placeText($text, Imanee::IM_POS_TOP_LEFT); return $imanee; }
/** * {@inheritdoc} */ public function compositeImage($image, $coordX, $coordY, $width = 0, $height = 0, $transparency = 0) { if (!is_object($image)) { $image = new Imanee($image, new GDResource()); } if (!$image instanceof \Imanee\Imanee) { throw new \Exception('Object not supported. It must be an instance of Imanee'); } if ($width and $height) { $dimensions = PixelMath::getBestFit($width, $height, $image->getWidth(), $image->getHeight()); $width = $dimensions['width']; $height = $dimensions['height']; } else { $width = $image->getWidth(); $height = $image->getHeight(); } /* TODO: implement pixel per pixel transparency */ return imagecopyresampled($this->getResource(), $image->getResource()->getResource(), $coordX, $coordY, 0, 0, $width, $height, $image->getWidth(), $image->getHeight()); }
public function validateAndSave($user) { $validator = Validator::make(Input::all(), User::$updateRules); if ($validator->fails()) { var_dump($validator->messages()); die; return Redirect::back()->withInput()->withErrors($validator); } else { //$user = new User(); $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->zip = Input::get('zip'); $user->birthday = Input::get('birthday'); $user->gender = Input::get('gender'); $user->quote = Input::get('quote'); $user->about = Input::get('about'); $image = Input::file('image'); // $user->image = $image->getClientOriginalName(); // $image->move(__DIR__ . '/../../public/img'); if (Input::hasfile('image')) { Input::file('image')->move(__DIR__ . '/../../public/images/users', Input::file('image')->getClientOriginalName()); $image = new Imanee(__DIR__ . '/../../public/images/users/' . Input::file('image')->getClientOriginalName()); $image->resize(200, 150)->write(__DIR__ . '/../../public/images/users/' . Input::file('image')->getClientOriginalName()); $user->image = Input::file('image')->getClientOriginalName(); } $result = $user->save(); //dd($result,$user); if ($result) { return Redirect::action('UsersController@index'); } else { return Redirect::back()->withInput(); } } }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = array()) { /** @var resource $resource */ $resource = $imanee->getResource()->getResource(); return imagefilter($resource, IMG_FILTER_GRAYSCALE); }
public function validateAndSave($organization) { $validator = Validator::make(Input::all(), Organization::$rules); if ($validator->fails()) { $messages = $validator->errors(); return Redirect::back()->withInput()->withErrors($messages); } else { $organization->name = Input::get('name'); $organization->description = Input::get('description'); if (Input::hasfile('image')) { Input::file('image')->move(__DIR__ . '/../../public/images/organizations', Input::file('image')->getClientOriginalName()); $image = new Imanee(__DIR__ . '/../../public/images/organizations/' . Input::file('image')->getClientOriginalName()); $image->resize(200, 150)->write(__DIR__ . '/../../public/images/organizations/' . Input::file('image')->getClientOriginalName()); $organization->image = Input::file('image')->getClientOriginalName(); } $organization->website = Input::get('website'); $organization->user_id = Input::get('user_id'); $result = $organization->save(); $userRole = Role::where('name', 'admin')->first(); Auth::user()->attachRole($userRole->id); Auth::user()->Roles()->sync(array(2)); if ($result) { return Redirect::action('OrganizationsController@show', $organization->id); } else { return Redirect::back()->withInput(); } } }
public function testShouldTextGen() { $resource = $this->getMockBuilder('Imanee\\ImageResource\\GDResource')->setMethods(['getTextGeometry', 'createNew', 'setFormat', 'annotate'])->getMock(); $resource->expects($this->any())->method('getTextGeometry'); $resource->expects($this->once())->method('annotate'); $drawer = $this->getMockBuilder('Imanee\\Drawer')->setMethods(['getFontSize'])->getMock(); $drawer->expects($this->once())->method('getFontSize'); Imanee::textGen('Testing', $drawer, 'png', 'transparent', $resource); }
/** * {@inheritdoc} */ public function apply(Imanee $imanee, array $options = []) { /** @var resource $resource */ $resource = $imanee->getResource()->getResource(); imagefilter($resource, IMG_FILTER_GAUSSIAN_BLUR); }