ubuntu修改图片格式(jpg、jpeg、pbm等)

来源:互联网 发布:gis软件开发 编辑:程序博客网 时间:2024/05/16 16:18

方法一:imagemagick

#安装sudo apt-get install imagemagick#转化convert 1.jpeg 1.jpg

方法二:opencv

#include <iostream>#include<opencv2/core/core.hpp>  #include<opencv2/highgui/highgui.hpp>  using namespace std;using namespace cv;int main(void){    Mat image=imread("1.jpeg");    if(!image.data){        cout<<"No data!"<<endl;    }    namedWindow("hello1");    imshow("hello1",image);    waitKey(500);    Mat result;    //flip(image,result,0);//1为水平,0为垂直,负数为即水平又垂直    //namedWindow("hello2");    //imshow("hello2",result);    //waitKey(500);    imwrite("1.jpg",image);}

此时就把1.jpeg修改为1.jpg