thinkphpÔõôÉèÖÃͼƬÖÊÁ¿
×÷ΪһÃû¿ª·¢Õߣ¬ÎÒÃÇÔÚÍøÕ¾¿ª·¢Öо³£»áʹÓÃͼƬÀ´¸»ºñÒ³ÃæÄÚÈÝ¡£¿ÉÊÇ£¬µ±ÎÒÃÇÔÚʹÓÃͼƬµÄͬʱ£¬Ò²ÐèҪעÖØͼƬµÄ¾ÞϸºÍÖÊÁ¿ÎÊÌâ¡£ÓÉÓÚ¹ý´ó»òÕßÖÊÁ¿²»¸ßµÄͼƬ»áÓ°ÏìÍøÕ¾µÄÐÔÄܺͼÓÔØËÙÂÊ£¬Õâ¹ØÓÚÓû§ÌåÑéÀ´ËµÊÇÒ»¸öµ¹Ô˵ÄÒòËØ¡£
¶ø¹ØÓÚʹÓÃthinkphp¿ò¼ÜµÄ¿ª·¢ÕßÀ´Ëµ£¬ÔõÑùͨ¹ý´úÂëÀ´¿ØÖÆͼƬµÄ¾ÞϸºÍÖÊÁ¿ÊÇÒ»ÏîÖ÷ÒªµÄÊÖÒÕ¡£ÏÂÃæ¾ÍÈÃÎÒÀ´·ÖÏíÒ»ÏÂthinkphp¿ò¼ÜÖÐÔõÑùÉèÖÃͼƬÖÊÁ¿µÄÒªÁì¡£
ÔÚthinkphp¿ò¼ÜÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃͼƬ´¦Àí¿âÀ´²Ù×÷ºÍ´¦ÀíͼƬ¡£ÆäÖУ¬Think\ImageÀà¿ÉÒÔ×ÊÖúÎÒÃÇÍê³É´¦ÀíͼƬµÄ¹¦Ð§¡£¶øÔÚʹÓÃThink\ImageÀàʱ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýsetQuality()ÒªÁìÀ´ÉèÖÃͼƬµÄÖÊÁ¿¾Þϸ¡£
setQuality()ÒªÁìµÄʹÓ÷½·¨ÈçÏ£º
use think\Image; ... $image = Image::open('image.jpg'); $image->setQuality(50); $image->save('new_image.jpg');
µÇ¼ºó¸´ÖÆ
ͨ¹ýÕâ¸öÒªÁ죬ÎÒÃÇ¿ÉÒÔ½«Í¼Æ¬µÄÖÊÁ¿ÉèÖÃΪ50£¬È»ºó½«´¦ÀíºóµÄͼƬÉúÑÄΪnew_image.jpg¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ʹÓÃsetQuality()ÒªÁì֮ǰ£¬ÎÒÃÇÐèÒªÏÈʹÓÃImage::open()ÒªÁìÀ´·¿ªÒª´¦ÀíµÄͼƬ¡£È»ºó£¬¶ÔͼƬ¾ÙÐÐÖÊÁ¿Ð޸ĺó£¬ÎÒÃÇÐèҪʹÓÃsave()ÒªÁ콫Ð޸ĺóµÄͼƬÉúÑĵ½Ö¸¶¨µÄ·¾¶Ï¡£
ÔÚÉèÖÃͼƬÖÊÁ¿Ê±£¬ÎÒÃÇÐèҪעÖØÒÔϼ¸µã£º
ÉèÖõÄͼƬÖÊÁ¿ÖµÔ½Ð¡£¬Í¼Æ¬µÄÎļþ¾ÞϸҲ¾ÍԽС¡£¿ÉÊÇ£¬ÖÊÁ¿Öµ¹ýµÍ»áÓ°ÏìͼƬµÄÇåÎú¶ÈºÍ¾«¶È¡£
ÔÚ´¦ÀíͼƬʱ£¬ÎÒÃÇÐèҪƾ֤ҳÃæÒªÇóºÍÐèÒªµÄÇåÎú¶ÈÀ´Ñ¡ÔñºÏÊʵÄÖÊÁ¿Öµ¡£
ÈôÊÇͼƬµÄÖÊÁ¿ÒѾºÜ¸ß£¬ÄÇôÔÙ¶ÔÆä¾ÙÐÐѹËõ´¦Àí¿ÉÄܻᵼÖÂͼƬʧÕæ¡£
ͨ¹ýʹÓÃsetQuality()ÒªÁ죬ÎÒÃÇ¿ÉÒÔÇáËɵؿØÖÆͼƬµÄÖÊÁ¿¾Þϸ£¬´Ó¶øÌá¸ßÍøÕ¾µÄÐÔÄܺͼÓÔØËÙÂÊ£¬Í¬Ê±Ò²°ü¹ÜÁËÓû§ÌåÑ顣ϣÍû±¾ÎĶÔÄãÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇthinkphpÔõôÉèÖÃͼƬÖÊÁ¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡