尊龙凯时人生就是博

laravel¿ò¼ÜÔõôµ¼³öͼƬ

laravel ÊÇÒ»¸öÊ¢ÐÐµÄ php ¿ò¼Ü £¬Îª¿ª·¢ÕßÌṩÁËÐí¶à±ãµ±µÄ¹¤¾ßºÍ¹¦Ð§ £¬Àû±ã¿ì½ÝµØ¾ÙÐÐÍøÕ¾¹¹½¨ºÍÓ¦Óÿª·¢¡£ÆäÖÐ £¬¹ØÓÚͼƬµÄ´¦ÀíºÍµ¼³öÒ²ÓкܺõÄÖ§³Ö £¬±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùʹÓà laravel ¿ò¼Üµ¼³öͼƬ¡£

ÔÚ Laravel ¿ò¼ÜÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓõÚÈý·½¿â intervention/image À´ÊµÏÖͼƬµÄ´¦ÀíºÍµ¼³ö¡£Ê×ÏÈ £¬ÐèÒªÔÚÏîÄ¿ÖÐ×°Öøÿâ £¬¿ÉÒÔʹÓà Composer ¾ÙÐÐ×°Öà £¬ÏÂÁîÈçÏ£º

composer require intervention/image

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬ÔÚ config/app.php ÎļþÖÐµÄ providers Êý×éÖÐÌí¼Ó \Intervention\Image\ImageServiceProvider::class £¬Í¬Ê±ÔÚ aliases Êý×éÖÐÌí¼Ó ‘Image’ => \Intervention\Image\Facades\Image::class £¬¼´¿ÉÍê³ÉÉèÖá£

ÏÂÃæ½øÈëÏêϸ²Ù×÷¡£ÈôÊÇÎÒÃÇÏëÒªµ¼³öÒ»ÕÅͼƬ £¬ÎÒÃÇÐèÒª×öÒÔϼ¸¸ö°ì·¨£º

¼ÓÔØͼƬÎļþ£ºIntervention/Image ¿âÌṩÁË make() ÒªÁìÀ´¼ÓÔØÖ¸¶¨µÄͼƬÎļþ £¬¿ÉÒÔ´ÓÎļþ·¾¶»ò URL ÖмÓÔØ¡£ÀýÈ磺

use Intervention\Image\ImageManagerStatic as Image;

$image = Image::make('path/to/image.jpg');

µÇ¼ºó¸´ÖÆ

µ÷½âͼƬ´óС£ºÈôÊÇÐèÒªµ¼³öÖ¸¶¨³ß´çµÄͼƬ £¬¿ÉÒÔʹÓà fit() ÒªÁì¾ÙÐе÷½â¡£ÀýÈ磺

// Ëõ·ÅÖÁ¿íΪ 300£¬¸ß¶È×Ô¶¯Ë³Ó¦
$image->fit(300);

// Ëõ·ÅÖÁ¸ßΪ 200£¬¿í¶È×Ô¶¯Ë³Ó¦
$image->fit(null, 200);

// Ëõ·ÅÖÁ¿íΪ 300£¬¸ßΪ 200
$image->fit(300, 200);

µÇ¼ºó¸´ÖÆ

µ¼³öͼƬ£º×îºó £¬ÎÒÃÇ¿ÉÒÔʹÓà save() ÒªÁ콫ͼƬµ¼³öµ½Ö¸¶¨Î»Öá£ÀýÈ磺

// µ¼³öΪ JPEG ÃûÌÃ£¬ÖÊÁ¿Îª 90£¬ÎļþÃûΪ image.jpg
$image->save('path/to/image.jpg', 90, 'jpg');

µÇ¼ºó¸´ÖÆ

ÕâÑù £¬ÎÒÃǾÍÀֳɵص¼³öÁËÒ»ÕÅͼƬ¡£

³ýÁËÉÏÊö»ù±¾²Ù×÷Íâ £¬Intervention/Image ¿â»¹Ö§³ÖÐí¶à¸ß¼¶²Ù×÷ £¬Èçµ÷½âͼƬÁÁ¶È¡¢±ÈÕնȡ¢±¥ºÍ¶ÈµÈ £¬¶¼¿ÉÒÔͨ¹ýÁ´Ê½Å²ÓÃÀ´ÊµÏÖ¡£ÀýÈ磺

// Ìá¸ßͼƬÁÁ¶ÈΪ 25%
$image->brightness(25);

// Ìá¸ßͼƬ±ÈÕÕ¶ÈΪ 50%
$image->contrast(50);

// ½µµÍͼƬ±¥ºÍ¶ÈΪ 75%
$image->greyscale()->colorize(45, 15, 115)->contrast(5)->brightness(-10)->pixelate(10);

µÇ¼ºó¸´ÖÆ

ͨ¹ýÕâЩ¸ß¼¶²Ù×÷ £¬ÎÒÃÇ¿ÉÒÔƾ֤ÐèÇóÎÞаµØ¾ÙÐÐͼƬ´¦ÀíºÍµ¼³ö¡£

×ܽáÀ´Ëµ £¬Laravel ¿ò¼ÜÌṩÁËÍêÉƵÄͼƬ´¦ÀíºÍµ¼³öÖ§³Ö £¬ÍŽá Intervention/Image ¿âµÄÇ¿Ê¢¹¦Ð§ £¬¿ÉÒÔÀû±ã¸ßЧµØʵÏÖͼƬ´¦ÀíºÍµ¼³ö £¬Îª¿ª·¢Õß´øÀ´ºÜ´óµÄ±ãµ±¡£

ÒÔÉϾÍÊÇlaravel¿ò¼ÜÔõôµ¼³öͼƬµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ