Provides methods for the dynamic manipulation of images. Various image formats such as JPEG, PNG, and GIF can be resized, cropped, rotated and sharpened.
All image manipulations are applied to a temporary image. Only the save() method is permanent, the temporary image being written to a specified image file.
Image manipulation methods can be chained efficiently. Recommended order: resize, crop, sharpen, quality and rotate or flip
此库提供方法动态的处理图片。支持对 JPEG,PNG 和 GIF 格式的图片进行调整大小,剪裁,旋转和锐化。
所有对图片的处理都会应用到一个临时图像上面,但只有 save() 方法是永久的,它会把临时图像写入指定的图像文件中。
图像处理方法也可以用“串连(chained)”方式。推荐顺序为:大小,剪裁,锐化,质量和旋转或翻转。
protected/extensionsprotectedThe following code is the component registration in the config file:
'import'=>array( ... 'application.helpers.*', ... ), 'components'=>array( 'image'=>array( 'class'=>'application.extensions.image.CImageComponent', // GD or ImageMagick 'driver'=>'GD', // ImageMagick setup path 'params'=>array('directory'=>'/opt/local/bin'), ),... )
See the following code example:
$image = Yii::app()->image->load('images/test.jpg'); $image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20); $image->save(); // or $image->save('images/small.jpg');
or
Yii::import('application.extensions.image.Image'); $image = new Image('images/test.jpg'); $image->resize(400, 100)->rotate(-45)->quality(75)->sharpen(20); $image->render();
Total 20 comments
schmunk, this extension based on latest Kohana Image library http://www.yiiframework.com/extension/easyimage/
It works great, but does anyone has an example for a watermark function? Would be very nice.
On the forum i read that it has been added? http://www.yiiframework.com/forum/index.php/topic/36242-new-version-of-image-extension-supported-watermark/page__p__174486__hl__watermark#entry174486
Haven't tried it yet, but the underlying library is available on github in version 3.2.1.
I agree with Parcouss too. Please, replace line 80 in Image_GD_Driver.php
Took a while to figure out the error and fix this $quality = CArray::remove('quality', $actions);
to
if (array_key_exists('quality', $actions)) { $quality = $actions['quality']; unset($actions['quality']);
} else { $quality = null; }
Thank You
4199
Thank you, Nayjest
I added these two lines at the end of imagecreatetransparent() function to solve the problem ... just before the return
Para las personas que usen esta extension en las nuevas versiones de yii framework. Les va a salir error. para esto deben hacer lo siguiente.
Gracias al usuario del post: #4199
por
Please have a look at your log file, usually something like /var/log/apache2/error.log
NetworkError: 500 Internal Server Error.
Please show us your PHP error - maybe a memory limit issue?
Its working perfectly for lower dimension images.Not working for high dimension mages.Please help me to fix this issue.
ram0973, thank you for the addition
hi, first of all thanks alot for the very usefull extension.
i got a problem with my resized image.ie the image im trying to resize have a rounded corners on the top.so its corner background was white before i resize it but after resizing with this extension it truned into black. on the top corners.
i think there will be some way to change this image background color in this extension.please help me.
-Sirin
Just wrote a smart_resize function: It's auto resize and crop image dimensions EXACTLY you want.
If i give different scale in width and height, it shows scale of same dimension
good work, thanks.
dave3011: you must use path, not url, i.e. /some/image/path.jpg, not http://someImage.path
After installation of this extenstion as described (both ways, image->load() and new Image() ), I get the error: **image file not found ** (in myapppath\protected\extensions\image\Image.php(78))
This is weird since I tried to resize an image with the full path: $image = new Image('http://SomeRandomPicFromTheWeb.jpg');
Any help is appreciated!
Is it possible to repair this bug for transparent GIF management in GD? This extension will always convert the background to black.
Guess you should use imagecolorallocatealpha()
Thank you!
That seems to have been fixed in the GD.php, but I did encounter the same issue on line 123 of Image.php where the author used require. Changing this to:
does the trick.
Leave a comment
Please login to leave your comment.