【发布时间】:2014-06-03 13:47:36
【问题描述】:
当我调用WP_Image_Editor->resize(...)函数时,图片的高度太小,它会忽略我传入的高度。例如:
//This image is 300 x 225
$image = wp_get_image_editor( "/var/www/wp-content/uploads/2014/03/test.jpg" );
//I tell it to resize to 290 x 290
$image->resize( 290, 290 ); //Passing "true" to crop doesn't help)
//It saves, but as 290 x 225!
$image->save( "/var/www/wp-content/uploads/2014/03/test-22.jpg" );
如何让它拉伸到合适的大小和比例?
EDIT 以下是上述每个函数调用返回的内容:
//var_dump of wp_get_image_editor( $myImagePath );
object(WP_Image_Editor_Imagick)#109 (6) {
["image":protected]=>
object(Imagick)#108 (0) {
}
["file":protected]=>
string(65) "/var/www/wp-content/uploads/2014/03/test.jpg"
["size":protected]=>
array(2) {
["width"]=>
int(300)
["height"]=>
int(225)
}
["mime_type":protected]=>
string(10) "image/jpeg"
["default_mime_type":protected]=>
string(10) "image/jpeg"
["quality":protected]=>
int(90)
}
//var_dump of $image->resize( 290, 290 );
bool(true)
//var_dump of $image->save( "/var/www/wp-content/uploads/2014/03/test-22.jpg" );
array(5) {
["path"]=>
string(68) "/var/www/wp-content/uploads/2014/03/test-22.jpg"
["file"]=>
string(11) "test-22.jpg"
["width"]=>
int(294)
["height"]=>
int(225)
["mime-type"]=>
string(10) "image/jpeg"
}
【问题讨论】:
标签: php wordpress imagemagick imagick