PDA

View Full Version : Download image synchronously, check size and resize it in Qt.



moreo
29th May 2015, 23:25
Hello. I'm new to qt. First of all sorry for my english.

I want to download image from remote server synchronously.

For this i need:
1) Check size of image before downloading (Cancel downloading if size is bigger then some limit)
2) Download SYNCHRONOUSLY (In my case I need this instead asynchronous)
3) Sequre file (eg to prevent some bash script injections etc).
4) Resize image to some default value (eg. reduce to some MaxWidth and MaxHeight or MaxKb if need) and convert to jpg (if file is png or something else).

How can I do this with Qt way?
I have read about QNetworkAccessManager and other classes, but I found only info about asynchronous download (using slots and signals).
Thank you.

P.S. I'm writing qt console application

anda_skoa
29th May 2015, 23:58
1) Check size of image before downloading (Cancel downloading if size is bigger then some limit)

Either by doing a head() call first or by deciding once you receive progress information.



2) Download SYNCHRONOUSLY (In my case I need this instead asynchronous)

You can always make an asynchronous operation synchronous, but why would you want to do that?



3) Sequre file (eg to prevent some bash script injections etc).

Whatever that means



4) Resize image to some default value (eg. reduce to some MaxWidth and MaxHeight or MaxKb if need) and convert to jpg (if file is png or something else).

QImage can do that.

Cheers,
_

moreo
30th May 2015, 00:10
Thanky you for replay.

I need synchronous approach because of my application workflow (Yes, may be it would be better to rewrite but I have no time). It's a console application and operations should go step by step.

Ok, I will try, thanks.

wysota
30th May 2015, 00:35
It's a console application and operations should go step by step.
I don't see how it requires the process to be synchronous.