Summary of the invention
In view of this, main purpose of the present invention is to provide a kind of by the method for batch picture uploading to network album, can shorten the uplink time of picture.
Another object of the present invention is to provide a kind of client, the uplink time of picture can be shortened.
For achieving the above object, technical scheme of the present invention is achieved in that
By the method for batch picture uploading to network album, comprising:
When client receives batch picture uploading instruction, start M simultaneously and compress thread and N number ofly upload thread, described M and N is positive integer;
Described compression thread is treated each width picture uploaded and is carried out compression process respectively, and joins in an image cache pond by the picture after process;
The each width picture joined in described image cache pond uploads in network album by described thread of uploading respectively.
A kind of client, comprising:
Described receiver module, for after receiving the instruction of batch picture uploading, notifies that described processing module performs self function;
Described processing module, for after the notice receiving described receiver module, start M simultaneously and compress thread and N number ofly upload thread, described M and N is positive integer; Wherein, described compression thread is used for carrying out compression process respectively to each width picture to be uploaded, and by process after picture join in an image cache pond, described in upload thread for being uploaded to respectively in network album by each width picture joined in described image cache pond.
Visible, adopt technical scheme of the present invention, when needs carry out batch picture uploading, client can start M compression thread simultaneously and N number ofly upload thread, compress thread and upload thread and carry out parallel processing, namely compress thread treat each width picture uploaded carry out respectively compression process, and the picture after process is joined in image cache pond, simultaneously, upload thread each width picture joined in image cache pond is uploaded in network album respectively, that is, while picture being carried out to compression process, namely processed good picture is being uploaded, while uploading processed good picture, untreated picture is being carried out to compression process again, thus shorten the uplink time of picture widely.
Embodiment
For problems of the prior art, propose a kind of by the scheme of batch picture uploading to network album in the present invention, the uplink time of picture can be shortened.
For make technical scheme of the present invention clearly, understand, to develop simultaneously embodiment referring to accompanying drawing, scheme of the present invention be described in further detail.
Fig. 2 is that the present invention is by the flow chart of batch picture uploading to the embodiment of the method for network album.As shown in Figure 2, comprising:
Step 21: when client receives batch picture uploading instruction, start M simultaneously and compress thread and N number ofly upload thread, M and N is positive integer.
When user needs to carry out batch picture uploading, corresponding instruction can be sent to used client, as clicked a certain button on human-computer interaction interface, after client receiving instruction, starting M simultaneously and compress thread and N number ofly upload thread.
M and N is positive integer, and concrete value all can be decided according to the actual requirements, and the value of M with N can be identical, also can be different.
Step 22: compression thread is treated each width picture uploaded and carried out compression process respectively, and joins in an image cache pond by the picture after process; Upload thread each width picture joined in image cache pond is uploaded in network album respectively.
In this step, under the prerequisite keeping certain definition, compression thread is treated each width picture uploaded and is carried out compression process respectively, and is joined in image cache pond by the picture after process.
Mention, most of network album provider, in order to save the memory space of server, all can require that client is by before in picture uploading to server, first compresses picture, to reduce the volume of picture under the prerequisite keeping certain definition before.
Usually, server can issue an index to client, for illustration of the volume requirement of the every width picture after uploading, such as can not more than 0.5M, so, client can according to the volume of each width picture to be uploaded, determine to adopt which kind of compress mode voluntarily, such as Lossless Compression mode, or lossy compression method mode, or the mode that Lossless Compression and lossy compression method combine.
Lossless Compression refers to and adopts certain algorithm to represent the data message of repetition, and picture can reduce completely, can not affect image content, and picture detail also can not be made to have loss; Lossy compression method then has certain change to picture, more monochrome information is remained when preserving picture, and form and aspect and the information of colorimetric purity and the pixel of surrounding are merged, the ratio merged is different, the ratio of compression is also different, because amount of information decreases, therefore compression ratio can be very high, but picture quality also can correspondingly decline.
Compared to Lossless Compression, lossy compression method can reduce picture volume better.
In actual applications, for each width picture to be uploaded, can, respectively by the difference between the picture volume comparing its actual volume and server requirement, determine flexibly to adopt Lossless Compression mode or lossy compression method mode, or both modes of combining.
How to carry out Lossless Compression and lossy compression method is prior art.
The space size in image cache pond also can be decided according to the actual requirements, and is not restricted in the present invention.
In addition, when carrying out compression process to each width picture to be uploaded, usually can follow certain order, specifically follow which kind of order and be not restricted, can be preset by user.
Such as, each width picture to be uploaded to be when user once travels the photo of shooting, so then can carry out compression process by the order after arriving first to each photos according to shooting time.
While compression thread carries out compression process, upload thread and each width picture joined in image cache pond is uploaded in network album respectively.
Usually, upload thread each width picture joined in image cache pond to be uploaded in network album respectively by the order after arriving first according to the joining day.
Further, upload thread after often uploading in a width picture to network album, uploaded picture to be about to and to delete from image cache pond, to save the memory space in image cache pond.
Visible, in embodiment illustrated in fig. 1, when needs carry out batch picture uploading, client can start M compression thread simultaneously and N number ofly upload thread, compress thread and upload thread and carry out parallel processing, namely compress thread treat each width picture uploaded carry out respectively compression process, and the picture after process is joined in image cache pond, simultaneously, upload thread each width picture joined in image cache pond is uploaded in network album respectively, that is, while picture being carried out to compression process, namely processed good picture is being uploaded, while uploading processed good picture, untreated picture is being carried out to compression process again, thus shorten the uplink time of picture widely.
In theory, the value of M and N is larger, more can shorten the uplink time of picture, but the value of M and N is larger, and the load of client is also larger, therefore, needs the value determining M and N according to actual conditions.
Usually, in actual applications, the value of M and N is 1, Fig. 3 and is when the value of M and N is 1, according to mode of the present invention by the process schematic of batch picture uploading to network album.As shown in Figure 3, thread a (compression thread) is respectively to picture A, picture B and picture C etc. carry out compression process, and the picture after process is joined in image cache pond, simultaneously, thread b (uploading thread) is respectively by the picture A after process, picture B, picture C etc. uploads in network album by network, and, in order to save the memory space in image cache pond, thread b is after uploading in network album by picture A, picture A can be deleted from image cache pond, equally, after picture B is uploaded in network album, picture B can be deleted from image cache pond, after picture C is uploaded in network album, picture C can be deleted from image cache pond, the like.
If one or two the value in M and N is not 1, value as M is 2, the value of N is 1, and supposes that 2 compression threads are respectively thread a and thread b, so, can while compression process being carried out to picture A by thread a, carry out compression by thread b to picture B to process, afterwards, by thread a, compression is carried out to picture C and process, carry out compression by thread b to picture D to process simultaneously, the like.
So far, the introduction about the inventive method embodiment is namely completed.
Based on above-mentioned introduction, Fig. 4 is the composition structural representation of client embodiment of the present invention.As shown in Figure 4, comprising:
Receiver module, for after receiving the instruction of batch picture uploading, notification handler module performs self function;
Processing module, for after receiving the notice of receiver module, start M simultaneously and compress thread and N number ofly upload thread, M and N is positive integer; Wherein, compression thread is used for carrying out compression process respectively to each width picture to be uploaded, and is joined in an image cache pond by the picture after process, uploads thread for being uploaded to respectively in network album by each width picture joined in image cache pond.
The specific works flow process of client shown in Fig. 4 is as follows:
After receiver module receives the batch picture uploading instruction of user, notice Executive Module performs self function; After Executive Module receives the notice of receiver module, start M simultaneously and compress thread and N number ofly upload thread; For each width picture to be uploaded, under the prerequisite keeping certain definition, M compression thread carries out compression process to it respectively according to predefined procedure, compress mode can be: the mode that lossy compression method mode, Lossless Compression mode, lossy compression method and Lossless Compression combine, and joins in image cache pond by the picture after every width process; Meanwhile, the each width picture joined in image cache pond was uploaded in network album by the order after arriving first according to the joining day by N number of thread of uploading respectively, and, uploading thread can after often uploading in a width picture to network album, be about to uploaded picture delete from image cache pond, to save the memory space in image cache pond.
The concrete value of M and N all can be decided according to the actual requirements, and usually, the value of M and N is 1.
Client shown in Fig. 4 can refer to PC or mobile terminal etc.
Visible, in embodiment illustrated in fig. 4, when needs carry out batch picture uploading, client can start M compression thread simultaneously and N number ofly upload thread, compress thread and upload thread and carry out parallel processing, namely compress thread treat each width picture uploaded carry out respectively compression process, and the picture after process is joined in image cache pond, simultaneously, upload thread each width picture joined in image cache pond is uploaded in network album respectively, that is, while picture being carried out to compression process, namely processed good picture is being uploaded, while uploading processed good picture, untreated picture is being carried out to compression process again, thus shorten the uplink time of picture widely.
And scheme of the present invention has the scope of application widely, such as, for the network album in the communal space in social networks, when batch picture uploaded wherein by needs, scheme of the present invention can be adopted.
In addition, for user, after adopting scheme of the present invention, only need choose each width picture to be uploaded and send the instruction of batch picture uploading, subsequent treatment all can be completed by client and server automatically, convenient quick again.
Therefore, scheme of the present invention is applicable to universal and promotes very much, has broad application prospects.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment made, equivalent replacement, improvement etc., all should be included within the scope of protection of the invention.