CN111667487A - Picture clipping method and device and computer equipment - Google Patents

Picture clipping method and device and computer equipment Download PDF

Info

Publication number
CN111667487A
CN111667487A CN202010357558.0A CN202010357558A CN111667487A CN 111667487 A CN111667487 A CN 111667487A CN 202010357558 A CN202010357558 A CN 202010357558A CN 111667487 A CN111667487 A CN 111667487A
Authority
CN
China
Prior art keywords
picture
cutting
cropping
width
size
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
CN202010357558.0A
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202010357558.0A priority Critical patent/CN111667487A/en
Publication of CN111667487A publication Critical patent/CN111667487A/en
Priority to PCT/CN2020/118001 priority patent/WO2021218016A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T3/04
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4023Decimation- or insertion-based scaling, e.g. pixel or line decimation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20112Image segmentation details
    • G06T2207/20132Image cropping

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Editing Of Facsimile Originals (AREA)
  • Image Processing (AREA)

Abstract

The invention discloses a picture clipping method, a picture clipping device and computer equipment, wherein the picture clipping method comprises the following steps: receiving a picture clipping instruction input by a user, carrying out corresponding equal ratio processing on a first clipped picture according to a preset pop-up layer, receiving the size of a clipping frame, further determining the actual size of the clipping frame in the first clipped picture, then the size of the box after cropping is determined, based on the ratio between the width and the height of the cropping frame, so as to determine the scaling of the first cropping picture, the first cutting picture is scaled according to the scaling, the cutting area of the cutting frame in the target cutting picture is determined according to the left offset and the upper offset of the cutting area, the position of the cutting area in the target cutting picture is determined, the image outside the cutting area is hidden, all the pixel contents of the whole picture do not need to be read into an internal memory, the cropping function of the picture is realized under the condition that a new picture does not need to be output again, so that the cropping efficiency of the picture is improved.

Description

Picture clipping method and device and computer equipment
Technical Field
The invention relates to the technical field of image processing, in particular to picture clipping, a picture clipping device and computer equipment.
Background
With the rapid development of image processing technology, image processing software provided by image processing software developers is more and more in variety and more rich in functions. At present, mainstream image processing software has an image cropping function. The picture cropping function is one of the essential main functions of many websites related to image processing software or pictures nowadays, and allows a user to crop an uploaded picture to obtain a new cropped picture.
The current method for clipping the picture is to clip an original picture to be clipped, and then re-output a new clipped picture. Almost all the picture cropping functions in the world are realized by using html5 new feature canvas. Before the canvas comes out, the web-side processing pictures are limited in their ability to process pictures by setting the pictures to display wide and high sizes or to be used as background pictures, and html5 comes out while bringing new tags such as canvas, audio, video and the like (html tags are many, such as div, p, h1, h2 and the like). Wherein canvas is a container for drawing images, can read the contents of the images, and can achieve the requirements of operating the width and the height or the definition of the images by operating each pixel point in the images, and finally output a new image; each picture has a fixed pixel value, such as a pixel with the size of 2000 × 2000, the picture is composed of 400 ten thousand pixels, each pixel represents a color, and is formed by mixing three rgb colors, one pixel can theoretically represent 25 × 25 colors, the actually stored data volume of the picture can be 4000000 bytes and is approximately equal to 3.8 million (4000000/1024/1024), the process of outputting the new picture is to input all the pixel contents and control parameters of the whole picture, the operation of blurring or synthesizing the new picture is achieved through the operation of each pixel, and the picture processing software like PS software is required to be applied to process the picture, so that each pixel can be accurately obtained. Therefore, the functions of cutting, synthesizing and the like of the picture can be realized. However, the canvas is required to read the content of the picture, manipulate the picture in the memory, and finally re-output a new picture, and the operation process consumes a lot of computing resources.
Disclosure of Invention
The invention provides a picture clipping method, a picture clipping device and computer equipment, and aims to solve the problems that a new picture needs to be output again in the picture clipping process, and a large amount of computing resources are consumed in the operation process.
A picture cropping method comprises the following steps:
receiving a picture cutting instruction input by a user, wherein the picture cutting instruction comprises a first cutting picture and the size of a box corresponding to the first cutting picture;
performing equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and displaying the second cut picture in the preset pop-up layer;
creating a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
receiving the size of a cutting frame set by a user;
calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
according to the ratio of the width to the height of the cutting frame, cutting the box corresponding to the first cutting picture to obtain a cut box corresponding to the ratio;
calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture;
correspondingly zooming the first cut picture according to the zooming proportion to obtain a target cut picture;
calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and displaying the cut picture.
A picture cropping device, comprising:
the image cutting instruction receiving module is used for receiving an image cutting instruction input by a user, wherein the image cutting instruction comprises a first cutting image and the size of a box corresponding to the first cutting image;
the equal ratio processing module is used for carrying out equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and the second cut picture is displayed in the preset pop-up layer;
a creating and cutting operation table module, which creates a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
the size module of the cutting frame is used for receiving the size of the cutting frame set by a user;
the first calculation module is used for calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
the cutting module is used for cutting the box corresponding to the first cutting picture according to the ratio of the width to the height of the cutting frame to obtain a cut box corresponding to the ratio;
the second calculation module is used for calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box and taking the multiplying power as the scaling of the first cutting picture;
the zooming module correspondingly zooms the first cut picture according to the zooming proportion to obtain a target cut picture;
the third calculation module is used for calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
the position determining module is used for determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and the display module displays the cut picture.
A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the above-mentioned picture cropping method when executing the computer program.
A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the above-mentioned picture cropping method.
In one scheme implemented by the image cropping method, the image cropping device and the computer equipment, the scheme obtains the cropped image without outputting a new image again, when the user stops stretching and positioning the cutting frame in the cutting operation table, receiving the size of the cutting frame set in the cutting operation table by the user to obtain the parameters of the values of the left offset and the upper offset of the cutting area, thereby determining the position of the cutting area in the target cutting picture, and then controlling the partial display of the original picture according to the parameters without reading all the pixel contents of the whole picture into a memory, therefore, a great deal of computing resources are saved, so the scheme can realize the purpose of saving the time and the cost without re-outputting a new graph, the image clipping function is realized, so that the image clipping efficiency is improved, and the consumption of computing resources is reduced.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the description of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flowchart of a method for cropping a picture according to an embodiment of the present invention;
FIG. 2 is another flowchart of a method for cropping a picture according to an embodiment of the present invention;
FIG. 3 is a schematic block diagram of an image cropping device according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In an embodiment, as shown in fig. 1, a method for cropping a picture is provided, which includes the following steps:
s10: receiving a picture cutting instruction input by a user, wherein the picture cutting instruction is provided with a first cutting picture and the size of a box corresponding to the first cutting picture.
The first cut picture is a complete original picture needing to be cut, for example, a user sends a first cut picture with the size of 2000 x 2000 pixels to be cut, and a cutting program receives a picture cutting instruction input by the user, wherein the size of a box corresponding to the first cut picture is the actual pixel value of the box of the first cut picture in the display area; for example, the first cropping picture with the size of 2000 × 2000 pixels in the picture cropping command and the box corresponding to the first cropping picture have the size of 100 × 100 pixels.
S20: and carrying out equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and displaying the second cut picture in the preset pop-up layer.
Generally, when a user intends to cut a picture, the user often has a "cut" button, and clicking the "cut" button will pop up a preset pop-up layer on a personal computer, a notebook computer, a smart phone, a tablet computer, and a portable wearable device, where the preset pop-up layer is preset, for example, the size of the preset pop-up layer is 800 × 800 pixels.
The second cropping picture is a picture which is displayed in the preset popup layer and is subjected to geometric processing by the first cropping picture. To display the first cropped picture with size of 2000 × 2000 pixels in the preset pop-up layer with size of 800 × 800 pixels, the first cropped picture with size of 2000 × 2000 pixels needs to be scaled by equal scaling 2000/800 to 2.5 times, that is, the first cropped picture with size of 2000 × 2000 pixels needs to be scaled by equal scaling 2.5 times, so as to obtain the second cropped picture with size of 800 × 800 pixels.
S30: and creating a cutting operation table for setting cutting parameters in the preset popup layer, wherein the size of the cutting operation table is the size of the second cutting picture.
The cutting operation table means that when the first cutting picture is zoomed in or zoomed out in an equal ratio and drawn on the preset pop-up layer, the first cutting picture actually occupies a position and a size area in the preset pop-up layer, and the operation of a subsequent user on the cutting frame cannot exceed the range of the cutting operation table.
For example, a cropping operation table for setting cropping parameters is created in a preset pop-up layer with a size of 800 × 800 pixels, where the size of the second cropping picture is 800 × 800 pixels, that is, the pixels of the cropping operation table are the pixels of the second cropping picture, that is, the size of the cropping operation table is also 800 × 800 pixels.
S40: and receiving the size of the cutting frame set by the user.
The cutting frame is a rectangular cutting frame, the second cutting picture is a rectangular picture, a rectangular coordinate system is established by taking the top left corner vertex of the second cutting picture displayed on the cutting operation table as an original point, and the pixels of the cutting frame comprise the leftmost left offset of the leftmost distance cutting operation table which takes the pixels of the top left corner vertex abscissa of the cutting frame as the cutting frame, the uppermost upper offset of the uppermost distance cutting operation table which takes the top left corner vertex ordinate of the cutting frame as the cutting frame, the width of the cutting frame and the height of the cutting frame. For example, the parameters of the crop box include a left offset left of 400 pixels, an upper offset top of 500 pixels, a width of 400 pixels, and a height of 300 pixels for the crop box.
S50: and calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture.
For example, according to the size of the cropping console also being 800 × 800 pixels, the parameters of the cropping frame with a left offset left of 400 pixels, an upper offset top of 500 pixels, a width of 400 pixels and a height of 300 pixels are calculated, according to the ratio between the left offset left of the cropping frame and the width of the cropping console: l 400/800|, calculating the left offset of the cropping frame to obtain the actual left offset _ left | (400/800) | 1000 pixels of the cropping frame in the first cropped picture; according to the ratio between the upper offset top of the crop box and the height of the crop station: l 500/800|, calculating the upper offset of the cropping frame to obtain the actual offset _ top | (500/800) | 1250 pixels of the cropping frame in the first cropped picture; according to the ratio between the width of the cutting frame and the width of the cutting console: l 400/800|, calculating the width of the cropping frame to obtain the actual width _ width | (400/800) | -1000 pixels of the cropping frame in the first cropping picture; according to the ratio between the high top of the crop box and the high of the crop station: and l 300/800 l, calculating the height of the cropping frame to obtain the actual height of the cropping frame in the first cropping picture, which is 2000 × 2000 (300/800) |, which is 750 pixels.
S60: and according to the ratio of the width to the height of the cutting frame, cutting the box corresponding to the first cutting picture to obtain a cut box corresponding to the ratio.
For example, the ratio between the width and height of the crop box is | 400: 300|, i.e., | 4: 3 l, and the size of the box corresponding to the first cropping picture is 100 × 100 pixels, then according to the width and height of the cropping frame, 4: 3, the box size after cutting corresponding to the ratio is 100 x 75 pixels.
S70: and calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture.
For example, since the actual width _ width of the cropping frame in the first cropping picture is 1000 pixels, the actual height _ height is 750 pixels, and the size of the box after cropping is 100 × 75 pixels, the magnification of the cropping frame between the actual size of the first cropping picture and the size of the box after cropping is 1000/100 times, that is, the scaling ratio of the first cropping picture is 10 times.
S80: and correspondingly zooming the first cut picture according to the zooming proportion to obtain a target cut picture.
For example, the first cropping picture with the size of 2000 × 2000 pixels is correspondingly scaled according to the scaling ratio of 10 times, so that the size of the target cropping picture after scaling is 200 × 200 pixels.
S90: and calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area.
For example, the actual offset _ left of the crop frame in the first crop picture is calculated at a reduction ratio of 10 times to-1000 pixels and the actual offset _ top is calculated at-1250 pixels, so that the left offset of the crop area is-1000/10 to-100 pixels and the up offset is-1250/10 to-125 pixels.
S100: and determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture.
For example, the left offset of the cropping area is-100 pixels, the upper offset is-125 pixels, the size of the target cropping picture is 200 × 200 pixels, the size of the box after cropping is 100 × 75 pixels, and the displayed picture is the cropped picture by using the overflow of the div box, namely hiding the image outside the cropping area, that is, the first cropping picture < img width ═ 100 px'; height ═ 100 px'; after being cut, src ═ 2000 × 2000 px' > becomes a cut picture:
<div style=‘width:100px;height:75px;overflow:hidden’>
<img style=‘width:200px;height:200px;left:-100px;top:-125px’>
</div>。
s110: and displaying the cut picture.
And sending the cut picture to a client so as to enable the client to display the cut picture, wherein the cut picture can be displayed on a personal computer, a notebook computer, a smart phone, a tablet personal computer and portable wearable equipment.
In this embodiment, taking an example of a tool for quickly generating an HTML5 page, when a user needs to make an HTML5 page, a large number of pictures and texts need to be added, where when the pictures are used, a requirement for cutting the pictures is generated, so as to achieve the purpose of editing the pictures and texts; the technical scheme is realized by aiming at the picture cutting, the problem that a canvas reads picture contents, operates the picture in a memory and finally outputs a new picture again in the picture cutting process is solved, the picture cutting function can be performed on the picture under the condition that the new picture is not generated, the picture cutting and outputting efficiency is improved, and the consumption of computing resources is reduced.
In the embodiment corresponding to fig. 1, the present solution obtains the cut picture without outputting a new picture again; after a user stops stretching and positioning the cropping frame in the cropping operation table, the size of the cropping frame set in the cropping operation table by the user is received, parameters of values of the left offset and the upper offset of the cropping area are obtained, the position of the cropping area in a target cropping picture is determined, partial display of an original picture is controlled according to the parameters, and all pixel contents of the whole picture do not need to be read into a memory, so that a large amount of computing resources are saved, the cropping function of the picture can be realized under the condition that a new picture does not need to be output again, the cropping efficiency of the picture is improved, and the loss of the computing resources is reduced.
In an embodiment, after step S100 and before step S110, that is, after the cropped picture is obtained and before the cropped picture is displayed, the method specifically includes the following steps:
s120: and receiving a picture re-cropping instruction input by a user, wherein the picture re-cropping instruction comprises the cropping operation table for setting the cropping parameters.
After the cutting program receives the re-cutting instruction, the re-cutting instruction comprises a cutting operation table used for setting cutting parameters, the same picture can be directly re-cut, and the size of the cutting operation table does not need to be recalculated.
S130: and re-executing the step of setting the size of the cutting frame according to the cutting operation table.
The step of setting the size of the cropping frame and the subsequent steps are executed again according to the size of the cropping console, which is described in detail above and therefore not described herein again.
In this embodiment, a picture resculping instruction input by a user is received, where the picture resculping instruction includes the cropping console for setting the cropping parameters, and the same picture is resculped to directly obtain the cropping console for setting the cropping parameters without recalculation, thereby improving the cropping efficiency.
In an embodiment, in step S20, that is, the performing geometric proportion processing on the first cropped picture according to the preset pop-up layer to obtain the second cropped picture specifically includes the following steps:
and if the width of the first cut picture is smaller than the width of the preset pop-up layer and the height of the first cut picture is smaller than the height of the preset pop-up layer, taking the first cut picture as a second cut picture.
For example, the size of the first cropped picture is 100 × 100 pixels, the size of the preset pop-up layer is 800 × 800 pixels, at this time, the width of 100 pixels of the first cropped picture is smaller than the width of 800 pixels of the preset pop-up layer, and the height of 100 pixels of the first cropped picture is smaller than the height of 800 pixels of the preset pop-up layer, so that the first cropped picture is directly used as the second cropped picture without being stretched or reduced.
And if the width of the first cut picture is equal to that of the preset pop-up layer and the height of the first cut picture is equal to that of the preset pop-up layer, taking the first cut picture as a second cut picture.
For example, the size of the first cropped picture is 100 × 100 pixels, the size of the preset pop-up layer is 100 × 100 pixels, at this time, the width 100 pixels of the first cropped picture is equal to the width 100 pixels of the preset pop-up layer, and the height 100 pixels of the first cropped picture is equal to the height 100 pixels of the preset pop-up layer, so that the first cropped picture is directly used as the second cropped picture without being stretched or reduced.
In this embodiment, the width and the height of the first cropped picture are respectively compared with the width and the height of the preset pop-up layer, and the value of the proportional scaling of the width and the height of the first cropped picture is determined according to the ratio of the width and the height of the first cropped picture, so that the second cropped picture is obtained, and the first cropped picture can be displayed in the cropping console without stretching deformation.
In an embodiment, if the width of the first cropped picture is larger than the width of the preset pop-up layer and the height of the first cropped picture is smaller than the height of the preset pop-up layer, a first ratio of the width of the first cropped picture to the width of the preset pop-up layer is calculated. And reducing the first cut picture according to the first ratio to obtain a second cut picture.
If the size of the first cropped picture is 2000 × 1000 pixels and the size of the preset pop-up layer is 1366 × 1560, and at this time, the width 2000 pixels of the first cropped picture is larger than the width 1566 pixels of the preset pop-up layer, and the height 1000 pixels of the first cropped picture is smaller than the height 1560 pixels of the preset pop-up layer, then calculating a first ratio of the width of the first cropped picture to the width of the preset pop-up layer: 2000/1366-1.464.
That is to say, the width and the height of the first cropped picture need to be reduced by 1.464 times at the same time, the first cropped picture can be completely put down by presetting the pop-up layer, the first cropped picture is reduced by 1.464 times according to the first ratio, and the width of the second cropped picture is obtained: 2000/1.464-1366 pixels, high for the second cropped picture: 1000/1.464-683 pixels, resulting in a second cropped picture size of 1366-683 pixels.
In this embodiment, the width and the height of the first cropped picture are compared with the width and the height of the preset pop-up layer, the value of the equal ratio scaling of the width and the height of the first cropped picture is determined according to the ratio of the width and the height of the first cropped picture, so as to obtain a second cropped picture, the first cropped picture is reduced according to the first ratio, the preset pop-up layer can wrap the next picture, and the first cropped picture is further displayed in the cropping operation table without deformation.
In an embodiment, if the width of the first cropped picture is smaller than the width of the preset pop-up layer and the height of the first cropped picture is larger than the height of the preset pop-up layer, a second ratio of the height of the first cropped picture to the height of the preset pop-up layer is calculated. And reducing the first cut picture according to the second ratio to obtain a second cut picture.
If the size of the first cropped picture is 2000 × 1000 pixels and the size of the preset pop-up layer is 2600 × 768, at this time, the width 2000 pixels of the first cropped picture is smaller than the width 2600 pixels of the preset pop-up layer, and the height 1000 pixels of the first cropped picture is larger than the height 768 pixels of the preset pop-up layer, then calculating a second ratio of the width of the first cropped picture to the height of the preset pop-up layer: 1000/768 ═ 1.302.
That is to say, the width and the height of the first cropped picture need to be reduced by 1.302 times at the same time, the first cropped picture can be completely placed by the preset pop-up layer, and the first cropped picture is reduced by 1.302 times according to the first ratio to obtain the width of the second cropped picture: 2000/1.302 ═ 1512 pixels, high for the second cropped picture: 1000/1.302-768 pixels, resulting in a second cropped picture size of 1512-768 pixels.
In this embodiment, the width and the height of the first cropped picture are respectively compared with the width and the height of the preset pop-up layer, and the value of the equal ratio scaling of the first cropped picture is determined according to the ratio of the width and the height of the preset pop-up layer, so as to obtain a second cropped picture, and the preset pop-up layer can wrap the picture, so that the first cropped picture is further displayed in the cropping console without deformation.
In an embodiment, if the width of the first cropped picture is larger than the width of the preset pop-up layer and the height of the first cropped picture is larger than the height of the preset pop-up layer, a third ratio of the width of the first cropped picture to the width of the preset pop-up layer is calculated. And calculating a fourth ratio of the height of the first cut picture to the height of the preset pop-up layer. And comparing the third ratio with the fourth ratio, and taking the value which is larger as a scaling ratio. And reducing the first cutting picture according to the scaling ratio to obtain a second cutting picture.
If the size of the first cropped picture is 2000 × 1000 pixels and the size of the preset pop-up layer is 1366 × 768 pixels, and the width 2000 pixels of the first cropped picture is larger than the width 1366 pixels of the preset pop-up layer and the height 1000 pixels of the first cropped picture is larger than the height 768 pixels of the preset pop-up layer, the third ratio 2000/1366 between the width of the first cropped picture and the width of the preset pop-up layer is calculated to be 1.464.
Calculating a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer: 1000/768 ═ 1.302.
That is to say, the width of the first cropped picture needs to be reduced by 1.464 times, the picture can be completely placed by presetting the pop-up layer, and meanwhile, in the height dimension, the next first cropped picture can be completely placed by reducing by 1.302 times, so that the image width and height are reduced by 1.464 times at the same time by taking the numerical value as the zoom ratio.
And reducing the first cutting picture according to the scaling ratio of 1.464 times to obtain the width of a second cutting picture: 2000/1.464-1366 pixels, high for the second cropped picture: 1000/1.464-683 pixels, i.e. the size of the resulting second cropped picture is 1366-683 pixels.
In this embodiment, the width and the height of the first cropped picture are respectively compared with the width and the height of the preset pop-up layer, and the value of the equal ratio scaling of the first cropped picture is determined according to the ratio of the width and the height of the preset pop-up layer, so as to obtain the second cropped picture, so that the preset pop-up layer can wrap the next picture, and further the first cropped picture is displayed in the cropping console without deformation.
In an embodiment, as shown in fig. 2, the parameters of the crop box include a leftmost offset amount of the leftmost distance from the cropping console with a pixel of an abscissa of an upper-left vertex of the crop box as the cropping box, an uppermost offset amount of the uppermost distance from the cropping console with an ordinate of the upper-left vertex of the crop box as the cropping box, a width of the crop box, and a height of the crop box, and in step S50, that is, the calculating the size of the crop box obtains an actual size of the crop box in the first crop picture, specifically includes the following steps:
s51: calculating the width of the cutting frame by adopting the following formula to obtain the actual width of the cutting frame in the first cutting picture:
the actual width is the width of the first cropping picture, the width of the crop box/the width of the cropping station.
For example, if the width of the cropping frame is 400 pixels, the size of the first cropping picture is 2000 × 1000 pixels, and the size of the cropping console is 800 × 800 pixels, then the actual width _ width of the first cropping picture is 2000 × 2000 (400/800) | 1000 pixels.
S52: calculating the height of the cutting frame by adopting the following formula to obtain the actual height of the cutting frame in the first cutting picture:
the actual high is the high of the crop box of the first crop picture/the high of the crop console.
For example, if the height of the crop box is 300 pixels, the actual height of the crop box in the first crop picture is 2000 × 750 pixels (300/800).
S53: calculating the left offset of the cutting frame by adopting the following formula to obtain the actual left offset of the cutting frame in the first cutting picture:
the actual left offset is the width of the first cropping picture, the left offset of the crop box/the width of the cropping console.
For example, if the left offset left of the cropping frame is 400 pixels, the actual left offset _ left of the first cropped picture is 2000 × 2000 | (400/800) | 1000 pixels.
S54: calculating the upper offset of the cutting frame by adopting the following formula to obtain the actual offset of the cutting frame in the first cutting picture:
for example, if the top offset top of the cropping frame is 500 pixels, the actual offset _ top of the first cropped picture is 2000 × 2000 (500/800) | 1250 pixels.
In practice, the offset is the top offset of the first cropping frame/the height of the cropping station.
It can be seen that, in the embodiment corresponding to fig. 2, the parameters of the cropping frame in the cropping operation table are set, and the parameters of the cropping frame in the cropping operation table are correspondingly calculated according to the corresponding formula, so that the actual pixels of the cropping frame in the first cropping picture can be accurately obtained.
In an embodiment, in step S40, the receiving the size of the crop box set by the user specifically includes the following steps:
s41: and receiving the movement operation of the contact point set on the frame line of the cutting frame by the user, and adjusting the size of the cutting frame according to the movement operation.
In the embodiment, the cutting frame is a rectangular cutting frame, the rectangular cutting frame is respectively provided with a contact point in the middle of four vertexes and four side lines, and the cutting area framed and selected by the cutting frame can be adjusted by moving the contact point.
In this embodiment, the user can conveniently and quickly and accurately cut out the required picture by receiving the moving operation of the contact point arranged on the frame line of the cutting frame and adjusting the size of the cutting frame according to the moving operation, and the user can conveniently and finely adjust the cutting frame, so that the picture cutting efficiency is improved.
It should be understood that, the sequence numbers of the steps in the above embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the present invention.
In an embodiment, an image cropping device is provided, and the image cropping device corresponds to the image cropping method in the above embodiment one to one. As shown in fig. 3, the picture cropping device comprises a received picture cropping instruction module 10, an equal ratio processing module 20, a create cropping console module 30, a received cropping frame size module 40, a first calculation module 50, a cropping module 60, a second calculation module 70, a scaling module 80, a third calculation module 90, a determined position module 100 and a presentation module 110. The functional modules are explained in detail as follows:
the image cutting instruction receiving module 10 is used for receiving an image cutting instruction input by a user, wherein the image cutting instruction comprises a first cutting image and the size of a box corresponding to the first cutting image;
the equal ratio processing module 20 is used for performing equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and the second cut picture is displayed in the preset pop-up layer;
a creating and cutting operation table module 30, which creates a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
a crop box size receiving module 40 for receiving the size of the crop box set by the user;
the first calculation module 50 is used for calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
a clipping module 60, which clips the box corresponding to the first clipping picture according to the ratio between the width and the height of the clipping frame to obtain a clipped box corresponding to the ratio;
the second calculating module 70 is used for calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture;
the zooming module 80 correspondingly zooms the first cut picture according to the zooming proportion to obtain a target cut picture;
a third calculating module 90, configured to calculate actual pixels of the cropping frame in the first cropped picture according to the scaling ratio to obtain a cropping area, where the cropping area includes a left offset of the cropping area and an offset on the cropping area;
a position determining module 100, configured to determine, according to the left offset and the upper offset of the clipping region, a position of the clipping region in the target clipping picture, and hide images outside the clipping region to obtain a clipped picture;
and a display module 110 for displaying the cut picture.
For the specific definition of the picture cropping device, reference may be made to the above definition of the picture cropping method, which is not described herein again. The modules in the image cropping device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 4. The computer device includes a processor, a memory, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The computer program is executed by a processor to implement a method of cropping a picture.
In one embodiment, there is provided a computer device having a computer program stored thereon, the computer program when executed by a processor implementing the steps of:
receiving a picture cutting instruction input by a user, wherein the picture cutting instruction comprises a first cutting picture and the size of a box corresponding to the first cutting picture;
performing equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and displaying the second cut picture in the preset pop-up layer;
creating a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
receiving the size of a cutting frame set by a user;
calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
according to the ratio of the width to the height of the cutting frame, cutting the box corresponding to the first cutting picture to obtain a cut box corresponding to the ratio;
calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture;
correspondingly zooming the first cut picture according to the zooming proportion to obtain a target cut picture;
calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and displaying the cut picture.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
receiving a picture cutting instruction input by a user, wherein the picture cutting instruction comprises a first cutting picture and the size of a box corresponding to the first cutting picture;
performing equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and displaying the second cut picture in the preset pop-up layer;
creating a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
receiving the size of a cutting frame set by a user;
calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
according to the ratio of the width to the height of the cutting frame, cutting the box corresponding to the first cutting picture to obtain a cut box corresponding to the ratio;
calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture;
correspondingly zooming the first cut picture according to the zooming proportion to obtain a target cut picture;
calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and displaying the cut picture.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A picture cropping method is characterized by comprising the following steps:
receiving a picture cutting instruction input by a user, wherein the picture cutting instruction comprises a first cutting picture and the size of a box corresponding to the first cutting picture;
performing equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and displaying the second cut picture in the preset pop-up layer;
creating a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
receiving the size of a cutting frame set by a user;
calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
according to the ratio of the width to the height of the cutting frame, cutting the box corresponding to the first cutting picture to obtain a cut box corresponding to the ratio;
calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box, and taking the multiplying power as the scaling of the first cutting picture;
correspondingly zooming the first cut picture according to the zooming proportion to obtain a target cut picture;
calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and displaying the cut picture.
2. The method of claim 1, wherein after the obtaining the cropped picture and before the displaying the cropped picture, the method further comprises:
receiving a picture re-cropping instruction input by a user, wherein the picture re-cropping instruction comprises a cropping operation table for setting cropping parameters;
and re-executing the step of setting the size of the cutting frame according to the cutting operation table.
3. The picture cropping method according to claim 1, wherein said performing an equal ratio process on said first cropped picture according to a preset pop-up layer to obtain a second cropped picture comprises:
if the width of the first cut picture is smaller than the width of the preset pop-up layer and the height of the first cut picture is smaller than the height of the preset pop-up layer, taking the first cut picture as a second cut picture;
and if the width of the first clipping picture is equal to the width of the preset popping layer and the height of the first clipping picture is equal to the height of the preset popping layer, taking the first clipping picture as the second clipping picture.
4. The picture cropping method of claim 3, wherein the method further comprises:
if the width of the first clipping picture is larger than the width of the preset popping layer and the height of the first clipping picture is smaller than the height of the preset popping layer, calculating a first ratio of the width of the first clipping picture to the width of the preset popping layer;
and reducing the first cutting picture according to the first ratio to obtain a second cutting picture.
5. The picture cropping method of claim 4, wherein the method further comprises:
if the width of the first clipping picture is smaller than the width of the preset popping layer and the height of the first clipping picture is larger than the height of the preset popping layer, calculating a second ratio of the height of the first clipping picture to the height of the preset popping layer;
and reducing the first cut picture according to the second ratio to obtain a second cut picture.
6. The picture cropping method of claim 5, wherein the method further comprises:
if the width of the first clipping picture is larger than the width of the preset pop-up layer and the height of the first clipping picture is larger than the height of the preset pop-up layer, calculating a third ratio of the width of the first clipping picture to the width of the preset pop-up layer;
calculating a fourth ratio of the height of the first cut picture to the height of the preset pop-up layer;
comparing the third ratio with the fourth ratio, and taking the value of the third ratio as a scaling ratio;
and reducing the first cutting picture according to the scaling ratio to obtain a second cutting picture.
7. The method of claim 1, wherein the parameters of the crop box include a leftmost offset from a cropping table with a pixel of an abscissa of an upper left vertex of the crop box, an uppermost offset from the cropping table with an ordinate of the upper left vertex of the crop box, a width of the crop box, and a height of the crop box, and the calculating the size of the crop box to obtain an actual size of the crop box in the first crop picture comprises:
calculating the width of the cutting frame by adopting the following formula to obtain the actual width of the cutting frame in the first cutting picture:
the actual width is the width of the cropping frame of the first cropping picture/the width of the cropping console;
calculating the height of the cutting frame by adopting the following formula to obtain the actual height of the cutting frame in the first cutting picture:
the actual height is the height of the high cutting frame of the first cutting picture/the height of the cutting operation table;
calculating the left offset of the cutting frame by adopting the following formula to obtain the actual left offset of the cutting frame in the first cutting picture:
the actual left offset is the width of the first cropping picture, the left offset of the cropping frame/the width of the cropping console;
calculating the upper offset of the cutting frame by adopting the following formula to obtain the actual offset of the cutting frame in the first cutting picture:
in practice, the offset is the top offset of the first cropping frame/the height of the cropping station.
8. The picture cropping method of claim 1, wherein said receiving a user-set crop box size comprises:
and receiving the movement operation of the contact point set on the frame line of the cutting frame by the user, and adjusting the size of the cutting frame according to the movement operation.
9. A picture cropping device, comprising:
the image cutting instruction receiving module is used for receiving an image cutting instruction input by a user, wherein the image cutting instruction comprises a first cutting image and the size of a box corresponding to the first cutting image;
the equal ratio processing module is used for carrying out equal ratio processing on the first cut picture according to a preset pop-up layer to obtain a second cut picture, and the second cut picture is displayed in the preset pop-up layer;
a creating and cutting operation table module, which creates a cutting operation table for setting cutting parameters in the preset pop-up layer, wherein the size of the cutting operation table is the size of the second cutting picture;
the size module of the cutting frame is used for receiving the size of the cutting frame set by a user;
the first calculation module is used for calculating the size of the cutting frame to obtain the actual size of the cutting frame in the first cutting picture;
the cutting module is used for cutting the box corresponding to the first cutting picture according to the ratio of the width to the height of the cutting frame to obtain a cut box corresponding to the ratio;
the second calculation module is used for calculating the multiplying power of the cutting frame between the actual size of the first cutting picture and the size of the cut box and taking the multiplying power as the scaling of the first cutting picture;
the zooming module correspondingly zooms the first cut picture according to the zooming proportion to obtain a target cut picture;
the third calculation module is used for calculating the actual pixels of the cutting frame in the first cutting picture according to the scaling ratio to obtain a cutting area, wherein the cutting area comprises a left offset of the cutting area and an upper offset of the cutting area;
the position determining module is used for determining the position of the cutting area in the target cutting picture according to the left offset and the upper offset of the cutting area, and hiding images outside the cutting area to obtain a cut picture;
and the display module displays the cut picture.
10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the picture cropping method according to any one of claims 1 to 8 when executing the computer program.
CN202010357558.0A 2020-04-29 2020-04-29 Picture clipping method and device and computer equipment Pending CN111667487A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202010357558.0A CN111667487A (en) 2020-04-29 2020-04-29 Picture clipping method and device and computer equipment
PCT/CN2020/118001 WO2021218016A1 (en) 2020-04-29 2020-09-27 Picture cropping method and apparatus, computer device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010357558.0A CN111667487A (en) 2020-04-29 2020-04-29 Picture clipping method and device and computer equipment

Publications (1)

Publication Number Publication Date
CN111667487A true CN111667487A (en) 2020-09-15

Family

ID=72382897

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010357558.0A Pending CN111667487A (en) 2020-04-29 2020-04-29 Picture clipping method and device and computer equipment

Country Status (2)

Country Link
CN (1) CN111667487A (en)
WO (1) WO2021218016A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112541919A (en) * 2020-12-29 2021-03-23 申建常 Picture segmentation processing method and processing system
CN112700454A (en) * 2020-12-28 2021-04-23 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
WO2021218016A1 (en) * 2020-04-29 2021-11-04 平安科技(深圳)有限公司 Picture cropping method and apparatus, computer device, and storage medium
CN116095249A (en) * 2022-05-30 2023-05-09 荣耀终端有限公司 Video processing method and electronic equipment
CN112700454B (en) * 2020-12-28 2024-05-14 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115131197A (en) * 2022-04-11 2022-09-30 广州宇中网络科技有限公司 Image preprocessing method, system and equipment based on network service intermediate layer

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106296760B (en) * 2015-05-21 2021-05-14 腾讯科技(深圳)有限公司 Picture clipping method and device
US10124606B2 (en) * 2016-04-20 2018-11-13 Butt Nouman Idris Under-glass digital printing method of multilayer synthetic leather
CN107544730B (en) * 2017-08-25 2020-06-09 广州视源电子科技股份有限公司 Picture display method and device and readable storage medium
CN109727257A (en) * 2018-12-28 2019-05-07 北京金山安全软件有限公司 Method, device and terminal for automatically cutting picture
CN111667487A (en) * 2020-04-29 2020-09-15 平安科技(深圳)有限公司 Picture clipping method and device and computer equipment

Cited By (6)

* 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
CN112700454A (en) * 2020-12-28 2021-04-23 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112700454B (en) * 2020-12-28 2024-05-14 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112541919A (en) * 2020-12-29 2021-03-23 申建常 Picture segmentation processing method and processing system
CN116095249A (en) * 2022-05-30 2023-05-09 荣耀终端有限公司 Video processing method and electronic equipment
CN116095249B (en) * 2022-05-30 2023-10-20 荣耀终端有限公司 Video processing method and electronic equipment

Also Published As

Publication number Publication date
WO2021218016A1 (en) 2021-11-04

Similar Documents

Publication Publication Date Title
CN111667487A (en) Picture clipping method and device and computer equipment
US8745515B2 (en) Presentation of large pages on small displays
US7337399B2 (en) Apparatus, system, and method for editing a region of a document intersecting multiple content component types in a single operation
JP4770878B2 (en) Information display device and program
US7738735B2 (en) Image processing apparatus for resizing of images, image processing method for resizing images, program, and storage medium
KR20070026681A (en) Method and system for viewing and enhancing images
CA2537100A1 (en) Improved presentation of large objects on small displays
CN113127784A (en) Large-screen data visual display method and device, storage medium and computer equipment
CN112684966A (en) Picture scaling method and device and electronic equipment
US20100295869A1 (en) System and method for capturing digital images
CN112367481A (en) Video clip processing method and device
CN115237522A (en) Page self-adaptive display method and device
CN111986088A (en) Image processing method, image processing device, storage medium and terminal equipment
CN114356479B (en) Page rendering method and device
CN110443772B (en) Picture processing method and device, computer equipment and storage medium
CN107861711B (en) Page adaptation method and device
WO2021259249A1 (en) Data display processing method and apparatus, computer device and storage medium
CN111045576B (en) Display control method, display control device, terminal equipment and electronic equipment
CN115454365A (en) Picture processing method and device, electronic equipment and medium
US20220005151A1 (en) Method of processing picture, computing device, and computer-program product
CN110519530B (en) Hardware-based picture-in-picture display method and device
US9384412B2 (en) Method and apparatus, computer-readable medium for content aware multimedia resizing
CN113379768A (en) Image processing method, image processing device, storage medium and computer equipment
CN113296661A (en) Image processing method and device, electronic equipment and readable storage medium
CN107357938B (en) Webpage display 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