CN105491398B - Image processing method, picture processing unit and picture processing platform - Google Patents

Image processing method, picture processing unit and picture processing platform Download PDF

Info

Publication number
CN105491398B
CN105491398B CN201410483969.9A CN201410483969A CN105491398B CN 105491398 B CN105491398 B CN 105491398B CN 201410483969 A CN201410483969 A CN 201410483969A CN 105491398 B CN105491398 B CN 105491398B
Authority
CN
China
Prior art keywords
picture
format
original image
compression
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201410483969.9A
Other languages
Chinese (zh)
Other versions
CN105491398A (en
Inventor
蔡述雄
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201410483969.9A priority Critical patent/CN105491398B/en
Publication of CN105491398A publication Critical patent/CN105491398A/en
Application granted granted Critical
Publication of CN105491398B publication Critical patent/CN105491398B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The present invention provides a kind of image processing method, obtain the attribute information of original image, original image is JPG picture, when the area of original image is not less than area threshold, it is converted into PNG and compresses, original image is also compressed, then the volume deviation of the two width pictures compared, when deviation is small and the color value of original image is greater than threshold value, select the compressed picture of former original image, otherwise the compressed picture of PNG format is selected, picture processing is carried out according to the attribute information of picture in the program, according to picture area, picture volume, the multifrequency natures such as color value are targetedly handled, reduce the volume of picture, it ensure that the quality of picture simultaneously, it is particularly suitable for the upload of picture, it shares during waiting, suitable picture format is provided for user, avoid as picture format it is inappropriate caused by picture The problems such as volume is excessive, bandwidth waste, poor image quality.

Description

Image processing method, picture processing unit and picture processing platform
Technical field
The present invention relates to picture process field, specifically a kind of image processing method and picture processing unit and figure Piece processing platform.
Background technique
With the development of the network information technology and electronic information technology and universal, electricity is commonly used in people in daily life Sub-pictures, such as mobile phone, digital camera all have the function of taking pictures, and the shared of many image informations becomes simple and convenient.In mesh In preceding many network platforms, all have the function of that picture is shared, such as upload head portrait, photograph album.User is using a figure When piece, it is often desired to which picture quality is good, small in size.But for a kind of picture of fixed format, in general picture Quality and volume be it is directly proportional, to obtain higher picture quality, which is necessarily required to meet certain size, therefore needs A tradeoff is done between picture image quality and volume size.
Such as in the network platform, when user selects uploading pictures, user pulls or clicks the figure for uploading a PNG32 format Piece, system carry out lossy compression according to the actual conditions of picture, and image size needed for making it meet the platform completes compression After return to new picture to user, downloading may be selected in user.Further, it is also possible to pair before and after being compressed to the picture of user's offer Than if user uploads the picture of jpeg format, carrying out a degree of lossy compression according to the quality of picture and size, keeping it full The requirement of pedal system platform, the new picture obtained after then compressing original image return to user, and show new picture and original The comparison of figure, user can choose downloading.In these schemes, picture upload format, be all by the format of original image Lai It determines, when the format of original image is not supported in the system platform, then can not upload.
To solve the above-mentioned problems, a kind of side of uploading pictures is disclosed in Chinese patent literature CN101808182A Transmission terminal and system in method, picture, the method for the uploading pictures include obtaining the picture letter for needing to be uploaded to picture sharing Web sites Breath judges the requirement to uploading pictures for needing the picture uploaded whether to meet picture sharing Web sites according to the information, is judged as When being, picture is uploaded to picture sharing Web sites, when being judged as NO, is carried out picture accordingly according to the requirement of picture sharing Web sites Conversion, then the picture after being converted is uploaded to picture sharing Web sites.In the program, user passes through blit in terminal such as PC machine When piece to picture sharing Web sites, the format for the uploading pictures that picture sharing Web sites are not supported can be converted into picture automatically and is total to by terminal It is uploaded to picture sharing Web sites again after enjoying the format of website support, picture thus may be implemented and upload automatically.But due to mesh The format for the uploading pictures that preceding picture sharing Web sites are supported is more and more diversified, and different its features of picture format is again different, should Scheme can not select optimal picture format in numerous picture formats, can not also optimize for different format pictures Processing.
Summary of the invention
For this purpose, technical problem to be solved by the present invention lies in can only carry out turning for format when the upload of picture in the prior art Change the compression with data, processing can not be targetedly optimized for the picture of different-format, to propose a kind of picture Processing method and the picture processing unit for using this method, and a kind of picture processing using the picture processing unit is provided simultaneously Platform.
A kind of image processing method is provided in order to solve the above technical problems, of the invention, including
The attribute information of original image is obtained, the original image is JPG format picture, the attribute information packet of the picture Include picture area and picture color value;
Judge whether the area of original image is less than area threshold, when be not less than area threshold when, then by original image into Row compression obtains the first format picture, and converts original image to after PNG format and compressed to obtain the second format picture, counts The volume deviation of the first format picture and the second format picture is calculated, if the volume deviation is less than deviation threshold and original image Color value is greater than color threshold, selects the first format picture, otherwise selects the body in the first format picture and the second format picture The small picture of product.
The present invention also provides a kind of picture processing units, comprising: extraction module: obtaining the attribute information of original image, institute Stating original image is JPG format picture, and the attribute information of the picture includes picture area and picture color value;
Judgment module: judging whether the area of original image is less than area threshold, if not, original image is compressed The first format picture is obtained, and converts original image to after PNG format and is compressed to obtain the second format picture, calculates first The volume deviation of format picture and the second format picture, if the volume deviation is less than the color value of deviation threshold and original image Greater than color threshold, the first format picture is selected, is otherwise selected small in size in the first format picture and the second format picture Picture.
In addition, the present invention also provides a kind of picture processing platform, including picture processing unit and storage equipment, the picture Processing unit is for handling picture, the server treated for storing picture processing unit picture.
The above technical solution of the present invention has the following advantages over the prior art,
(1) present invention provides a kind of image processing method, obtains the attribute information of original image, and original image is JPG figure Piece is converted into PNG and compresses, original image is also compressed, then when the area of original image is not less than area threshold The volume deviation of the two width pictures compared when deviation is small and the color value of original image is greater than threshold value, selects former original graph Otherwise the compressed picture of piece selects the compressed picture of PNG format, carry out picture according to the attribute information of picture in the program Processing, is targetedly handled according to multifrequency natures such as picture area, picture volume, color values, reduces the volume of picture, Ensure that the quality of picture simultaneously, be particularly suitable for picture upload, it is shared etc. during, provide the suitable of optimization for user Picture format, avoid as picture format it is inappropriate caused by picture volume is excessive, bandwidth waste, poor image quality the problems such as.
(2) the present invention also provides a kind of picture processing units, including extraction module and judgment module, and JPG figure may be implemented The processing of piece, the original image provided for user optimize processing, obtain in conjunction with the contents attribute and format characteristic of picture Preferred format and the form of expression are obtained, the expression way of picture is optimized.
(3) the present invention also provides a kind of picture processing platforms using above-mentioned picture processing unit, including picture processing dress Equipment is set and is stored, after picture to be treated is carried out above-mentioned processing via picture processing unit, is stored in storage equipment, It is effectively utilized the attribute of picture itself, improves the shared quality and uploading speed of picture.
Detailed description of the invention
In order to make the content of the present invention more clearly understood, it below according to specific embodiments of the present invention and combines Attached drawing, the present invention is described in further detail, wherein
Fig. 1 is the hardware environment schematic diagram that image processing method is run in embodiment of the present invention;
Fig. 2 is another hardware environment schematic diagram that image processing method is run in embodiment of the present invention;
Fig. 3 is another hardware environment schematic diagram that image processing method is run in embodiment of the present invention
Fig. 4 is the flow chart of the image processing method of the embodiment of the present invention 1;
Fig. 5 is the flow chart of the image processing method of the embodiment of the present invention 2;
Fig. 6 is the flow chart of the image processing method of the embodiment of the present invention 3;
Fig. 7 is the flow chart of the image processing method of the embodiment of the present invention 4;
Fig. 8 is the structure chart of the picture processing unit of the embodiment of the present invention 6;
Fig. 9 is the structure chart of the picture processing unit of the embodiment of the present invention 7.
Specific embodiment
In a particular embodiment, the plurality of picture processing method under present inventive concept is provided.Design structure of the invention Think to be handled according to the attribute information of picture picture, using the format information combination transparent characteristic of picture, picture area, The multifrequency natures such as picture volume, color value are targetedly handled, and while reducing picture volume, guarantee the matter of picture Amount.Since different image content is different, than if any picture color it is abundant, some picture colors are single, and some pictures contain Transparent part etc., different pictures have different characteristics, and also different the characteristics of various picture formats, some picture format colors Coloured silk is abundant, and some picture format data volumes are small, and the present invention is exactly that these characteristics are utilized, by the actual attribute of picture and various figures The characteristic of piece format combines, and is handled, thus guarantee picture effect while reducing picture volume to the greatest extent, it is especially suitable In picture upload, it is shared etc. during, provide suitable picture for user, avoid as picture format it is inappropriate caused by figure The problems such as piece volume is excessive, bandwidth waste, poor picture quality.
In this embodiment, the method application environment of picture processing can be that computer, mobile phone etc. can be to figures In the terminal device that piece is handled, as shown in Figure 1 and Figure 2, in such devices, user can select picture and carry out at picture Reason, picture stores in such devices after processing.The application environment of the image processing method may be website or some applications The server of program, as user can pass through the client of mobile phone or computer Website login or these application programs, user After selected picture, the picture upload onto the server in handled, as shown in figure 3, being handled simultaneously by server the picture completion Storage.
Embodiment 1:
A kind of JPG image processing method is provided in the present embodiment, the equipment for executing this method is computer, in the computer It is inside provided with and performs the following operations corresponding program instruction, the process which carries out picture processing is as shown in Figure 4.
User provides the original image of a JPG format.Jpeg format picture, also referred to as JPG format picture, are most common A kind of picture format, stop after file entitled " .GIF " or " .jpeg ", is organized to set up by a software development federation, is one Kind lossy compression format, JPEG compression technology is highly advanced, it removes the image data of redundancy with lossy compression mode, is obtaining The lively image of very abundant can be showed while high compression ratio, preferable image can be obtained with least disk space Quality.
The picture treatment process of the JPG format provided in the present embodiment for user is as follows, as shown in Figure 4:
Firstly, computer obtains the attribute information of original image, the attribute information of the picture includes picture area and figure Piece color value.Picture area refers to the length and wide product of picture.Picture color value refers to all pixels point for including in picture In possessed all colours quantity.General each pixel is indicated by one group of numerical value, is traversed in the picture All pixels point, this group of numerical value is identical, then it represents that identical color is classified as a kind of color;If it is different, then table Show different colors, color value increases one kind, has thus obtained all color values of the picture.
Then, computer judges whether the area of original image is less than area threshold, and area threshold is in the present embodiment 100*100 pixel is then compressed original image to obtain JPG format picture 1, and will be former when being greater than the area threshold Beginning picture is compressed to obtain PNG format image 2 after being converted into PNG format, then calculates the volume and PNG of JPG format picture 1 The volume of format picture 2.The volume of picture refers to the size of the occupied memory space of picture, if the size of picture is 1k, 1M Deng, picture volume size by its area, pixel number etc. many factors are comprehensive determines.Obtain the body of JPG format picture 1 After long-pending and PNG format image 2 volume, then the difference of the two volumes is calculated, as volume deviation, volume deviation is actually With regard to the difference of the volume of two width pictures.If the volume deviation is less than 40K and the color value of original image is greater than 30000 kinds, It selects JPG format picture 1 as treated picture, otherwise selects small in size in JPG format picture 1 and PNG format image 2 Picture as treated picture.
Original image is such as compressed to obtain JPG format picture 1, original image is converted by the compression in the above process To be compressed to obtain PNG format image 2 after PNG format, compression therein is all lossy compression.Lossy compression is according to human eye Characteristic (time lag etc.), reduce semaphore, signal itself has certain loss, that is, image quality has loss.This Compression ratio selection 75% in embodiment, in other modes, also can choose 70%-80%.
In above process, it after having obtained JPG format picture 1 and PNG format image 2, is shown due to JPG format Picture, color is relatively abundanter, if be greater than 30000 kinds in the more such as the present embodiment of color value, can pay the utmost attention to JPG format Graphic form, but the volume of picture cannot be allowed too big again, therefore in the case that two obtained width picture volumes are not much different It can preferentially select the picture 1 of JPG format as treated picture.When color value is few, then do not need preferentially to select The picture of JPG format, but consider to select picture small in size, to reduce the occupied space of picture.When volume difference compares When big, and consider small in size preferential, therefore is all select picture small in size as treated to scheme in the case of these Piece.
In other alternative embodiments, the area threshold can choose 500-22500 pixel, color threshold Value can choose the different color value of 20000-35000 kind, and volume deviation can choose within the scope of 20-50K.
Picture of the computer by above-mentioned processing mode, then after can be processed.The present invention is by the actual attribute of picture It is combined with the characteristic of JPG picture format, optimizes processing, thus the expression original image information that obtaining can be optimal Picture format and manifestation mode improve the expression effect of picture, be particularly suitable for picture upload, it is shared etc. during, be User provides the suitable picture format of optimization, avoid as picture format it is inappropriate caused by picture volume is excessive, bandwidth is unrestrained Take, poor image quality the problems such as.
Embodiment 2:
Another JPG image processing method is provided in the present embodiment, this method can be executed by mobile phone terminal, be used Family stores the original image that a format is JPG format in mobile phone, has in the mobile phone and executes following treatment process Instruction, so that following process flow is completed, as shown in figure 5, the attribute includes figure firstly, mobile phone reads original JPG picture attribute The pictures build-in attributes such as format information, area, color value, former compression ratio, the volume of piece, then mobile phone judges the face of original image Product, if it is less than 150*150 pixel, is then converted to PNG8 format for original image by program, as treated picture.
If the area of original image is not less than above-mentioned threshold value 150*150 pixel, mobile phone if, passes through program for original graph Piece carries out lossy compression and obtains JPG picture 1, and converts PNG24 format for original image and (can also turn in other embodiments It is changed to PNG32 format) lossy compression is carried out afterwards obtains PNG picture 2, then calculate the inclined of the volume of JPG picture 1 and PNG picture 2 Difference.If the color value of original image is greater than 20000 kinds and the volume deviation of compressed JPG picture 1 and PNG picture 2 is less than 50K then selects JPG picture 1 for the picture after optimization;If the color value of original image is less than or equal to 20000 kinds, or compression When the volume deviation of JPG picture 1 and PNG picture 2 afterwards is more than or equal to 50K, then select picture small in size as treated Picture.
A compression such as 70% or 80% can be preset during above-mentioned lossy compression, in mobile phone, according to The compression ratio carries out lossy compression.In other implementations, a suitable pressure can also be obtained according to current situation Contracting ratio needs to obtain at this time the former compression ratio of original image first, if the original compression ratio is greater than 75%, using 75% described in Compression ratio when lossy compression;If the former compression ratio of original image is less than 75%, using the former compression ratio of original image as institute Compression ratio when stating lossy compression is compressed.
After completion of the above process, as final picture, can also lead to above by the picture after handset processes It crosses mobile phone to be further processed, such as obtaining that treated, picture is compared with original image, if treated Picture format is identical as original image format, then direct output treated picture, is stored in the storage card of mobile phone;Such as not phase Together, then original image is subjected to compression acquisition and the consistent compressed picture of original image format, after the compressed picture and processing Picture export simultaneously, be stored in the storage card of mobile phone.More selections can be thus provided for user, meet user's Diversity requirement.
In other preferred implementations, mobile phone can also be original image after having carried out above-mentioned processing to picture The picture for exporting a WEBP format, is stored in mobile phone card.Due to the picture of the WEBP picture format, some places are obtained It uses, it is spare to export such width figure herein, also provides more convenience for user.It, can be with during picture output A plurality of types of pictures are exported as needed for user, user can according to need to select, using more convenient.
Embodiment 3:
A kind of processing method of PNG picture is provided in the present embodiment, the equipment for executing this method is server, in server In be stored with the instruction code for executing following processes, user provides user in website and selects picture by mobile phone Website login Interface, when user, which selectes PNG picture, to be uploaded, server obtains the information of the picture, and the picture is handled as follows, stream Journey figure is as shown in Figure 6:
Firstly, server determines the attribute information for the PNG picture that user selectes, the attribute information include transparent characteristic, Area, color value.
PNG format image, i.e., portable network graphic (PNG, Portable Network Graphics), is a kind of figure As file format.PNG is capable of providing the lossless compression image file of length ratio GIF small 30%.PNG format has 8,24,32 The three kinds of forms in position, wherein 8 PNG support two different transparent forms (index is transparent and alpha is transparent), 24 PNG are not propped up Hold transparent, 32 PNG increase 8 transparent channels on the basis of 24, therefore can show 256 grades of transparencies.PNG8 and The subsequent number of PNG24 is then the color value for representing this PNG format and at most can indexing and store." 8 " represent 28 powers Namely 256 colors, and 24 24 powers for representing 2 probably have ten thousand color more than 1600.
The area and color value of picture were introduced in the above-described embodiments, and details are not described herein.The transparent characteristic of picture is Refer to and whether there is transparent pixel in picture, if there are transparent pixels in picture, then it is assumed that the picture is translucent Picture, if transparent pixel is not present in the picture, that is, all pixels are all opaque, then it is assumed that the figure Piece is not translucent picture.Whether pixel is transparent to be indicated by alpha channel (Alpha Channel).
Since the pictorial information for including in PNG picture is more, in order to reduce the volume of picture, server is first to original PNG picture carries out lossless compression, and getting rid of does not influence the information that picture shows quality.Lossless compression is to close video signal And arrange, signal itself does not lose.Picture after original image is carried out without compressing, as subsequent processing.
Then, server further judges the transparent characteristic of original image, when transparent pixels point is not present, judges picture Area or picture color value, if picture area is less than 100*100 pixel or picture color value is less than 30000 kinds different When color, then PNG8 format picture is converted by the PNG picture after above-mentioned lossless compression;Otherwise, that is, the area of picture not Less than the color value of 100*100 pixel and picture not less than in the case where 30000 kinds, by the PNG picture after lossless compression into Row compression obtains a width picture, and the PNG picture after the lossless compression is converted to compressed to obtain again after JPG format it is another Secondary picture, the then volume of more compressed two width picture select picture small in size after compression as treated picture, By treated, picture is stored in the server, is provided for user and the functions such as is checked, downloads.
In other alternative embodiments, the threshold value of above-mentioned area is also an option that 500-22500 pixel, such as 150*150 pixel;Above-mentioned color threshold can choose the different color value of 20000-35000 kind, and such as 20000 kinds, 25000 kinds Or 35000 kinds.
In image processing method provided in this embodiment, the original PNG picture that user selectes is carried out by server Processing carries out picture processing according to the attribute information of picture in the program, according to the transparent characteristic of picture, color value and area into Row judgement, realizes and preferably shows original image information with lesser picture volume, improve the property of picture quality and volume Valence ratio, be particularly suitable for picture upload, it is shared etc. during, provide the suitable picture of optimization for user, avoid due to scheming The problems such as picture volume caused by piece format is inappropriate is excessive, bandwidth waste.
Embodiment 4:
Another PNG image processing method is provided in the present embodiment, original image format is PNG, processing stream herein Journey is as shown in Figure 2.The equipment for realizing this method is tablet computer, and user is selected in present in the computer using tablet computer Picture is stored with the program instruction performed the following operations in the tablet computer, completes to select user by running the instruction The process that is handled of picture, flow chart is as shown in Figure 7.
After user selectes picture, firstly, tablet computer executes the instruction of PNG picture processing, the figure after obtaining lossless compression The attribute of piece, the former compression ratio of area, color value, transparent characteristic and picture including picture.The compression ratio of picture refers to logical The compression ratio of digital imagery size and original image after crossing encoder compresses as Digital size.Then, nothing is carried out to original PNG picture Damage compression, the picture after obtaining lossless compression.
Then, program therein is called by tablet computer, judges such as to deposit in original image with the presence or absence of transparent pixel In transparent pixel, then the original image is translucent picture, and if there is no transparent pixel, then the picture is not Translucent picture.In the process, if there are transparent pixels in original image, the picture after lossless compression is carried out Lossy compression that compression ratio is 75% is simultaneously converted into the picture with transparent PNG8 format, and 75% compression ratio herein is excellent The compression ratio of choosing, compression proximate to it such as 70-80% also may be implemented.
When being judged as NO, that is to say, that transparent pixel is not present in original image, then further judges original image Area or color value, if area is less than 150*150 pixel or picture color value less than 35000 kinds, after lossless compression Picture be converted into PNG8 format;Otherwise the picture after lossless compression is converted into JPG format, and by the JPG format after conversion Original PNG format image after picture and lossless compression carries out lossy compression respectively, and compression ratio can be set to 70%, so After compare compressed picture volume, select the picture of format small in size as treated picture, be stored in tablet computer In.
After completion of the above process, it can will be deposited above by tablet computer treated picture as final picture Storage, can also be further processed by tablet computer, and such as obtaining that treated, picture compares with original image Compared with if treated, picture format is identical as original image format, directly output treated picture, is stored in plate electricity In the hard disk of brain;If not identical, then original image is subjected to compression acquisition and the consistent compressed picture of original image format, by this Picture exports compressed picture simultaneously and is stored in tablet computer and selects for user with treated.It can thus be mentioned for user For more selecting, meet the diversity requirement of user.
In other preferred implementations, tablet computer can also be original after having carried out above-mentioned processing to picture Picture exports the picture of a WEBP format, and is stored in the hard disk of tablet computer.Due to the picture of the WEBP picture format, Popularization and use has been obtained, it is spare to export such width figure herein, also provides more convenience for user.It is defeated in picture During out, it can according to need and export a plurality of types of pictures for user, user can according to need to select, using more It is convenient.
Embodiment 5:
The processing method of the picture for JPG format is given in above-described embodiment 1 and 2, specifically:
The attribute information of original image is obtained, the original image is JPG format picture, the attribute information packet of the picture Include picture area and picture color value;Judge whether the area of original image is less than area threshold, when being not less than area threshold, Then original image is compressed to obtain the first format picture, and converts original image to after PNG format and is compressed to obtain Second format picture calculates the volume deviation of the first format picture and the second format picture, if the volume deviation is less than deviation The color value of threshold value and original image is greater than color threshold, selects the first format picture, otherwise selects the first format picture and the Picture small in size in two format pictures.
The processing method for PNG format image is given in above-described embodiment 3 and 4, method particularly includes:
Firstly, determine the attribute information of original image, wherein the original image is PNG format image, the attribute letter Breath includes transparent characteristic, area, color value;Then, lossless compression is carried out to original image and obtains intermediate picture;Next, it is determined that The transparent characteristic of the original image judges the area or color value of original image, if former when transparent pixels point is not present Beginning picture area is less than area threshold or original image color value is less than color threshold, then converts PNG8 for the intermediate picture Format picture;Otherwise the intermediate picture is compressed, and is pressed again after the intermediate picture is converted to JPG format Contracting, the volume of more compressed two width picture, picture small in size after selection compression.
A kind of image processing method is provided in the present embodiment, in conjunction with above two picture processing mode, can be selected automatically It takes format and is converted, select suitable compression algorithm, the picture that obtains that treated.The hardware environment for realizing this method is clothes The computer of business device, the server and user connect, and the interface of user's uploading pictures is provided on the computer of user, and server is logical The picture of interface captures user selection is crossed, and carries out picture processing.For the picture that user uploads, server can be according to picture Format and other property parameters determine that the picture is to select PNG or JPG format, determine compressed picture body further according to algorithm Long-pending compression ratio.Process is as follows:
Step 1: user uploads a picture (PNG or JPG format) by the upload interface in computer, and server obtains should The transparent characteristic of picture, picture format, picture color value, picture area, picture volume, the category of picture original compression ratio etc. picture Property parameter, then carry out step 2 operation.The meaning of these property parameters by the agency of mistake in the above-described embodiments, herein not It repeats again.
Step 2: server judges the format of picture, if picture format is PNG, carries out first to original PNG picture lossless Then compression judges original PNG picture with the presence or absence of transparent pixel (whether being with translucent picture), if so, holding Row step 3 executes step 4 if not being.If picture is not PNG format and is JPG format, 6 are thened follow the steps.
Step 3: lossy compression is carried out to original PNG picture and is converted into the picture with alpha transparent png8 format simultaneously, It is preferred value through a large amount of pictures test 75% so selecting 75% compression ratio when lossy compression since original image is PNG.
Step 4: picture is to judge the area of original image, such as original graph at this time there is no the PNG picture of transparent pixels point The area of piece is less than 100*100 pixel or picture color value is less than 30000 kinds, then by the picture after lossless compression in step 2 Switch to the picture of PNG8 format.If it is not, executing step 5.
Step 5: the PNG picture after lossless compression in step 2 being converted into JPG format, then by the picture of the JPG format Lossy compression is carried out, and the PNG picture after lossless compression is also subjected to lossy compression, compression ratio is all 75%, then compares compression Picture volume afterwards exports picture small in size as treated picture, and is stored in the hard disk of server.
Step 6: picture is JPG format, obtains the former compression ratio of picture first, if compression ratio is greater than 75%, after specifying The compression ratio of continuous lossy compression is 75%, if specifying the compression ratio of subsequent lossy compression is picture original compression ratio less than 75%.If Picture area is less than 100*100, converts picture into the picture of PNG8 format.If it is not, executing step 7.
Step 7: picture being converted into PNG format, can according to need herein and be converted into PNG24 or PNG32, the present embodiment In be converted to PNG32 format, by original JPG picture progress lossy compression obtain JPG picture 1, which is carried out Lossy compression obtains PNG picture 2, the compression ratio that compression ratio is obtained according to step 6.If original image color value is greater than 30000 simultaneously And the volume deviation of JPG picture 1 and PNG picture 2 is when being less than 50k, then using JPG picture 1 as the picture after preferred;Otherwise, If picture color value less than 30000 or when the volume deviation of JPG picture 1 and PNG picture 2 is greater than or equal to 50k, compares two kinds The picture volume of format selects the picture of format small in size as treated picture, is stored in the hard disk of server.This Difference of the volume deviation of two width pictures in embodiment actually with regard to the volume of two width pictures.
Step 8: executed above step, server obtain one it is consistent with original image format or converted picture format Picture, if obtaining the picture different from original image format, continue to original image carry out a lossy compression after obtain with The identical compressed picture of original image format, while exporting the compressed picture and converted format treated picture, it deposits Storage is in the hard disk of server, if obtaining the identical picture of picture format, directly exports, is stored in the hard disk of server.This When can also will converted the picture after format analysis processing and carry out once format conversion, be converted to the format of original image, then one And it is output in the hard disk of server.The picture type of output can select according to the needs of users, and execute step 9.
Step 9: the picture for exporting a WEBP format for original image is spare (chrome support), is stored in the hard disk of server In.
Step 10: server can also by all picture presentations exported after above-mentioned processing in the computer interface of user, It selects, while can also recommend for user one such or several for user.
Image processing method in the present embodiment can be used for server and handle picture, support user customized Compression ratio and batch processing.Suitable picture format can be selected for user automatically, avoid making since picture format is inappropriate At picture volume it is excessive, the problems such as bandwidth waste.
In addition, for the original image of the formats such as picture such as bmp, gif of extended formatting, it can also be in present inventive concept Under enlightenment, according to the own characteristic of these picture formats and the characteristics of other property parameters of the picture, format conversion and pressure are carried out Contracting optimization, the picture optimized.
For example, being not processed if original image is dynamic gif picture, if original image is static gif, turn It is changed to the picture of jpg format, then reduced volume, because jpg is better than gif in image quality, but volume is not necessarily, finally chooses The picture of picture small in size as output.
Embodiment 6:
A kind of picture processing unit is provided in the present embodiment, is handled for the picture to PNG format, structural block diagram is such as Shown in Fig. 8, including
Property extracting module: determining the attribute information of original image, wherein the original image is PNG format image, institute Stating attribute information includes transparent characteristic, area, color value;
Lossless compression modules: lossless compression is carried out to original image and obtains intermediate picture;
Judge conversion module: judging the transparent characteristic of the original image, when transparent pixels point is not present, judges original The area or color value of picture, if original image area is less than area threshold or original image color value is less than color threshold, Then PNG8 format picture is converted by the intermediate picture;Otherwise the intermediate picture is compressed, and by the middle graph Piece is compressed again after being converted to JPG format, the volume of more compressed two width picture, figure small in size after selection compression Piece.
Preferably, judge that conversion module is also used to judge when there are transparent pixels point, then to intermediate picture compression and turn Turn to the picture with transparent PNG8 format.
It is further preferred that judging that the compression in conversion module is lossy compression.
The compression ratio of lossy compression described in the present embodiment is 75%, and the area threshold is 10000 pixels, the face Chromatic threshold value is 30000 kinds of different colours.In other implementations, the compression ratio of the lossy compression is 70%-80%, institute Stating area threshold is 500 pixels to 22500 pixels, and the color threshold is 20000 to 35000 kinds of different colours.
The optimization processing to PNG format image may be implemented in picture processing unit in the present embodiment, provides for user Original image optimize processing in conjunction with the contents attribute and format characteristic of picture, obtain preferred format and performance shape Formula optimizes the expression way of picture.
Embodiment 7:
Another picture processing unit is provided in the present embodiment, is handled for the picture to JPG format, structural frames Figure is as shown in figure 9, include
Extraction module: obtaining the attribute information of original image, and the original image is JPG format picture, the picture Attribute information includes picture area and picture color value;
Judgment module: judging whether the area of original image is less than area threshold, if not, original image is compressed The first format picture is obtained, and converts original image to after PNG format and is compressed to obtain the second format picture, calculates first The volume deviation of format picture and the second format picture, if the volume deviation is less than the color value of deviation threshold and original image Greater than color threshold, the first format picture is selected, is otherwise selected small in size in the first format picture and the second format picture Picture.
Preferably, the judgment module is also used to judge whether the area of original image is less than area threshold, if so, then will Original image is converted to PNG8 format picture.
In addition, the boil down in the judgment module is lossy compression.
In other implementations, the attribute information further includes the former compression ratio of original image, the judgment module Further include obtaining compression ratio submodule: the compression ratio of the lossy compression is obtained, if the former compression ratio of original image is greater than 75%, then using 75% as the lossy compression compression ratio;If the former compression ratio of original image is less than 75%, with original Compression ratio when the former compression ratio of picture is the lossy compression.
In the present embodiment, first format picture is JPG format picture, and second format picture is PNG format figure Piece.The area threshold is 10000 pixels, and the color threshold is 30000 kinds of different colours, and the volume deviation threshold value is 50k.In other embodiments,.The area threshold is 500 pixels to 22500 pixels, and the color threshold is 20K to 50k may be selected in 20000-35000 kind different colours, the volume deviation threshold value.
The optimization processing to JPG format picture may be implemented in picture processing unit in the present embodiment, provides for user Original image optimize processing in conjunction with the contents attribute and format characteristic of picture, obtain preferred format and performance shape Formula optimizes the expression way of picture.
Embodiment 8:
A kind of picture processing platform is provided in the present embodiment, while including the picture processing unit in above-described embodiment 6 and 7 With storage equipment, for the picture processing unit for handling picture, the storage equipment is right for the picture that stores that treated The picture is handled, and can be used in the services such as the picture upload in website, shared, storage.It is flat in the processing of other pictures In platform, any picture processing unit in above-described embodiment 6 or 7 can also be only included.
The picture processing platform is a kind of intelligent image platform, also referred to as intelligence figure platform.User is using a picture When, it is often desired to picture quality is good, small in size, this needs does a tradeoff between picture image quality and volume.Intelligence figure platform The picture compression demand of PNG, JPEG, GIF multiple format is blended together, the operability and selectivity of user are more convenient.
Meanwhile intelligence figure platform is embodied in intelligence.User is often not clear a picture when selecting picture format PNG format or jpeg format should be used, is using PNG32 or PNG8 or alpha+PNG8, so intelligence figure platform In picture processing unit help the suitable and optimal picture format of user's automatic conversion, as recommending format to be pushed to use Family.Since the picture of WEBP format now starts gradually popular, intelligence figure platform also will be the figure of user's conversion portion WEBP format The picture volume of piece, WEBP format can be smaller relative to JPEG, and image quality is more preferable.
The technology used mainly includes the library HTML5 File API, ImageMagick, the library PNGCRUSH, the library PNGQUANT, And the picture optimized treatment method in above-described embodiment.Wherein, HTML5 File API: provide user pull uploading pictures with Click the foreground interface of uploading pictures.ImageMagick provides picture switching foundation, provides picture compression, picture WEBPization etc. Image converting method.PNGCRUSH realizes PNG lossless compression algorithm library.PNGQUANT realizes PNG Lossy Compression Algorithm library.
In the processing routine of picture processing unit, the image processing method in above-mentioned other embodiments is utilized, according to The format and attribute of current image are handled, such as, original image JPEG, first acquisition original image attribute, further according to original image attribute, needle Whether picture, which properly switchs to the picture of PNG or PNG8, is judged to the parameter (color value number, area value, transparency etc.) of picture, most The volume of comparison front and back picture afterwards, preferentially adopts.It has all been discussed in detail in the specific embodiment of method in front, it is no longer superfluous It states.
Concrete operations are as follows:
(1) enter the page, (picture format can be for user's click one picture of upload or one picture of pulling upload PNG,JPEG,GIF)
(2) picture processing platform is that user selects suitable compression quality and recommends suitable picture format automatically.
(3) user can compare the image quality of new picture and original image on the page, provide panorama sketch comparison and thumbnail comparison.
(4) if the image quality volume of dissatisfied picture, user may be selected other compression ratios and re-compress picture.
(5) user can download the new picture after conversion.
(6) batch uploading pictures, batch download pictures are supported.
Picture processing platform in the present embodiment, will need to upload or shared picture by being carried out after above-mentioned processing on It passes, improves the quality of picture.
Obviously, the above embodiments are merely examples for clarifying the description, and does not limit the embodiments.It is right For those of ordinary skill in the art, can also make on the basis of the above description it is other it is various forms of variation or It changes.There is no necessity and possibility to exhaust all the enbodiments.And it is extended from this it is obvious variation or It changes still within the protection scope of the invention.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more, The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces The form of product.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
Although preferred embodiments of the present invention have been described, it is created once a person skilled in the art knows basic Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as It selects embodiment and falls into all change and modification of the scope of the invention.

Claims (19)

1. a kind of image processing method, which is characterized in that including
The attribute information of original image is obtained, the original image is JPG format picture, and the attribute information of the picture includes figure Piece area and picture color value, the picture color value refer to the quantity of possessed color in the pixel for including in picture;
Judge whether the area of original image is less than area threshold, when being not less than area threshold, then presses original image Contracting obtains the first format picture, and converts original image to after PNG format and is compressed to obtain the second format picture, calculates the The volume deviation of one format picture and the second format picture, if the volume deviation is less than volume deviation threshold value and original image Color value is greater than color threshold, selects the first format picture, otherwise selects the body in the first format picture and the second format picture The small picture of product, wherein first format picture is JPG format picture, second format picture is PNG format image.
2. the method according to claim 1, wherein judge whether the area of original image is less than area threshold, If so, original image is then converted to PNG8 format picture.
3. method according to claim 1 or 2, which is characterized in that described to be compressed original image to obtain the first lattice Formula picture, and convert original image to and compressed to obtain in the processing of the second format picture after format to be selected, the compression For lossy compression.
4. according to the method described in claim 3, it is characterized in that, the attribute information further includes the former compression of original image Than.
5. according to the method described in claim 4, it is characterized in that, further including having described in acquisition before the lossy compression The process of the compression ratio of compression is damaged, if the former compression ratio of original image is greater than 75%, using 75% as the lossy compression Compression ratio;If the former compression ratio of original image is less than 75%, with the former compression ratio of original image for the lossy compression When compression ratio.
6. method according to claim 1 or 2, which is characterized in that the area threshold is 500 to 22500 pixels, institute Stating color threshold is 20000-35000 kind different colours.
7. method according to claim 1 or 2, which is characterized in that the area threshold is 10000 pixels, the face Chromatic threshold value is 30000 kinds of different colours.
8. method according to claim 1 or 2, which is characterized in that the volume deviation threshold value is 20K to 50k.
9. method according to claim 1 or 2, which is characterized in that the volume deviation threshold value is 50k.
10. a kind of picture processing unit, including
Extraction module: obtaining the attribute information of original image, and the original image is JPG format picture, the attribute of the picture Information includes picture area and picture color value, and the picture color value refers to possessed face in the pixel for including in picture The quantity of color;
Judgment module: judging whether the area of original image is less than area threshold, if not, original image is compressed to obtain First format picture, and convert original image to after PNG format and compressed to obtain the second format picture, calculate the first format The volume deviation of picture and the second format picture, if the volume deviation is less than the color value of volume deviation threshold value and original image Greater than color threshold, the first format picture is selected, is otherwise selected small in size in the first format picture and the second format picture Picture, wherein first format picture is JPG format picture, second format picture is PNG format image.
11. device according to claim 10, which is characterized in that the judgment module is also used to judge the face of original image Whether product is less than area threshold, if so, original image is then converted to PNG8 format picture.
12. device described in 0 or 11 according to claim 1, which is characterized in that the boil down in the judgment module is Lossy compression.
13. device according to claim 12, which is characterized in that the attribute information further includes the former compression of original image Than.
14. device according to claim 13, which is characterized in that the judgment module further includes obtaining compression ratio submodule Block: obtaining the compression ratio of the lossy compression, if the former compression ratio of original image is greater than 75%, has described in using 75% Damage the compression ratio of compression;If the former compression ratio of original image less than 75%, has with the former compression ratio of original image to be described Compression ratio when damage compression.
15. device described in 0 or 11 according to claim 1, which is characterized in that the area threshold is 500 pixels to 22500 Pixel, the color threshold are 20000-35000 kind different colours.
16. device described in 0 or 11 according to claim 1, which is characterized in that the area threshold is 10000 pixels, described Color threshold is 30000 kinds of different colours.
17. device described in 0 or 11 according to claim 1, which is characterized in that the volume deviation threshold value is 20K to 50k.
18. device described in 0 or 11 according to claim 1, which is characterized in that the volume deviation threshold value is 50k.
19. a kind of picture processing platform using any one of claim 10-18 described device, which is characterized in that including Picture processing unit and storage equipment, the picture processing unit is for handling picture, and the storage equipment is for depositing Store up the picture processing unit treated picture.
CN201410483969.9A 2014-09-19 2014-09-19 Image processing method, picture processing unit and picture processing platform Active CN105491398B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410483969.9A CN105491398B (en) 2014-09-19 2014-09-19 Image processing method, picture processing unit and picture processing platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410483969.9A CN105491398B (en) 2014-09-19 2014-09-19 Image processing method, picture processing unit and picture processing platform

Publications (2)

Publication Number Publication Date
CN105491398A CN105491398A (en) 2016-04-13
CN105491398B true CN105491398B (en) 2019-06-28

Family

ID=55678063

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410483969.9A Active CN105491398B (en) 2014-09-19 2014-09-19 Image processing method, picture processing unit and picture processing platform

Country Status (1)

Country Link
CN (1) CN105491398B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108111858B (en) * 2016-11-24 2020-06-05 腾讯科技(深圳)有限公司 Picture compression method and device
CN107105341B (en) * 2017-03-30 2020-02-21 联想(北京)有限公司 Video file processing method and system
CN106998487A (en) * 2017-04-27 2017-08-01 努比亚技术有限公司 image processing method, device and mobile terminal
CN108920548A (en) * 2018-06-14 2018-11-30 上海爱优威软件开发有限公司 The multi-format storage method and system of photo
CN109271540B (en) * 2018-09-26 2021-05-25 浙江万朋教育科技股份有限公司 Implementation method for combining picture lossy compression and recording transparency information

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1681288A (en) * 2004-03-19 2005-10-12 株式会社理光 Image processing apparatus, image data generation and transmission method and image data generation and transmission program
CN102957906A (en) * 2011-08-29 2013-03-06 广州九游信息技术有限公司 Method and system for image classifying compression
CN102984151A (en) * 2012-11-26 2013-03-20 北京奇虎科技有限公司 Method and server for providing picture data for computing terminal
CN103826028A (en) * 2012-11-19 2014-05-28 腾讯科技(深圳)有限公司 Method and device for compressing picture in lossless way

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4950929B2 (en) * 2008-04-01 2012-06-13 キヤノン株式会社 Image file editing apparatus, image file editing method and program
JP4775454B2 (en) * 2009-02-13 2011-09-21 富士ゼロックス株式会社 Image communication apparatus and image communication control program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1681288A (en) * 2004-03-19 2005-10-12 株式会社理光 Image processing apparatus, image data generation and transmission method and image data generation and transmission program
CN102957906A (en) * 2011-08-29 2013-03-06 广州九游信息技术有限公司 Method and system for image classifying compression
CN103826028A (en) * 2012-11-19 2014-05-28 腾讯科技(深圳)有限公司 Method and device for compressing picture in lossless way
CN102984151A (en) * 2012-11-26 2013-03-20 北京奇虎科技有限公司 Method and server for providing picture data for computing terminal

Also Published As

Publication number Publication date
CN105491398A (en) 2016-04-13

Similar Documents

Publication Publication Date Title
CN105491398B (en) Image processing method, picture processing unit and picture processing platform
US11200916B2 (en) Highlighting media through weighting of people or contexts
CN108810622B (en) Video frame extraction method and device, computer readable medium and electronic equipment
CN108632625A (en) A kind of method for video coding, video encoding/decoding method and relevant device
US20210160556A1 (en) Method for enhancing resolution of streaming file
CN104917666B (en) A kind of method and apparatus making personalized dynamic expression
JP4810443B2 (en) Apparatus and method for displaying multimedia content
CN103209326B (en) PNG (Portable Network Graphic) image compression method
US9836819B1 (en) Systems and methods for selective retention and editing of images captured by mobile image capture device
CN105430393A (en) Picture processing method, picture processing device and picture processing platform
CN107180443B (en) A kind of Freehandhand-drawing animation producing method and its device
CN102291506B (en) The method of picture uploading and device
CN105493501A (en) Virtual video camera
CN103338235B (en) On mobile phone, realize the method for dynamic wallpaper interactive mode, personalized creation
CN103765473B (en) The method and device of the digital image representation of the adjustment of view are provided
CN103595965B (en) The mobile video monitoring method controlled based on video flow
CN1136730C (en) Cartoon compressing method for radio network and hand-held radio equipment
CN109840879A (en) Image rendering method, device, computer storage medium and terminal
CN106165409A (en) Image processing apparatus, camera head, image processing method and program
CN103312981A (en) Synthetic multi-picture taking method and shooting device
CN106303226A (en) Image processing method and device
CN107295423A (en) A kind of adaptive coding and transmission method live for mobile terminal video
CN105975168A (en) OSD menu fading-in and fading-out method and device
CN108228852A (en) The method, apparatus and computer readable storage medium of electron album cover generation
CN104966309B (en) A kind of system compressed automatically and processing method with transparency image

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant