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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
carbon0404
Posts: 17
Joined: 2012-04-11T05:11:30-07:00
Authentication code: 8675308

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

Post 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?
Post Reply