Solved Process with arguments doesn't work...
-
Hello,
Trying to convert some files to images with imagemagick, I need to run this command line (at this time, the process is running .bat file but I would like to remove it and execute process only in Qt):
for %%f in ("\\DGS1109N007\Affichage\Messages\*.*") do ( "\\DGS1109N007\Affichage\Display\imagmagick\magick.exe" convert -density 300 -trim "\\DGS1109N007\Affichage\Messages\*.*" -quality 100 "\\DGS1109N007\Affichage\Display\Messages\output.jpg" )
for that I try to use c++ process in Qt but it doesn't work:
QDir directory("//DGS1109N007/Affichage/Messages"); QStringList images = directory.entryList(QStringList(),QDir::Files); foreach(QString filename, images) { program ="//DGS1109N007/Affichage/Display/imagmagick/magick.exe"; QStringList arguments; arguments << "convert -density 300 -trim" <<"//DGS1109N007/Affichage/Messages"+filename<<"-quality 100 "<<"//DGS1109N007/Affichage/Display/Messages/output.jpg"; myProcess.start(program,arguments);`` I don't receive any error but it doesn't do any thing, could you help me? Kind regards
-
@filipdns
Hi
Check what
http://doc.qt.io/qt-5/qprocess.html#error
reports. -
@mrjj Thanks mrjj but it doesn't help me, I'm sorry
-
@filipdns
but what did it report ?
Its impossible to guess what is wrong with no extra info.
and that function is how QProcess tells how it went.btw. i can see
magick.exe so that seems like windows.
but you are giving it linux paths as parameter
"//DGS1109N007/Affichage/Messages"windows uses \ and not / so not sure magick.exe likes it.
also in your sample for .bat, you are using the \ version. -
Think you are missing a "/" after
-
@Gerd
Good catch!
yes seems filename will be directly appended. -
Sorry, last post was incomplete...
Think you are missing a "/" after "Messages" and before filename in this Line:arguments << "convert -density 300 -trim" <<"//DGS1109N007/Affichage/Messages"+filename<<"-quality 100 "<<"//DGS1109N007/Affichage/Display/Messages/output.jpg"
-
@mrjj You are right, magick don't like / but qt don't like \ then, I don't know...
-
@Gerd Hi Gerd, Yes, the / was missing, now I receive something, but error and not expected conversion...
magick.exe: UnableToOpenBlob 'convert -density 300 -trim': No such file or directory @ error/blob.c/OpenBlob/3490.
what mean what say mrjj, magick don't accept / but expect ...
I will try replace.("/", "\") to see what append..
-
try to check what is in arguments, it seems that you also miss a blnk after "...trim"
-
@Gerd Hi Gerd,
I found how make it work:
program=QDir::toNativeSeparators("//DGS1109N007/Echanges_SAA/Affichage/Display/imagmagick/magick ")+ "convert -density 300 -trim "+ QDir::toNativeSeparators("\"//DGS1109N007/Echanges_SAA/Affichage/Messages/"+filename)+"\" -quality 100 "+QDir::toNativeSeparators("\"//DGS1109N007/Echanges_SAA/Affichage/Display/Messages/output.jpg");
now I have an other strange thing not linked with this topic...
with:
QDir directory("//DGS1109N007/Echanges_SAA/Affichage/Messages"); QStringList images = directory.entryList(QStringList(),QDir::Files); for(int i=0;i<images.count();i++) { //do whatever you need to do QString filename=images[i]; qDebug()<<"filename"<<filename; program=QDir::toNativeSeparators("//DGS1109N007/Echanges_SAA/Affichage/Display/imagmagick/magick ")+ "convert -density 300 -trim "+ QDir::toNativeSeparators("\"//DGS1109N007/Echanges_SAA/Affichage/Messages/"+filename)+"\" -quality 100 "+QDir::toNativeSeparators("\"//DGS1109N007/Echanges_SAA/Affichage/Display/Messages/output.jpg"); myProcess.start(program); myProcess.waitForFinished(10000); }
the conersion is made only with the first file, but the qDebug()<<"filename"<<filename; print all files...
I try to put some waitForFinished but same result...
-
@filipdns
Hi
but dont you save all input files to the same filename (output.jpg) ? -
@mrjj hi, not, imagemagic rename output file itself like ouput-1.jpg output-2.jpg
-
@mrjj I openned an other topic for this problem because it's not linked with the title ;-)