Page 1 of 1

is that quality is ignored when convert a jpg to webp a bug?

Posted: 2012-09-17T03:02:27-07:00
by carbon0404
well,I want to use the IM to convert a jpg picture to webp format with different quality param to test how many bytes I can saved.code like this:

Code: Select all

taf::Int32 convert(const struct SInfo targetInfo, 
            vector<char> &targetData)
{

    try{
        if(m_image.magick()== "JPEG")
        {
            
            if (targetInfo.type=="WEBP")
            {
                if(targetInfo.quality <= m_info.quality)
                {
                    if(IImageConvert::QUALITY_MINI == targetInfo.quality)
                    {
                        m_image.quality(g_WEBP_MINI);
                    }
                    if(IImageConvert::QUALITY_LOW == targetInfo.quality)
                    {
                        m_image.quality(g_WEBP_LOW);
                    }   
                    if(IImageConvert::QUALITY_NORMAL == targetInfo.quality)
                    {
                        m_image.quality(g_WEBP_NORMAL);
                    }
                    if(IImageConvert::QUALITY_HIGH == targetInfo.quality)
                    {
                        m_image.quality(g_WEBP_HIGH);
                    }

                    MT_RLOG<<"adjust quality for webp,q:"<<targetInfo.quality<<"|"<<m_image.quality()<<endl;
                }
            }else
	    {
                    if(IImageConvert::QUALITY_MINI == targetInfo.quality)
                    {
                        m_image.quality(g_JPG_MINI);
                    }
                    if(IImageConvert::QUALITY_LOW == targetInfo.quality)
                    {
                        m_image.quality(g_JPG_LOW);
                    }   
                    if(IImageConvert::QUALITY_NORMAL == targetInfo.quality)
                    {
                        m_image.quality(g_JPG_NORMAL);
                    }
                    if(IImageConvert::QUALITY_HIGH == targetInfo.quality)
                    {
                        m_image.quality(g_JPG_HIGH);
                    }
 
            }
        //输出
        Blob outputblob;        
        m_image.write( &outputblob, targetInfo.type, m_image.depth());
        
        
        
    }catch(Exception &e){
        snprintf(m_error, sizeof(m_error), e.what());
        return -1; 
    }

    return 0;
}
varibles like g_WEBP_NORMAL are some const int values;when I use jpeg as target type for a jpg pic,it works well,the output picture's size is changed acording the quality,but for webp as the target type,whatever quality I used,the output picture file size is the same,is it a bug?who can help me?