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
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!
I solved this problem using client ini file in root directory...
Check if your webserver config allows modification of the memory_limit setting. Does the same error still appear?
Following code does thumbnail from image, which storage on server:
Should I add
before?
UPD
I tried to add previous line before code, which does thumbnail, but it's not work...
Look like you're trying to resize a larger image. Adjust your PHP memory_limit, eg. with ini_set().
Hello!
I use this extension for resize images in my gallery with images for desktop and I have sometimes error in error_log.log file like
[08-Jan-2012 09:36:27] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2560 bytes) in /home/username/public_html/protected/extensions/image/drivers/GD.php on line 368
What can it be? What should I do to solve this problem?
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!
Could I suggest that the Image class gets renamed to EImage as Image can potentially clash with other application models?
Regards,
Cass
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.
是否可以支持打水印功能?watermarks
When used in a loop it's an Fatal error: Cannot redeclare class Image_GD_Driver
update: Solved: Changing 'include' in line 123 in GD.php to 'include_once' helps. Don't know why the author used include.
guys..i have done what the manual above says. included changing in the line 80 on the image_gd_driver.php file.
but after i put the script in the index.php (i want to put my picture in the fron pages) I encounter some proble
guys..i have done what the manual above says. included changing in the line 80 on the image_gd_driver.php file.
but after i put the script in the index.php (i want to put my p
I just installed this extension for project I am working on for gallery module, and it is working perfect. I had my own small image library that I am using for simple image manipulation tasks(croping and resizing only), but for advanced functions, this is very nice to use, especially in Yii projects!
That is what i need like wideimage library.
thanks
I agree with Parcouss. Please, replace line 80 in Image_GD_Driver.php
to:
I have this error when i use Image to save and resize more than one pic to my server
Hi,
I used this extension (as I said in previous post) and changed some things:
You can take the code and use it or do whatever you want with. It's in my extension.
It's excellent ! Really good.
However, I don't like the need for the CArray.php file, and so for the helper folder.
I used your extension in another one, where I have removed this need (fileimagearbehavior). CArray is only needed for 1 function of 3 lines, used only twice (one call in each Image_*_Driver.php file).
You can see these two files or copy them if you don't want CArray.
Thanx for the work and this extension !
Leave a comment
Please login to leave your comment.