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;
}