CN109727257A - Method, device and terminal for automatically cutting picture - Google Patents

Method, device and terminal for automatically cutting picture Download PDF

Info

Publication number
CN109727257A
CN109727257A CN201811632553.3A CN201811632553A CN109727257A CN 109727257 A CN109727257 A CN 109727257A CN 201811632553 A CN201811632553 A CN 201811632553A CN 109727257 A CN109727257 A CN 109727257A
Authority
CN
China
Prior art keywords
target photo
picture
original image
cut
dimension information
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.)
Pending
Application number
CN201811632553.3A
Other languages
Chinese (zh)
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.)
Beijing Kingsoft Internet Security Software Co Ltd
Original Assignee
Beijing Kingsoft Internet Security Software 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 Beijing Kingsoft Internet Security Software Co Ltd filed Critical Beijing Kingsoft Internet Security Software Co Ltd
Priority to CN201811632553.3A priority Critical patent/CN109727257A/en
Publication of CN109727257A publication Critical patent/CN109727257A/en
Pending legal-status Critical Current

Links

Landscapes

  • Image Processing (AREA)

Abstract

The embodiment of the invention discloses a method, a device and a terminal for automatically clipping pictures, relates to the technical field of computers, and can ensure that the pictures are not distorted and deformed during clipping. The method obtains the size information width X of the original picture1High Y1And size information width X of target picture2High Y2(ii) a Judging whether the original picture and the target picture are horizontal plates or vertical plates according to the size information; if the original picture and the target picture are horizontal or vertical at the same time, cutting the original picture to obtain an intermediate picture according to the size information of the original picture and the target picture; zooming the intermediate picture according to the size information of the target picture to obtain a target picture; or if the original picture and the target picture are not horizontal or vertical at the same time, zooming the original picture to obtain an intermediate picture according to the size information of the original picture and the target picture; and cutting the intermediate picture according to the size information of the target picture and/or the size information of the original picture to obtain the target picture.

Description

A kind of method, apparatus and terminal of automatic cutting picture
Technical field
The present invention relates to field of computer technology more particularly to a kind of method, apparatus and terminal of automatic cutting picture.
Background technique
Existing picture automation is cut in program, only supports for the picture of identical dimensions to be cropped to specified size Or original image is required to be the vertical version picture of identical size or must cut since the center of original image, scale cutting Target Photo cannot be guaranteed the main body for leaving original image, based on requirements above when wallpaper material size is different, horizontal version is plain Material wants the original image core cut out not in the center of original image, and cut-out picture will pixel mistake Very, out of proportion, picture main body is lost after cutting.
Summary of the invention
In view of this, the embodiment of the present invention provides a kind of method, apparatus of automatic cutting picture, terminal, storage medium, it can It is out of proportion with pixel distortion in effective solution picture cutting process, the problem of loss after the cutting of picture main body, the terminal It can be mobile phone, tablet computer, removable computer etc..
In a first aspect, the embodiment of the present invention provides a kind of method of automatic cutting picture, comprising: obtain the ruler of original image The very little wide X of information1, high Y1With the wide X of dimension information of Target Photo2, high Y2;The original image is judged according to the dimension information It is horizontal version or vertical version with the Target Photo;If the original image and the Target Photo are horizontal version or vertical version simultaneously, According to the dimension information of the original image and the Target Photo, cuts the original image and obtain intermediate picture;According to institute The dimension information for stating Target Photo scales the intermediate picture and obtains Target Photo;Or, if the original image and the target Picture does not scale the original then according to the dimension information of the original image and the Target Photo for horizontal version or vertical version simultaneously Beginning picture obtains intermediate picture;It is cut in described according to the dimension information of the Target Photo and/or original image dimension information Between picture obtain Target Photo.
Optionally, described the original image to be judged according to the dimension information and the Target Photo is horizontal version or perpendicular Version further include:
If the high Y of dimension of picture information is greater than width X, picture is vertical version;
If the high Y of dimension of picture information is less than width X, picture is vertical version.
Optionally, it is described cut the original image and obtain intermediate picture include:
An empty drawing board is drawn, the original image is placed on the drawing board and is cut.
Optionally, it is described cut the original image and obtain intermediate picture include:
Calculate the ratio of width to height f of the original image1=X1/Y1, the Target Photo the ratio of width to height f2=X2/Y2
Judge the f2With the f1Size;
If f2> f1, then the height of original image is cut to Y3=X1/f2Obtain intermediate picture;
If f2< f1, then the width of original image is cut to X3=Y1*f2Obtain intermediate picture.
Optionally, obtaining Target Photo according to the dimension information of the Target Photo scaling intermediate picture includes:
According to the size of the Target Photo and intermediate picture ratio, it is big to Target Photo to scale the intermediate picture It is small, obtain Target Photo.
Optionally, the scaling original image obtains intermediate picture and includes:
Calculate the wide ratio f of the wide and described original image of the Target Photow=X2/X1With the Target Photo height and institute State the high ratio f of original imageh=Y2/Y1
Judge the fwAnd fhSize, if fw< fh, then f is enabled3=fh;Or,
If fw> fh, then f is enabled3=fw
The original image is scaled to f3Size obtain intermediate picture, the high Y of intermediate picture3=Y1*f3, intermediate picture Wide X3=X1*f3
Optionally, described that Target Photo packet is obtained according to the dimension information of the Target Photo cutting intermediate picture It includes: drawing an empty drawing board, the Target Photo is placed on the drawing board and is cut.
Optionally, it is described the intermediate picture cut according to the dimension information of the Target Photo obtain Target Photo also wrap It includes:
If X3=X2, then the height of the Target Photo is cut to Y2Obtain intermediate picture;
If Y3=Y2, then the width of the Target Photo is cut to X2Obtain intermediate picture;
Optionally, it is described the intermediate picture cut according to the dimension information of the Target Photo obtain Target Photo also wrap It includes: calculating the ratio of width to height f of the Target Photo2=X2/Y2
Calculating the top left co-ordinate cut is (x, 0), wherein the x=(X1-Y1*f2)/2*f3
The coordinate for calculating the lower right corner cut is (x+X2, y), wherein the y=(Y1-X1/f2)/2*f3
According to top left co-ordinate (x, 0) and bottom right angular coordinate (x+X2, y) intermediate picture is cut to obtain target Picture.
Optionally, the cutting includes: and is subject to two central axis equal proportions of picture to cut picture two sides.
Second aspect, the embodiment of the present invention provide a kind of device of automatic cutting picture, comprising:
Obtain module, the wide X of dimension information for obtaining original image1, high Y1With the wide X of dimension information of Target Photo2、 High Y2
Judgment module, for the original image is judged according to the dimension information and the Target Photo be horizontal version or Vertical version;
Module is cut, if being simultaneously horizontal version or vertical version for the original image and the Target Photo, according to The dimension information of original image and the Target Photo cuts the original image and obtains intermediate picture;
Zoom module obtains Target Photo for scaling the intermediate picture according to the dimension information of the Target Photo; Or,
If being not simultaneously horizontal version or vertical version for the original image and the Target Photo, according to the original image With the dimension information of the Target Photo, scales the original image and obtain intermediate picture;
Module is cut, the centre is cut according to the dimension information of the Target Photo and/or original image dimension information Picture obtains Target Photo.
Optionally, the judgment module executes:
When the high Y of dimension of picture information is greater than width X, picture is vertical version picture;
When the high Y of dimension of picture information is less than width X, picture is horizontal domain piece.
Optionally, it is described cut the original image and obtain intermediate picture include:
An empty drawing board is drawn, the original image is placed on the drawing board and is cut.
Optionally, it is described cut the original image and obtain intermediate picture include:
Computing module, for calculating the ratio of width to height f of the original image1=X1/Y1, the Target Photo the ratio of width to height f2 =X2/Y2
Judgment module, for judging the f2With the f1Size;
Module is cut, if being used for f2> f1, then the height of original image is cut to Y3=X1/f2Obtain intermediate picture;
If f2< f1, then the width of original image is cut to X3=Y1*f2Obtain intermediate picture.
Optionally, obtaining Target Photo according to the dimension information of the Target Photo scaling intermediate picture includes:
Zoom module scales the intermediate picture to target according to the size of the Target Photo and intermediate picture ratio Picture size obtains Target Photo.
Optionally, the scaling original image obtains intermediate picture and includes:
Computing module, for calculating the wide ratio f of the wide and described original image of the Target Photow=X2/X1With the mesh Mark on a map piece height and the high ratio f of the original imageh=Y2/Y1
Judgment module, for judging the fwAnd fhSize, work as fw< fhWhen, then enable f3=fh;Or,
Work as fw> fhWhen, then enable f3=fw
Zoom module, for scaling the original image to f3Size obtain intermediate picture, the high Y of intermediate picture3=Y1* f3, the wide X of intermediate picture3=X1*f3
Optionally, described that Target Photo packet is obtained according to the dimension information of the Target Photo cutting intermediate picture It includes:
An empty drawing board is drawn, the Target Photo is placed on the drawing board and is cut.
Optionally, it is described the intermediate picture cut according to the dimension information of the Target Photo obtain Target Photo also wrap It includes:
If X3=X2, then the height of the Target Photo is cut to Y2Obtain intermediate picture;
If Y3=Y2, then the width of the Target Photo is cut to X2Obtain intermediate picture;
Optionally, it is described the intermediate picture cut according to the dimension information of the Target Photo obtain Target Photo also wrap It includes:
Computing module calculates the ratio of width to height f of the Target Photo2=X2/Y2
Calculating the top left co-ordinate cut is (x, 0), wherein the x=(X1-Y1*f2)/2*f3
The coordinate for calculating the lower right corner cut is (x+X2, y), wherein the y=(Y1-X1/f2)/2*f3
Module is cut according to top left co-ordinate (x, 0) and bottom right angular coordinate (x+X2, y) intermediate picture is cut Obtain Target Photo.
Optionally, it is described cut module also execute: be subject to picture two central axis equal proportions to picture two sides carry out It cuts.
The third aspect, the embodiment of the present invention also provide a kind of terminal, and the terminal includes: shell, processor, storage Device, circuit board and power circuit, wherein circuit board is placed in the space interior that shell surrounds, and processor and memory setting exist On circuit board;Power circuit, for each circuit or the device power supply for above-mentioned electronic equipment;Memory is executable for storing Program code;Processor is corresponding with executable program code to run by reading the executable program code stored in memory Program, the method for executing any automatic cutting picture provided in an embodiment of the present invention.
Fourth aspect, the embodiment of the present invention also provide a kind of computer readable storage medium, described computer-readable to deposit Storage media is stored with one or more program, and one or more of programs can be executed by one or more processor, Method to realize any automatic cutting picture provided in an embodiment of the present invention.
The method, apparatus for automatic cutting picture, the terminal, storage medium of the embodiment of the present invention offer,
Obtain the wide X of dimension information of original image1, high Y1With the wide X of dimension information of Target Photo2, high Y2;According to described Dimension information judges the original image and the Target Photo is horizontal version or vertical version;If the original image and the target Picture is that horizontal version or vertical version according to the dimension information of the original image and the Target Photo cut the original graph simultaneously Piece obtains intermediate picture;The intermediate picture, which is scaled, according to the dimension information of the Target Photo obtains Target Photo;Or, if institute Stating original image and the Target Photo not is simultaneously horizontal version or vertical version, according to the ruler of the original image and the Target Photo Very little information scales the original image and obtains intermediate picture;According to the dimension information of the Target Photo and/or original image ruler Very little information cuts the intermediate picture and obtains Target Photo.The scheme through the invention, can be cut out with effective solution picture Pixel distortion during cutting, it is out of proportion, the problem of loss after the cutting of picture main body.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this Some embodiments of invention for those of ordinary skill in the art without creative efforts, can be with Other attached drawings are obtained according to these attached drawings.
Fig. 1 is a kind of flow chart for the method for automatic cutting picture that the embodiment of the present invention provides;
Fig. 2 is a kind of structural schematic diagram for the device for automatic cutting picture that the embodiment of the present invention provides;
Fig. 3 is a kind of structural schematic diagram for the terminal that the embodiment of the present invention provides.
Specific embodiment
The embodiment of the present invention is described in detail with reference to the accompanying drawing.
It will be appreciated that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Base Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts it is all its Its embodiment, shall fall within the protection scope of the present invention.
In a first aspect, the embodiment of the present invention provides a kind of method of automatic cutting picture, can be cut out with effective solution picture Pixel distortion during cutting, it is out of proportion, the problem of loss after the cutting of picture main body.
As shown in Figure 1, the method for the automatic cutting picture that the embodiment of the present invention 1 provides may include:
S101 obtains the wide X of dimension information of original image1, high Y1With the wide X of dimension information of Target Photo2, high Y2
In this step, picture is cut to original image is cut to Target Photo size, wherein original image and target Size between picture is not specifically limited, and the size of original image, which can be greater than Target Photo, might be less that target figure The size of piece.
S102, judges the original image according to the dimension information and the Target Photo is horizontal version or vertical version;
In this step, if dimension of picture information is greater than width X as the high Y of dimension of picture information, picture is vertical version, if picture The high Y of dimension information is less than width X, then picture is vertical version.
S103, if the original image and the Target Photo are simultaneously horizontal version or vertical version, according to the original image With the dimension information of the Target Photo, cuts the original image and obtain intermediate picture;
In this step, an empty drawing board is drawn, the original image is placed on the drawing board and is cut.It can The method of cutting out of choosing calculates the ratio of width to height f of the original image1=X1/Y1, the Target Photo the ratio of width to height f2=X2/Y2;Sentence Break the f2With the f1Size;If f2> f1, then the height of original image is cut to Y3=X1/f2Obtain intermediate picture;If f2 < f1, then the width of original image is cut to X3=Y1*f2Intermediate picture is obtained, cutting original image described above obtains target Picture is to be subject to two central axis equal proportions of the original image to cut the original image two sides.
S104 scales the intermediate picture according to the dimension information of the Target Photo and obtains Target Photo.
In this step, according to the size of the Target Photo and intermediate picture ratio, the intermediate picture is scaled extremely Target Photo size obtains Target Photo.
For example, obtaining original image dimension information is width X1For 240, high Y1It is 480, the wide X of Target Photo dimension information2For 120, high Y2It is 360, judges that the dimension information of original image and Target Photo is tall and big in width, be all vertical version picture.It calculates Original image the ratio of width to height f1=X1/Y1=240/480=1/2, Target Photo the ratio of width to height f2=X2/Y2=120/360=1/3, then f2< f1, original image is subject to perpendicular central axis equal proportion, the width of original image is cut to X3=Y1*f2=480*1/3= 160, i.e. 40 sizes are dismissed in the left and right sides, obtain intermediate picture X3For 160, high Y3It is 480, it is big that intermediate picture is zoomed to 3/4 It is small to obtain Target Photo.
For example, obtaining original image dimension information is width X1For 120, high Y1It is 90, the wide X of Target Photo dimension information2For 80, high Y2It is 40, judges that the dimension information of original image and Target Photo is high less than width, be all horizontal domain piece.It calculates former Beginning picture the ratio of width to height f1=X1/Y1=120/90=4/3, Target Photo the ratio of width to height f2=X2/Y2=80/40=2, then f2> f1, will Original image is subject to horizontal central axis equal proportion and the high of original image is cut Y3=X1/f2=120/2=60, i.e., upper and lower two sides 15 sizes are dismissed, intermediate picture X is obtained3For 120, high Y3It is 60, the size that intermediate picture zooms to 2/3 is obtained into target figure Piece.
S105, if the original image and the Target Photo are not simultaneously horizontal version or vertical version, according to the original graph The dimension information of piece and the Target Photo scales the original image and obtains intermediate picture;
In this step, the wide ratio f of the wide and described original image of the Target Photo is calculatedw=X2/X1With the target Picture height and the high ratio f of the original imageh=Y2/Y1;Judge the fwAnd fhSize, if fw< fh, then f is enabled3=fh; Or, if fw> fh, then f3=fw;The original image is scaled to f3Size obtain intermediate picture, the high Y of intermediate picture3=Y1*f3, The wide X of intermediate picture3=X1*f3
S106 cuts the intermediate picture according to the dimension information of the Target Photo and/or original image dimension information Obtain Target Photo.
In this step in one embodiment, the intermediate picture is cut according to the dimension information of the Target Photo and is obtained Target Photo;An empty drawing board is drawn, the Target Photo is placed on the drawing board and is cut.If X3=X2, then will The height of the Target Photo is cut to Y2Obtain intermediate picture;If Y3=Y2, then the width of the Target Photo is cut to X2It obtains Intermediate picture cuts picture two sides wherein being subject to two central axis equal proportions of picture.
Optionally, obtaining original image dimension information is width X1For 240, high Y1It is 200, the wide X of Target Photo dimension information2 For 40, high Y2It is 80, the high Y of original image1Less than wide X1For horizontal domain piece, the high Y of Target Photo2Greater than wide X2For vertical version picture, meter Calculate the wide ratio f of the wide and described original image of Target Photow=X2/X1=1/6, calculate Target Photo height and the original image High ratio fh=Y2/Y1=2/5, fw< fh, enable f3=fh=2/5, horizontal central axis two sides etc. up and down are subject to original image Scaling is to a height of Y3=Y1*f3=80, equal proportion at left and right sides of perpendicular central axis, which is subject to, to original image zooms to width for X3 =X1*f3=96.Then Y3=Y2, target of being subject to, which erects central axis and each side cuts 28, obtains Target Photo.
In this step in another embodiment, according to the dimension information of the Target Photo and original image size Information cuts the intermediate picture and obtains Target Photo.An empty drawing board is drawn, the Target Photo is placed into institute It states and is cut on drawing board.Optional method of cutting out calculates the ratio of width to height f of the Target Photo2=X2/Y2;Calculate the left side cut Upper angular coordinate is (x, 0), wherein the x=(X1-Y1*f2)/2*f3;The coordinate for calculating the lower right corner cut is (x+X2, y), Described in y=(Y1-X1/f2)/2*f3;According to top left co-ordinate (x, 0) and bottom right angular coordinate (x+X2, y) and to the intermediate picture It is cut to obtain Target Photo.
Citing, acquisition original image dimension information are width X1For 240, high Y1It is 200, the wide X of Target Photo dimension information2For 40, high Y2It is 80, the high Y of original image1Less than wide X1For horizontal domain piece, the high Y of Target Photo2Greater than wide X2For vertical version picture, calculate The wide ratio f of the wide and described original image of Target Photow=X2/X1=1/6, it calculates Target Photo height and the original image is high Ratio fh=Y2/Y1=2/5, fw< fh, enable f3=fh=2/5, the horizontal central axis ratio such as two sides up and down is subject to original image Example zooms to a height of Y3=Y1*f3=80, equal proportion at left and right sides of perpendicular central axis, which is subject to, to original image zooms to width for X3= X1*f3=96.
Further, the ratio of width to height f of the Target Photo is calculated2=X2/Y2=1/2;Calculating the top left co-ordinate cut is (x, 0), wherein the x=(X1-Y1*f2)/2*f3=28;The coordinate for calculating the lower right corner cut is (x+X2, y), wherein the y =(Y1-X1/f2)/2*f3=-80;According to top left co-ordinate (28,0) and bottom right angular coordinate (68, -80) to the intermediate picture It is cut to obtain Target Photo.Wherein drawing board is using the picture upper left corner as origin (0,0).
The method for automatic cutting picture that the embodiment of the present invention provides, the dimension information for obtaining original image are wide X1, high Y1With the wide X of dimension information of Target Photo2, high Y2;The original image and the mesh are judged according to the dimension information Piece of marking on a map is horizontal version or vertical version;If the original image and the Target Photo are simultaneously horizontal version or vertical version, according to The dimension information of original image and the Target Photo cuts the original image and obtains intermediate picture;According to the target figure The dimension information of piece scales the intermediate picture and obtains Target Photo;Or, if the original image is different with the Target Photo When scale the original image then according to the dimension information of the original image and the Target Photo and obtain for horizontal version or vertical version To intermediate picture;The middle graph is cut according to the dimension information of the Target Photo and/or original image dimension information Piece obtains Target Photo.Original image is cut to obtain intermediate picture, is guaranteed when original image is cut to Target Photo not It is distorted, is indeformable.
Second aspect, the embodiment of the present invention also provide a kind of device of automatic cutting picture, can be with effective solution figure Pixel distortion in piece cutting process, it is out of proportion, the problem of loss after the cutting of picture main body.
As shown in Fig. 2, the device for the automatic cutting picture that the embodiment of the present invention provides, comprising:
Module S201 is obtained, the wide X of dimension information of original image is obtained1, high Y1With the wide X of dimension information of Target Photo2、 High Y2
In this step, picture is cut to original image is cut to Target Photo size, wherein original image and target Size between picture is not specifically limited, and the size of original image, which can be greater than Target Photo, might be less that target figure The size of piece.
Judgment module S202, the original image is judged according to the dimension information and the Target Photo be horizontal version or Vertical version;
In this step, if dimension of picture information is greater than width X as the high Y of dimension of picture information, picture is vertical version, if picture The high Y of dimension information is less than width X, then picture is vertical version.
Module S203 is cut, if the original image and the Target Photo are simultaneously horizontal version or vertical version, according to The dimension information of original image and the Target Photo cuts the original image and obtains intermediate picture;
In this step, an empty drawing board is drawn, the original image is placed on the drawing board and is cut.It can The method of cutting out of choosing calculates the ratio of width to height f of the original image1=X1/Y1, the Target Photo the ratio of width to height f2=X2/Y2;Sentence Break the f2With the f1Size;If f2> f1, then the height of original image is cut to Y3=X1/f2Obtain intermediate picture;If f2 < f1, then the width of original image is cut to X3=Y1*f2Intermediate picture is obtained, cutting original image described above obtains target Picture is to be subject to two central axis equal proportions of the original image to cut the original image two sides.
Zoom module S204 scales the intermediate picture according to the dimension information of the Target Photo and obtains Target Photo.
In this step, according to the size of the Target Photo and intermediate picture ratio, the intermediate picture is scaled extremely Target Photo size obtains Target Photo.
For example, obtaining original image dimension information is width X1For 240, high Y1It is 480, the wide X of Target Photo dimension information2For 120, high Y2It is 360, judges that the dimension information of original image and Target Photo is tall and big in width, be all vertical version picture.It calculates Original image the ratio of width to height f1=X1/Y1=240/480=1/2, Target Photo the ratio of width to height f2=X2/Y2=120/360=1/3, then f2< f1, original image is subject to perpendicular central axis equal proportion, the width of original image is cut to X3=Y1*f2=480*1/3= 160, i.e. 40 sizes are dismissed in the left and right sides, obtain intermediate picture X3For 160, high Y3It is 480, it is big that intermediate picture is zoomed to 3/4 It is small to obtain Target Photo.
For example, obtaining original image dimension information is width X1For 120, high Y1It is 90, the wide X of Target Photo dimension information2For 80, high Y2It is 40, judges that the dimension information of original image and Target Photo is high less than width, be all horizontal domain piece.It calculates former Beginning picture the ratio of width to height f1=X1/Y1=120/90=4/3, Target Photo the ratio of width to height f2=X2/Y2=80/40=2, then f2> f1, will Original image is subject to horizontal central axis equal proportion and the high of original image is cut Y3=X1/f2=120/2=60, i.e., upper and lower two sides 15 sizes are dismissed, intermediate picture X is obtained3For 120, high Y3It is 60, the size that intermediate picture zooms to 2/3 is obtained into target figure Piece.
In another embodiment, Zoom module S204, if be used for the original image with the Target Photo difference It scales the original image then according to the dimension information of the original image and the Target Photo for horizontal version or vertical version and obtains Intermediate picture;
In this step, the wide ratio f of the wide and described original image of the Target Photo is calculatedw=X2/X1With the target Picture height and the high ratio f of the original imageh=Y2/Y1;Judge the fwAnd fhSize, if fw< fh, then f is enabled3=fh; Or, if fw> fh, then f3=fw;The original image is scaled to f3Size obtain intermediate picture, the high Y of intermediate picture3=Y1*f3, The wide X of intermediate picture3=X1*f3
Module S203 is cut, for cutting according to the dimension information and/or original image dimension information of the Target Photo The intermediate picture obtains Target Photo.In this step one embodiment, cut according to the dimension information of the Target Photo The intermediate picture obtains Target Photo;An empty drawing board is drawn, the Target Photo is placed on the drawing board and is carried out It cuts.If X3=X2, then the height of the Target Photo is cut to Y2Obtain intermediate picture;If Y3=Y2, then by the target figure The width of piece is cut to X2Intermediate picture is obtained, picture two sides are cut out wherein being subject to two central axis equal proportions of picture It cuts.
Optionally, obtaining original image dimension information is width X1For 240, high Y1It is 200, the wide X of Target Photo dimension information2 For 40, high Y2It is 80, the high Y of original image1Less than wide X1For horizontal domain piece, the high Y of Target Photo2Greater than wide X2For vertical version picture, meter Calculate the wide ratio f of the wide and described original image of Target Photow=X2/X1=1/6, calculate Target Photo height and the original image High ratio fh=Y2/Y1=2/5, fw< fh, enable f3=fh=2/5, horizontal central axis two sides etc. up and down are subject to original image Scaling is to a height of Y3=Y1*f3=80, equal proportion at left and right sides of perpendicular central axis, which is subject to, to original image zooms to width for X3 =X1*f3=96.Then Y3=Y2, target of being subject to, which erects central axis and each side cuts 28, obtains Target Photo.
In this step another embodiment, it is also used to the dimension information and original image ruler according to the Target Photo Very little information cuts the intermediate picture and obtains Target Photo.An empty drawing board is drawn, the Target Photo is placed into It is cut on the drawing board.Optional method of cutting out calculates the ratio of width to height f of the Target Photo2=X2/Y2;Calculate cutting Top left co-ordinate is (x, 0), wherein the x=(X1-Y1*f2)/2*f3;The coordinate for calculating the lower right corner cut is (x+X2, y), Wherein y=(the Y1-X1/f2)/2*f3;According to top left co-ordinate (x, 0) and bottom right angular coordinate (x+X2, y) and to the middle graph Piece is cut to obtain Target Photo.
Citing, acquisition original image dimension information are width X1For 240, high Y1It is 200, the wide X of Target Photo dimension information2For 40, high Y2It is 80, the high Y of original image1Less than wide X1For horizontal domain piece, the high Y of Target Photo2Greater than wide X2For vertical version picture, calculate The wide ratio f of the wide and described original image of Target Photow=X2/X1=1/6, it calculates Target Photo height and the original image is high Ratio fh=Y2/Y1=2/5, fw< fh, enable f3=fh=2/5, the horizontal central axis ratio such as two sides up and down is subject to original image Example zooms to a height of Y3=Y1*f3=80, equal proportion at left and right sides of perpendicular central axis, which is subject to, to original image zooms to width for X3= X1*f3=96.
Further, the ratio of width to height f of the Target Photo is calculated2=X2/Y2=1/2;Calculating the top left co-ordinate cut is (x, 0), wherein the x=(X1-Y1*f2)/2*f3=28;The coordinate for calculating the lower right corner cut is (x+X2, y), wherein the y =(Y1-X1/f2)/2*f3=-80;According to top left co-ordinate (28,0) and bottom right angular coordinate (68, -80) to the intermediate picture It is cut to obtain Target Photo.Wherein drawing board is using the picture upper left corner as origin (0,0).
The device for automatic cutting picture that the embodiment of the present invention provides, the dimension information for obtaining original image are wide X1, high Y1With the wide X of dimension information of Target Photo2, high Y2;The original image and the mesh are judged according to the dimension information Piece of marking on a map is horizontal version or vertical version;If the original image and the Target Photo are simultaneously horizontal version or vertical version, according to The dimension information of original image and the Target Photo cuts the original image and obtains intermediate picture;According to the target figure The dimension information of piece scales the intermediate picture and obtains Target Photo;Or, if the original image is different with the Target Photo When scale the original image then according to the dimension information of the original image and the Target Photo and obtain for horizontal version or vertical version To intermediate picture;The middle graph is cut according to the dimension information of the Target Photo and/or original image dimension information Piece obtains Target Photo.Original image is cut to obtain intermediate picture, is guaranteed when original image is cut to Target Photo not It is distorted, is indeformable.
The third aspect, the embodiment of the present invention provide a kind of terminal, can be lost with pixel in effective solution picture cutting process Very, out of proportion, the problem of loss after the cutting of picture main body.
As shown in figure 3, a kind of terminal that the embodiment of the present invention provides, may include: shell 431, processor 32, storage Device 33, circuit board 34 and power circuit 35, wherein circuit board 34 is placed in the space interior that shell 31 surrounds, 32 He of processor Memory 33 is arranged on circuit board 34;Power circuit 35, for each circuit or the device power supply for above-mentioned electronic equipment;It deposits Reservoir 33 is for storing executable program code;Processor 32 by read in memory 33 executable program code that stores come Program corresponding with executable program code is run, for executing the side described in aforementioned any embodiment for terminal input Method.
Processor 32 to the specific implementation procedures of above-mentioned steps and processor 32 by operation executable program code come The step of further executing may refer to the description of previous embodiment, and details are not described herein.
The terminal exists in a variety of forms, including but not limited to:
(1) mobile communication equipment: the characteristics of this kind of equipment is that have mobile communication function, and to provide speech, data Communication is main target.This Terminal Type includes: smart phone (such as iPhone), multimedia handset, functional mobile phone and low Hold mobile phone etc..
(2) super mobile personal computer equipment: this kind of equipment belongs to the scope of personal computer, there is calculating and processing function Can, generally also have mobile Internet access characteristic.This Terminal Type includes: PDA, MID and UMPC equipment etc., such as iPad.
(3) portable entertainment device: this kind of equipment can show and play multimedia content.Such equipment include: audio, Video player (such as iPod), handheld device, e-book and intelligent toy and portable car-mounted navigation equipment.
(4) server: providing the equipment of the service of calculating, and the composition of server includes that processor, hard disk, memory, system are total Line etc., server is similar with general computer architecture, but due to needing to provide highly reliable service, in processing energy Power, stability, reliability, safety, scalability, manageability etc. are more demanding.
(5) other electronic equipments with data interaction function.
Fourth aspect, the embodiment of the present invention also provide a kind of computer readable storage medium, described computer-readable to deposit Storage media is stored with one or more program, and one or more of programs can be executed by one or more processor, Method to realize any automatic cutting picture of previous embodiment offer, therefore it is also able to achieve corresponding technical effect, it is preceding Detailed description has been carried out in text, and details are not described herein again.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence " including one ... ", it is not excluded that There is also other identical elements in the process, method, article or apparatus that includes the element.
Each embodiment in this specification is all made of relevant mode and describes, same and similar portion between each embodiment Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.
For Installation practice, since it is substantially similar to the method embodiment, so the comparison of description is simple Single, the relevent part can refer to the partial explaination of embodiments of method.
For convenience of description, description apparatus above is to be divided into various units/modules with function to describe respectively.Certainly, exist Implement to realize each unit/module function in the same or multiple software and or hardware when the present invention.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with Relevant hardware is instructed to complete by computer program, the program can be stored in a computer-readable storage medium In, the program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein, the storage medium can be magnetic Dish, CD, read-only memory (Read-Only Memory, ROM) or random access memory (Random Access Memory, RAM) etc..
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any In the technical scope disclosed by the present invention, any changes or substitutions that can be easily thought of by those familiar with the art, all answers It is included within the scope of the present invention.Therefore, protection scope of the present invention should be subject to the protection scope in claims.

Claims (10)

1. a kind of method of automatic cutting picture, which is characterized in that the described method includes:
Obtain the wide X of dimension information of original image1, high Y1With the wide X of dimension information of Target Photo2, high Y2
The original image is judged according to the dimension information and the Target Photo is horizontal version or vertical version;If the original graph Piece and the Target Photo are horizontal version or vertical version simultaneously, then according to the dimension information of the original image and the Target Photo, It cuts the original image and obtains intermediate picture;
The intermediate picture, which is scaled, according to the dimension information of the Target Photo obtains Target Photo;Or,
If the original image and the Target Photo are not simultaneously horizontal version or vertical version, according to the original image and the mesh It marks on a map the dimension information of piece, scales the original image and obtain intermediate picture;
The intermediate picture, which is cut, according to the dimension information of the Target Photo and/or original image dimension information obtains target figure Piece.
2. the method according to claim 1, wherein described judge the original image according to the dimension information With the Target Photo be horizontal version or vertical version includes:
If the high Y of dimension of picture information is greater than width X, picture is vertical version picture;
If the high Y of dimension of picture information is less than width X, picture is horizontal domain piece.
3. the method according to claim 1, wherein the cutting original image obtains intermediate picture packet It includes:
An empty drawing board is drawn, the original image is placed on the drawing board and is cut.
4. according to the method described in claim 3, it is characterized in that, the cutting original image obtains intermediate picture packet It includes:
Calculate the ratio of width to height f of the original image1=X1/Y1, the Target Photo the ratio of width to height f2=X2/Y2
Judge the f2With the f1Size;
If f2> f1, then the height of original image is cut to Y3=X1/f2Obtain intermediate picture;
If f2< f1, then the width of original image is cut to X3=Y1*f2Obtain intermediate picture.
5. according to the method described in claim 4, it is characterized in that, being scaled in described according to the dimension information of the Target Photo Between picture obtain Target Photo and include:
According to the size of the Target Photo and intermediate picture ratio, the intermediate picture is scaled to Target Photo size, is obtained To Target Photo.
6. the method according to claim 1, wherein the scaling original image obtains intermediate picture packet It includes:
Calculate the wide ratio f of the wide and described original image of the Target Photow=X2/X1With the Target Photo height and the original The high ratio f of beginning pictureh=Y2/Y1
Judge the fwAnd fhSize, if fw< fh, then f is enabled3=fh;Or,
If fw> fh, then f is enabled3=fw
The original image is scaled to f3Size obtain intermediate picture, the high Y of intermediate picture3=Y1*f3, the wide X of intermediate picture3= X1*f3
7. according to the method described in claim 6, it is characterized in that, described cut institute according to the dimension information of the Target Photo It states intermediate picture and obtains Target Photo and include:
An empty drawing board is drawn, the Target Photo is placed on the drawing board and is cut.
8. the method according to the description of claim 7 is characterized in that described cut institute according to the dimension information of the Target Photo It states intermediate picture and obtains Target Photo further include:
If X3=X2, then the height of the Target Photo is cut to Y2Obtain intermediate picture;
If Y3=Y2, then the width of the Target Photo is cut to X2Obtain intermediate picture.
9. the method according to the description of claim 7 is characterized in that described cut institute according to the dimension information of the Target Photo It states intermediate picture and obtains Target Photo further include:
Calculate the ratio of width to height f of the Target Photo2=X2/Y2
Calculating the top left co-ordinate cut is (x, 0), wherein the x=(X1-Y1*f2)/2*f3
The coordinate for calculating the lower right corner cut is (x+X2, y), wherein the y=(Y1-X1/f2)/2*f3
According to top left co-ordinate (x, 0) and bottom right angular coordinate (x+X2, y) intermediate picture is cut to obtain Target Photo.
10. any method in -8 according to claim 1, which is characterized in that the cutting includes:
The two central axis equal proportions of picture of being subject to cut picture two sides.
CN201811632553.3A 2018-12-28 2018-12-28 Method, device and terminal for automatically cutting picture Pending CN109727257A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811632553.3A CN109727257A (en) 2018-12-28 2018-12-28 Method, device and terminal for automatically cutting picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811632553.3A CN109727257A (en) 2018-12-28 2018-12-28 Method, device and terminal for automatically cutting picture

Publications (1)

Publication Number Publication Date
CN109727257A true CN109727257A (en) 2019-05-07

Family

ID=66296053

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811632553.3A Pending CN109727257A (en) 2018-12-28 2018-12-28 Method, device and terminal for automatically cutting picture

Country Status (1)

Country Link
CN (1) CN109727257A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112927241A (en) * 2021-03-08 2021-06-08 携程旅游网络技术(上海)有限公司 Picture capturing and thumbnail generating method, system, equipment and storage medium
CN113450361A (en) * 2021-05-14 2021-09-28 山东英信计算机技术有限公司 Crawler image processing method and device, computer equipment and storage medium
WO2021218016A1 (en) * 2020-04-29 2021-11-04 平安科技(深圳)有限公司 Picture cropping method and apparatus, computer device, and storage medium
CN113655977A (en) * 2021-08-18 2021-11-16 北京达佳互联信息技术有限公司 Material display method and device, electronic equipment and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080025578A1 (en) * 2006-07-25 2008-01-31 Fujifilm Corporation Automatic reproduction method and apparatus
CN102890816A (en) * 2011-07-20 2013-01-23 深圳市快播科技有限公司 Method and device for video image scaling
CN103514271A (en) * 2013-09-13 2014-01-15 北京奇虎科技有限公司 Method and device for providing thumbnail image corresponding to webpage content
CN103514272A (en) * 2013-09-13 2014-01-15 北京奇虎科技有限公司 Method and device for providing thumbnail corresponding to webpage content
CN103824252A (en) * 2014-02-10 2014-05-28 安徽科大讯飞信息科技股份有限公司 Picture processing method and system
CN103903221A (en) * 2012-12-24 2014-07-02 腾讯科技(深圳)有限公司 Image generation method, image generation device and image generation system
CN104484853A (en) * 2014-12-24 2015-04-01 北京奇虎科技有限公司 Method and device for clipping pictures containing graphical signs
CN104484854A (en) * 2014-12-24 2015-04-01 北京奇虎科技有限公司 Cropping method and device for people pictures
CN105094563A (en) * 2015-08-11 2015-11-25 成都视达科信息技术有限公司 Image clipping method and system
CN105205780A (en) * 2015-10-19 2015-12-30 新华瑞德(北京)网络科技有限公司 Picture cropping method and device
CN105678695A (en) * 2014-11-19 2016-06-15 腾讯科技(深圳)有限公司 Picture processing method and device
CN106157239A (en) * 2015-04-22 2016-11-23 阿里巴巴集团控股有限公司 A kind of image processing method and relevant device and system

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080025578A1 (en) * 2006-07-25 2008-01-31 Fujifilm Corporation Automatic reproduction method and apparatus
CN102890816A (en) * 2011-07-20 2013-01-23 深圳市快播科技有限公司 Method and device for video image scaling
CN103903221A (en) * 2012-12-24 2014-07-02 腾讯科技(深圳)有限公司 Image generation method, image generation device and image generation system
CN103514271A (en) * 2013-09-13 2014-01-15 北京奇虎科技有限公司 Method and device for providing thumbnail image corresponding to webpage content
CN103514272A (en) * 2013-09-13 2014-01-15 北京奇虎科技有限公司 Method and device for providing thumbnail corresponding to webpage content
CN103824252A (en) * 2014-02-10 2014-05-28 安徽科大讯飞信息科技股份有限公司 Picture processing method and system
CN105678695A (en) * 2014-11-19 2016-06-15 腾讯科技(深圳)有限公司 Picture processing method and device
CN104484853A (en) * 2014-12-24 2015-04-01 北京奇虎科技有限公司 Method and device for clipping pictures containing graphical signs
CN104484854A (en) * 2014-12-24 2015-04-01 北京奇虎科技有限公司 Cropping method and device for people pictures
CN106157239A (en) * 2015-04-22 2016-11-23 阿里巴巴集团控股有限公司 A kind of image processing method and relevant device and system
CN105094563A (en) * 2015-08-11 2015-11-25 成都视达科信息技术有限公司 Image clipping method and system
CN105205780A (en) * 2015-10-19 2015-12-30 新华瑞德(北京)网络科技有限公司 Picture cropping method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2021218016A1 (en) * 2020-04-29 2021-11-04 平安科技(深圳)有限公司 Picture cropping method and apparatus, computer device, and storage medium
CN112927241A (en) * 2021-03-08 2021-06-08 携程旅游网络技术(上海)有限公司 Picture capturing and thumbnail generating method, system, equipment and storage medium
CN113450361A (en) * 2021-05-14 2021-09-28 山东英信计算机技术有限公司 Crawler image processing method and device, computer equipment and storage medium
CN113655977A (en) * 2021-08-18 2021-11-16 北京达佳互联信息技术有限公司 Material display method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109727257A (en) Method, device and terminal for automatically cutting picture
CN105262810A (en) Cloud backup method and device for picture and electronic equipment
US8595638B2 (en) User interface, device and method for displaying special locations on a map
CN104994283B (en) A kind of bearing calibration of local distortion and mobile terminal
US20090167919A1 (en) Method, Apparatus and Computer Program Product for Displaying an Indication of an Object Within a Current Field of View
CN102760170A (en) Electronic book note-taking method based on screenshot
CN103793521B (en) Image processing method and device
CN104866501A (en) Electronic travel photo album generation method and system
CN104159120B (en) A kind of video image stabilization method, apparatus and system
CN105159975B (en) To-be-cleaned data identification method and device and electronic equipment
CN103530114A (en) Picture managing method and device
CN102404397A (en) Message reminding method, device and system
CN108134903B (en) Shooting method and related product
CN104199906A (en) Recommending method and device for shooting region
CN104508689A (en) A two-dimension code processing method and a terminal
CN103365964A (en) Information recommendation method as well as related equipment and system
TWI706332B (en) Graphic coding display method and device and computer equipment
CN103179322A (en) Image color correction method and electronic device
CN106989697A (en) The acquisition methods and device of a kind of optical axis included angle
CN106027517B (en) A kind of game subpackage method and apparatus supported by all kinds of means
US20130227383A1 (en) Apparatus and method for searching for resources of e-book
CN107390986A (en) A kind of mobile terminal cuts out figure control method, storage device and mobile terminal
CN105228105A (en) A kind of indoor orientation method and user terminal
CN105808674A (en) Picture display method and device and electronic equipment
CN103236042A (en) Self-adaptive picture processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20190507

RJ01 Rejection of invention patent application after publication