[go: up one dir, main page]

WO2021218016A1 - Picture cropping method and apparatus, computer device, and storage medium - Google Patents

Picture cropping method and apparatus, computer device, and storage medium Download PDF

Info

Publication number
WO2021218016A1
WO2021218016A1 PCT/CN2020/118001 CN2020118001W WO2021218016A1 WO 2021218016 A1 WO2021218016 A1 WO 2021218016A1 CN 2020118001 W CN2020118001 W CN 2020118001W WO 2021218016 A1 WO2021218016 A1 WO 2021218016A1
Authority
WO
WIPO (PCT)
Prior art keywords
cropping
picture
cropped
cropped picture
width
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.)
Ceased
Application number
PCT/CN2020/118001
Other languages
French (fr)
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
Publication of WO2021218016A1 publication Critical patent/WO2021218016A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/04Context-preserving transformations, e.g. by using an importance map
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4023Scaling of whole images or parts thereof, e.g. expanding or contracting based on decimating pixels or lines of pixels; based on inserting pixels or lines of pixels
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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

Definitions

  • This application relates to the field of artificial intelligence, to the field of image processing technology, and in particular to a picture cropping method, device, computer equipment, and storage medium.
  • the current mainstream image processing software all have the image cropping function.
  • the picture cropping function is one of the main functions necessary for many image processing software or picture websites today. It allows users to crop the uploaded picture to obtain a new cropped picture.
  • the current method of image cropping is to import the original image that needs to be cropped, and then crop the original image to obtain a new cropped image.
  • almost all picture cropping functions in the world are realized by the new feature canvas of html5.
  • the web-side processed pictures by setting the display width and height of the picture or using it as a background picture. Its ability to process pictures was very limited.
  • html5 came out it also brought new labels such as canvas, audio, video (html tags). There are many, such as div, p, h1, h2, etc.).
  • canvas is the container used to draw the image.
  • a picture has a fixed pixel value, such as a pixel with a size of 2000 * 2000, the picture is composed of 4 million pixels, and at the same time, each pixel represents a color, which is composed of three colors of rgb. A pixel can theoretically represent 25 * 25 * 25 colors.
  • the actual data size of the image may be 4000000 bytes, which is approximately equal to 3.8 megabytes (4000000 / 1024 / 1024).
  • the process of outputting a new image is Input the content and control parameters of all pixels of the entire image, and use the calculation of each pixel to achieve the operation of blurring or synthesizing a new image, and image processing software such as PS software is required to process the image to be accurate To every pixel. In this way, functions such as cropping and compositing of pictures can be realized.
  • This application provides a picture cropping method, device, computer equipment, and storage medium to solve the problem that a new picture needs to be re-output during the picture cropping process, and a large amount of computing resources will be consumed in the calculation process.
  • a picture cropping method includes: receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; The first cropped picture is subjected to equal ratio processing to obtain the second cropped picture, which is displayed in the preset pop-up layer; a cropping console for setting cropping parameters is created in the preset pop-up layer, wherein the cropping
  • the size of the console is the size of the second cropped picture; receives the size of the crop frame set by the user; calculates the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; according to The ratio between the width and the height of the cropping frame, crop the box corresponding to the first cropped picture to obtain the cropped box corresponding to the ratio; calculate the actual size of the cropping frame in the first cropped picture
  • the magnification between the size of the cropped box and the size of the cropped box, and the magnification is used as the zoom ratio of the
  • a picture cropping device comprising: a picture cropping instruction module that receives a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; etc.
  • the ratio processing module which performs equal ratio processing on the first cropped picture according to the preset pop-up layer, obtains the second cropped picture, and displays it in the preset pop-up layer; creates a cropping console module, and pops it up in the preset A cropping console for setting cropping parameters is created in the layer, wherein the size of the cropping console is the size of the second cropped picture; a module for receiving cropping frame size, receiving the size of the cropping frame set by the user; a first calculation module Calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; the cropping module, according to the ratio between the width and the height of the cropping frame, performs the first cropping The box corresponding to the picture is cropped to obtain the cropped box corresponding to the ratio; the second calculation module calculates the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and The magnification is used as the zoom ratio of the first cropped picture; the
  • a computer device includes a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor.
  • the processor executes the computer-readable instructions, the following steps are implemented: receiving a user The inputted picture cropping instruction, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer, Obtain the second cropped picture and display it in the preset pop-up layer; create a cropping operation table for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping operation table is the second cropping The size of the picture; receiving the size of the cropping frame set by the user; calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; according to the width and height of the cropping frame The ratio of the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the cropping box is calculated between the actual size of
  • One or more readable storage media storing computer readable instructions, when the computer readable instructions are executed by one or more processors, the one or more processors perform the following steps: receiving a picture input by a user A cropping instruction, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer to obtain the second Crop the picture and display it in the preset pop-up layer; create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture Receive the size of the crop frame set by the user; calculate the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; according to the ratio between the width and height of the crop frame, Crop the box corresponding to the first cropped picture to obtain a cropped box corresponding to the ratio; calculate the magnification of the cropping frame between the actual size of the first cropped
  • this solution obtains the cropped picture without re-outputting a new picture.
  • the user stops cropping in the cropping console After the frame is stretched and positioned, the size of the crop frame set by the user in the cropping console is received, and the parameters of the left offset and the upper offset of the cropped area are obtained, so as to determine the size of the cropped area in the target cropped picture.
  • Fig. 1 is a flowchart of a picture cropping method in an embodiment of the present application
  • FIG. 2 is another flowchart of a picture cropping method in an embodiment of the present application
  • Fig. 3 is a schematic block diagram of a picture cropping device in an embodiment of the present application.
  • Fig. 4 is a schematic diagram of a computer device in an embodiment of the present application.
  • a method for cropping a picture which includes the following steps:
  • S10 Receive a picture cropping instruction input by the user, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture.
  • the first cropped picture is a complete original picture that needs to be cropped.
  • the user sends out a first cropped picture with a size of 2000 * 2000 pixels to crop
  • the cropping program receives the picture cropping instruction input by the user.
  • the size of the box corresponding to the first cropped picture is the actual pixel value of the box in the display area of the first cropped picture; for example, the first cropped picture and the first cropped picture with a size of 2000 * 2000 pixels are included in the picture cropping instruction
  • the size of the corresponding box is 100* 100 pixels.
  • S20 Perform proportional processing on the first cropped picture according to the preset pop-up layer to obtain a second cropped picture, and display it in the preset pop-up layer.
  • a preset pop-up layer is popped up.
  • the preset pop-up layer is preset.
  • the size of the preset pop-up layer is 800*800 pixels.
  • the second cropped picture refers to a picture in which the first cropped picture displayed in the preset pop-up layer undergoes equal ratio processing.
  • 2000/800 2.5 times, that is, the first cropped picture with a size of 2000 * 2000 pixels is reduced by 2.5 times to obtain a second cropped picture with a size of 800 * 800 pixels.
  • S30 Create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture.
  • the cropping console refers to the area where the first cropped picture actually occupies the position and size of the preset pop-up layer when the first cropped picture is scaled up or down and drawn on the preset pop-up layer, and the user’s subsequent crop frame None of the operations can exceed the scope of this cutting console.
  • the cropping frame is a rectangular cropping frame
  • the second cropping picture is a rectangular picture.
  • a rectangular coordinate system is established with the top-left vertex of the second cropping picture displayed on the cropping console as the origin.
  • the pixels of the cropping frame include the top left of the cropping frame.
  • the pixel of the abscissa of the corner vertex is the left offset of the leftmost corner of the cropping frame from the leftmost left of the cutting console, and the ordinate of the top left corner of the cropping frame is the topmost distance of the cropping frame.
  • the upper offset of the top edge of the cropping console The amount, the width of the cropping frame and the height of the cropping frame.
  • the parameters of the cropping frame include that the left offset of the cropping frame is 400 pixels, the top offset is 500 pixels, the width is 400 pixels, and the height is 300 pixels.
  • S50 Calculate the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture.
  • the left offset of the crop frame is 400 pixels
  • the top offset is 500 pixels
  • the width is 400 pixels
  • the height is 300 pixels.
  • the actual left offset of the first cropped picture _left 2000*
  • 1000 pixels
  • 1250 pixels
  • the width of the cropping frame is calculated to obtain that the cropping frame is in the first
  • the actual width of a cropped picture_width 2000*
  • the ratio between the width and height of the cropping frame is
  • S70 Calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and use the magnification as the zoom ratio of the first cropped picture.
  • the actual height _height 750 pixels
  • the size of the cropped box is 100*75 pixels
  • the cropping frame is in the first cropped picture.
  • the first cropped picture with a size of 2000*2000 pixels is correspondingly scaled according to a zoom ratio of 10 times, and the size of the target cropped picture obtained according to the zoom ratio is 200*200 pixels.
  • S90 Calculate the actual pixels of the cropping frame in the first cropped picture according to the zoom ratio to obtain a cropped area, where the cropped area includes a left offset of the cropped area and an upper offset of the cropped area.
  • S100 Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area, and obtain a cropped picture.
  • the left offset of the crop area is -100 pixels
  • the upper offset is -125 pixels
  • the size of the target cropped image is 200*200 pixels
  • the size of the cropped box is 100*75 pixels
  • the overflow hidden style attribute of the box, that is, hide the image outside the cropped area
  • the cropped picture is sent to the client, so that the client displays the cropped picture, and the cropped picture can be displayed on a personal computer, a notebook computer, a smart phone, a tablet computer, and a portable wearable device.
  • this solution does not need to re-output a new image to obtain the cropped picture; when the user stops stretching and positioning the crop frame in the cropping console, the receiving user is cropping
  • the size of the cropping frame set in the console is used to obtain the left offset and upper offset parameters of the cropped area, so as to determine the position of the cropped area in the target cropped image, and then obtain the control of the original image according to the above parameters
  • Partial display does not need to read all the pixel content of the entire picture into the memory, so it saves a lot of computing resources, so this solution can realize the cropping function of the picture without re-outputting a new picture. Thereby improving the efficiency of picture cropping and reducing the loss of computing resources.
  • step S100 and before S110 that is, after the cropped picture is obtained, and before the cropped picture is displayed, the following steps are specifically included:
  • S120 Receive a picture re-cropping instruction input by the user, where the picture re-cropping instruction includes the cropping console for setting cropping parameters.
  • the re-cropping instruction includes a cropping console for setting cropping parameters, which can directly re-crop the same picture without recalculating the size of the cropping console.
  • the picture re-cropping instruction input by the user is received, where the picture re-cropping instruction includes the cropping console for setting cropping parameters.
  • the picture re-cropping instruction includes the cropping console for setting cropping parameters.
  • Re-cropping the same picture can directly obtain cropping for setting cropping parameters.
  • the operating table does not need to be recalculated, which improves cutting efficiency.
  • step S20 that is, performing equal ratio processing on the first cropped picture according to the preset pop-up layer to obtain the second cropped picture, specifically includes the following steps:
  • the first cropped picture is taken as the first cropped picture. 2. Crop the picture.
  • the size of the first cropped picture is 100*100 pixels, and the size of the preset pop-up layer is 800*800 pixels.
  • the width of the first cropped picture is 100 pixels wider than that of the preset pop-up layer by 800 pixels. If the pixels are small, 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, the first cropped picture does not need to be stretched or reduced, and it is directly used as the second cropped picture.
  • the first cropped picture is taken as the first cropped picture. 2. Crop the picture.
  • the size of the first cropped picture is 100*100 pixels
  • the size of the preset pop-up layer is 100*100 pixels.
  • the width of the first cropped picture is 100 pixels and the width of the preset pop-up layer is 100 pixels. If the pixels are equal, and the height of 100 pixels of the first cropped picture is equal to the height of 100 pixels of the preset pop-up layer, the first cropped picture does not need to be stretched or reduced, and it is directly used as the second cropped picture.
  • the width and height of the first cropped image are compared with the width and height of the preset pop-up layer, and the ratio of the width and height of the first cropped image is determined according to the ratio of the two.
  • Obtaining the second cropped picture can enable the first cropped picture to be displayed in the cropping console without being stretched or deformed.
  • the first crop is calculated The first ratio of the width of the picture to the width of the preset pop-up layer.
  • the first cropped picture is reduced according to the first ratio to obtain the second cropped picture.
  • the size of the first cropped picture is 2000 * 1000 pixels
  • the size of the preset pop-up layer is 1366 * 1560.
  • the width of the first cropped picture is 2000 pixels larger than the width of the preset pop-up layer of 1566 pixels.
  • the width and height of the first cropped picture need to be reduced by 1.464 times at the same time, so that the preset pop-up layer can fully place the first cropped picture, and the first cropped picture is reduced according to the first ratio of 1.464 times to obtain the second crop.
  • the width of the picture: 2000/1.464 1366 pixels
  • the height of the second cropped picture: 1000/1.464 683 pixels
  • the size of the second cropped picture is 1366*683 pixels.
  • the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer, and the ratio of the width and height of the first cropped picture is determined according to the ratio of the two. , So as to obtain the second cropped picture, and reduce the first cropped picture according to the first ratio, so that the preset pop-up layer can wrap the picture, and further enable the first cropped picture to be displayed in the cropping console without deformation.
  • the first crop is calculated The second ratio of the height of the picture to the height of the preset pop-up layer.
  • the first cropped picture is reduced according to the second ratio to obtain the second cropped picture.
  • the width of the first cropped picture is 2000 pixels smaller than the width of the preset pop-up layer of 2600 pixels
  • the height of the first cropped picture is 1000 pixels larger than the height of the preset pop-up layer by 768 pixels
  • the width and height of the first cropped image need to be reduced by 1.302 times at the same time, so that the preset pop-up layer can fully place the first cropped image, and the first cropped image is reduced according to the first ratio of 1.302 times to obtain the second crop.
  • the width of the picture: 2000/1.302 1512 pixels
  • the height of the second cropped picture: 1000/1.302 768 pixels
  • the size of the second cropped picture is 1512*768 pixels.
  • the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer respectively, and the proportional zoom value of the first cropped picture is determined according to the ratio of the two, so as to obtain the second
  • the picture is cropped, and the preset pop-up layer can wrap the picture, further making the first cropped picture displayed in the cropping console without distortion.
  • the first cropped picture is calculated The third ratio of the width of and the width of the preset pop-up layer. Calculate a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer. The third ratio is compared with the fourth ratio, and the larger value is the zoom ratio. The first cropped picture is reduced according to the zoom ratio to obtain the second cropped picture.
  • the size of the first cropped picture is 2000 * 1000 pixels
  • the size of the preset pop-up layer is 1366 * 768 pixels.
  • the width of the first cropped picture is 2000 pixels larger than the width of the preset pop-up layer of 1366 pixels.
  • the height of the first cropped picture is 1000 pixels larger than the height of the preset pop-up layer is 768 pixels
  • the width of the first cropped picture needs to be reduced by 1.464 times, so that the preset pop-up layer can fully place the picture.
  • the first cropped picture needs to be reduced by 1.302 times to fully place the first cropped picture, so take the value
  • the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer respectively, and the proportional zoom value of the first cropped picture is determined according to the ratio of the two, so as to obtain the second
  • the picture is cropped so that the preset pop-up layer can wrap the picture, so that the first cropped picture is displayed in the cropping console without deformation.
  • the cropping frame parameters include taking the pixel of the abscissa of the vertex of the upper left corner of the cropping frame as the leftmost offset of the cropping frame from the leftmost left of the cropping console, and taking the cropping frame
  • the ordinate of the upper left corner vertex is the upper offset of the uppermost edge of the cropping frame from the uppermost edge of the cutting console, the width of the cropping frame, and the height of the cropping frame.
  • step S50 it is the size of the cropping frame. Performing calculations to obtain the actual size of the cropping frame in the first cropped picture specifically includes the following steps:
  • Actual width The width of the first cropped picture * the width of the cropping frame/the width of the cropping console.
  • the width of the cropping frame is 400 pixels
  • the size of the first cropped picture is 2000*1000 pixels
  • the size of the cropping console is 800*800 pixels
  • the actual width of the first cropped picture_width 2000*
  • 1000 pixels.
  • the actual height the height of the first cropped picture * the height of the cropping frame / the height of the cropping console.
  • the actual height of the cropping frame in the first cropped picture_height 2000*
  • 750 pixels.
  • Actual left Offset the width of the first cropped picture * the left offset of the cropping frame / the width of the cropping console.
  • 1000 pixels.
  • 1250 pixels.
  • Actual offset height of the first cropped picture*upper offset of cropping frame/height of cropping console.
  • step S40 the receiving the size of the crop frame set by the user specifically includes the following steps:
  • S41 Receive a moving operation of the contact set by the user on the frame line of the cropping frame, and adjust the size of the cropping frame according to the moving operation.
  • the cropping frame in this embodiment is a rectangular cropping frame.
  • the rectangular cropping frame is provided with a contact point each in the middle of the four vertices and four edges, and the cropping area selected by the cropping frame can be adjusted by moving the contact points.
  • a picture cropping device is provided, and the picture cropping device corresponds to the picture cropping method in the above-mentioned embodiment one-to-one.
  • the picture cropping device includes a picture cropping instruction module 10, a ratio processing module 20, a cropping console creation module 30, a crop frame size receiving module 40, a first calculation module 50, a cropping module 60, and a second The calculation module 70, the zoom module 80, the third calculation module 90, the position determination module 100, and the display module 110.
  • the detailed description of each functional module is as follows: the picture cropping instruction module 10 receives the picture cropping instruction input by the user, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; etc.
  • the ratio processing module 20 performs equal ratio processing on the first cropped picture according to a preset pop-up layer to obtain a second cropped picture, which is displayed in the preset pop-up layer; creates a cropping console module 30, Suppose that a cropping console for setting cropping parameters is created in the pop-up layer, where the size of the cropping console is the size of the second cropped picture; the cropping frame size receiving module 40 receives the size of the cropping frame set by the user; A calculation module 50 calculates the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; the crop module 60 calculates the size of the crop frame according to the ratio between the width and the height of the crop frame The box corresponding to the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the second calculation module 70 calculates the difference between the actual size of the cropped frame in the first cropped picture and the size of the cropped box The zoom ratio of the first cropped picture; the zoom module 80 correspondingly zooms the first cropped picture according
  • Each module in the above-mentioned picture cropping device can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above-mentioned modules may be embedded in the form of hardware or independent of the processor in the computer equipment, or may be stored in the memory of the computer equipment in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.
  • a computer device is provided.
  • the computer device may be a terminal, and its internal structure diagram may be as shown in FIG. 4.
  • the computer equipment includes a processor, a memory, a display screen and an input device connected through a system bus.
  • the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system and computer readable instructions.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the computer readable instruction is executed by the processor to realize a picture cropping method.
  • a computer device including a memory, a processor, and computer-readable instructions stored in the memory and running on the processor, and the processor implements the following steps when the computer-readable instructions are executed:
  • the inputted picture cropping instruction wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer, Obtain the second cropped picture and display it in the preset pop-up layer; create a cropping operation table for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping operation table is the second cropping
  • the size of the picture receiving the size of the cropping frame set by the user; calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; according to the width and height of the cropping frame
  • the ratio of the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the cropping box is calculated between the actual size of
  • one or more readable storage media storing computer readable instructions are provided.
  • the readable storage medium stores computer readable instructions.
  • the readable storage media provided in this embodiment include non-transitory A volatile readable storage medium and a volatile readable storage medium.
  • the one or more processors implement the following steps: receiving a picture cropping instruction input by a user, wherein , The picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer to obtain the second cropped picture, and Displayed in the preset pop-up layer; create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; receiving user settings The size of the cropping frame; the size of the cropping frame is calculated to obtain the actual size of the cropping frame in the first cropped picture; according to the ratio between the width
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

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

Abstract

The present application relates to the field of artificial intelligence. Disclosed are a picture cropping method and apparatus, a computer device and a storage medium. Said method comprises: receiving a picture cropping instruction inputted by a user; according to a preset pop-up layer, performing corresponding proportional processing on a first cropping picture; then receiving the size of a cropping frame; determining the actual size of the cropping frame in the first cropping picture; determining the size of a cropped box according to the ratio of the width to the height of the cropping frame; determining the scaling of the first cropping picture; scaling the first cropping picture according to the scaling; obtaining a cropping region of the cropping frame in a target cropping picture; and then according to a left offset and an upper offset of the cropping region, determining the position of the cropping region in the target cropping picture, and hiding an image outside the cropping region. The function of picture cropping is achieved without reading the content of all pixels of the whole picture into a memory and without outputting a new picture again, thereby increasing the picture cropping efficiency.

Description

一种图片裁剪方法、装置、计算机设备及存储介质Picture cutting method, device, computer equipment and storage medium

本申请要求于2020年4月29日提交中国专利局、申请号为202010357558.0,发明名称为“一种图片裁剪方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on April 29, 2020, the application number is 202010357558.0, and the invention title is "A picture cutting method, device, computer equipment and storage medium". The entire content of the application is approved The reference is incorporated in this application.

技术领域Technical field

本申请涉及人工智能领域,涉及图像处理技术领域,尤其涉及一种图片裁剪方法、装置、计算机设备及存储介质。This application relates to the field of artificial intelligence, to the field of image processing technology, and in particular to a picture cropping method, device, computer equipment, and storage medium.

 To

背景技术Background technique

随着图像处理技术的快速发展,图像处理软件开发者提供的图像处理软件的种类越来越多、功能越来越丰富。目前主流的图像处理软件均具有图像裁剪功能。图片裁剪功能是现今许多涉及图像处理软件或者图片类网站必备的主要功能之一,它允许用户对上传的图片做裁剪处理,从而得到一个裁剪后的新图。With the rapid development of image processing technology, image processing software developers provide more and more types of image processing software and more and more functions. The current mainstream image processing software all have the image cropping function. The picture cropping function is one of the main functions necessary for many image processing software or picture websites today. It allows users to crop the uploaded picture to obtain a new cropped picture.

目前图片裁剪的方法是导入需要裁剪的原始图片后,在原始图片上进行裁剪后得到重新输出一张新的裁剪后的图片。目前世面上几乎所有的图片裁剪功能都是利用html5新特色canvas实现的。在canvas画布出来以前,web端处理图片通过设定显示宽高大小的图片或当作背景图使用,其处理图片的能力非常局限,html5出来同时带来canvas、audio、video等新标签(html标签有很多,如div、p、h1、h2等等)。其中canvas就是用于绘制图像的容器它可以把图片内容读到其中,并可以通过操作图片中的每个像素点来达到操作图片宽高或清晰度等的需要,最终输出一个新的图像;每张图片都有固定的像素值,如尺寸为2000 * 2000的像素,该张图片即由400万个像素点组成,同时,每个像素点代表一个颜色,又由rgb三个颜色混合而成,一个像素点理论上可以表示25 * 25  * 25种颜色,该张图的实际存储的数据量大小可能是4000000字节,约等于3.8兆大小(4000000 / 1024 / 1024),输出新图的过程是把整个图的所有像素点内容及控制参数输入,通过对每个像素点的运算来达到使模糊或合成新图的操作,且需要应用类似PS软件等图片处理软件对图片进行处理,才可以精确到每个像素。由此便可以实现图片的裁剪、合成等功能。The current method of image cropping is to import the original image that needs to be cropped, and then crop the original image to obtain a new cropped image. At present, almost all picture cropping functions in the world are realized by the new feature canvas of html5. Before the canvas canvas came out, the web-side processed pictures by setting the display width and height of the picture or using it as a background picture. Its ability to process pictures was very limited. When html5 came out, it also brought new labels such as canvas, audio, video (html tags). There are many, such as div, p, h1, h2, etc.). Among them, canvas is the container used to draw the image. It can read the content of the image, and can manipulate each pixel in the image to achieve the needs of operating the width, height or definition of the image, and finally output a new image; A picture has a fixed pixel value, such as a pixel with a size of 2000 * 2000, the picture is composed of 4 million pixels, and at the same time, each pixel represents a color, which is composed of three colors of rgb. A pixel can theoretically represent 25 * 25 * 25 colors. The actual data size of the image may be 4000000 bytes, which is approximately equal to 3.8 megabytes (4000000 / 1024 / 1024). The process of outputting a new image is Input the content and control parameters of all pixels of the entire image, and use the calculation of each pixel to achieve the operation of blurring or synthesizing a new image, and image processing software such as PS software is required to process the image to be accurate To every pixel. In this way, functions such as cropping and compositing of pictures can be realized.

 To

技术问题technical problem

发明人意识到,需要canvas读取图片的内容,并在内存中操作图片,最终还要重新输出一张新的图,其运算过程会消耗大量的计算资源。The inventor realized that the need for canvas to read the content of the picture, manipulate the picture in the memory, and finally re-output a new picture, the calculation process will consume a lot of computing resources.

 To

技术解决方案Technical solutions

本申请提供一种图片裁剪方法、装置、计算机设备及存储介质,以解决图片裁剪过程中需要重新输出一张新的图,运算过程会消耗大量的计算资源的问题。This application provides a picture cropping method, device, computer equipment, and storage medium to solve the problem that a new picture needs to be re-output during the picture cropping process, and a large amount of computing resources will be consumed in the calculation process.

一种图片裁剪方法,包括:接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收用户设置的裁剪框的尺寸;对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示所述裁剪后的图片。A picture cropping method includes: receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; The first cropped picture is subjected to equal ratio processing to obtain the second cropped picture, which is displayed in the preset pop-up layer; a cropping console for setting cropping parameters is created in the preset pop-up layer, wherein the cropping The size of the console is the size of the second cropped picture; receives the size of the crop frame set by the user; calculates the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; according to The ratio between the width and the height of the cropping frame, crop the box corresponding to the first cropped picture to obtain the cropped box corresponding to the ratio; calculate the actual size of the cropping frame in the first cropped picture The magnification between the size of the cropped box and the size of the cropped box, and the magnification is used as the zoom ratio of the first cropped picture; correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; The zoom ratio calculates the actual pixels of the crop frame in the first cropped picture to obtain the crop area, where the crop area includes the left offset of the crop area and the upper offset of the crop area; according to the size of the crop area The left offset and the upper offset determine the position of the cropped area in the target cropped picture, hide images outside the cropped area, and obtain a cropped picture; and display the cropped picture.

一种图片裁剪装置,包括:接收图片裁剪指令模块,接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;等比处理模块,根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;创建裁剪操作台模块,在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收裁剪框尺寸模块,接收用户设置的裁剪框的尺寸;第一计算模块,对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;裁剪模块,根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;第二计算模块,计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;缩放模块,按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;第三计算模块,按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;确定位置模块,根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示模块,展示所述裁剪后的图片。A picture cropping device, comprising: a picture cropping instruction module that receives a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; etc. The ratio processing module, which performs equal ratio processing on the first cropped picture according to the preset pop-up layer, obtains the second cropped picture, and displays it in the preset pop-up layer; creates a cropping console module, and pops it up in the preset A cropping console for setting cropping parameters is created in the layer, wherein the size of the cropping console is the size of the second cropped picture; a module for receiving cropping frame size, receiving the size of the cropping frame set by the user; a first calculation module Calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; the cropping module, according to the ratio between the width and the height of the cropping frame, performs the first cropping The box corresponding to the picture is cropped to obtain the cropped box corresponding to the ratio; the second calculation module calculates the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and The magnification is used as the zoom ratio of the first cropped picture; the zoom module correspondingly zooms the first cropped picture according to the zoom ratio to obtain the target cropped picture; and the third calculation module performs the cropping according to the zoom ratio The frame is calculated on the actual pixels of the first cropped picture to obtain the cropped area, where the cropped area includes the left offset of the cropped area and the offset on the cropped area; the position determining module, according to the left offset of the cropped area The shift amount and the upper offset determine the position of the cropped area in the target cropped picture, hide images outside the cropped area to obtain the cropped picture; a display module displays the cropped picture.

一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收用户设置的裁剪框的尺寸;对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示所述裁剪后的图片。A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and capable of running on the processor. When the processor executes the computer-readable instructions, the following steps are implemented: receiving a user The inputted picture cropping instruction, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer, Obtain the second cropped picture and display it in the preset pop-up layer; create a cropping operation table for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping operation table is the second cropping The size of the picture; receiving the size of the cropping frame set by the user; calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; according to the width and height of the cropping frame The ratio of the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the cropping box is calculated between the actual size of the first cropped picture and the size of the cropped box The magnification, and the magnification is used as the zoom ratio of the first cropped picture; correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; according to the zoom ratio, the crop frame is set in the The actual pixels of the first cropped picture are calculated to obtain the cropped area, where the cropped area includes the left offset of the cropped area and the upper offset of the cropped area; according to the left offset and the upper offset of the cropped area, Determine the position of the cropped area in the target cropped picture, hide images outside the cropped area, and obtain a cropped picture; and display the cropped picture.

一个或多个存储有计算机可读指令的可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收用户设置的裁剪框的尺寸;对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示所述裁剪后的图片。One or more readable storage media storing computer readable instructions, when the computer readable instructions are executed by one or more processors, the one or more processors perform the following steps: receiving a picture input by a user A cropping instruction, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer to obtain the second Crop the picture and display it in the preset pop-up layer; create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture Receive the size of the crop frame set by the user; calculate the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; according to the ratio between the width and height of the crop frame, Crop the box corresponding to the first cropped picture to obtain a cropped box corresponding to the ratio; calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and Use the magnification as the zoom ratio of the first cropped picture; correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; adjust the cropping frame in the first cropped picture according to the zoom ratio The actual pixels of the picture are calculated to obtain the cropped area, where the cropped area includes the left offset of the cropped area and the upper offset of the cropped area; the left offset and the upper offset of the cropped area are used to determine the The position of the cropped area in the target cropped picture, hide the image outside the cropped area, and obtain the cropped picture; and display the cropped picture.

 To

有益效果Beneficial effect

上述图片裁剪方法、装置、计算机设备及存储介质所实现的其中一个方案中,本方案在不需要重新输出一张新的图的情况下得到裁剪后的图片,当用户停止在裁剪操作台中对裁剪框的拉伸定位后,接收用户在裁剪操作台中设置的裁剪框的尺寸,得到裁剪区域的左偏移量和上偏移量的数值的参数,从而确定所述裁剪区域在目标裁剪图片中的位置,再根据上述参数得到控制原图的部分显示,不需要将整个图片的所有像素内容读入内存,因此是节省了大量的计算资源的,故而本方案能够在不需要重新输出一张新的图的情况下,实现图片的裁剪功能,从而提高图片裁剪的效率,减少计算资源的损耗。In one of the solutions implemented by the above-mentioned picture cropping method, device, computer equipment and storage medium, this solution obtains the cropped picture without re-outputting a new picture. When the user stops cropping in the cropping console After the frame is stretched and positioned, the size of the crop frame set by the user in the cropping console is received, and the parameters of the left offset and the upper offset of the cropped area are obtained, so as to determine the size of the cropped area in the target cropped picture. The position, and then according to the above parameters to control the partial display of the original image, there is no need to read all the pixel content of the entire image into the memory, so it saves a lot of computing resources, so this solution can output a new In the case of a picture, the picture cropping function is realized, thereby improving the efficiency of picture cropping and reducing the loss of computing resources.

本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。The details of one or more embodiments of the present application are presented in the following drawings and description, and other features and advantages of the present application will become apparent from the description, drawings and claims.

 To

附图说明Description of the drawings

为了更清楚地说明本申请的技术方案,下面将对本申请的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions of the present application more clearly, the following will briefly introduce the accompanying drawings used in the description of the present application. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. Ordinary technicians can obtain other drawings based on these drawings without creative labor.

图1是本申请一实施例中图片裁剪方法的一流程图;Fig. 1 is a flowchart of a picture cropping method in an embodiment of the present application;

图2是本申请一实施例中图片裁剪方法的另一流程图;FIG. 2 is another flowchart of a picture cropping method in an embodiment of the present application;

图3是本申请一实施例中图片裁剪装置的一原理框图;Fig. 3 is a schematic block diagram of a picture cropping device in an embodiment of the present application;

图4是本申请一实施例中计算机设备的一示意图。Fig. 4 is a schematic diagram of a computer device in an embodiment of the present application.

 To

具体实施方式Detailed ways

下面将结合本申请中的附图,对本申请中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, rather than all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of this application.

在一实施例中,如图1所示,提供一种图片裁剪方法,包括如下步骤:In one embodiment, as shown in FIG. 1, a method for cropping a picture is provided, which includes the following steps:

S10S10 :接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸。: Receive a picture cropping instruction input by the user, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture.

第一裁剪图片为需要进行裁剪操作的完整的原始图片,例如,用户发出对一张尺寸为2000 * 2000像素的第一裁剪图片进行裁剪,裁剪程序接收到用户输入的图片裁剪指令,其中,所述第一裁剪图片对应的盒子的尺寸为第一裁剪图片原本在展示区域的盒子的实际像素值;例如,图片裁剪指令中带有尺寸为2000 * 2000像素的第一裁剪图片和第一裁剪图片对应的盒子的尺寸为100 * 100像素。The first cropped picture is a complete original picture that needs to be cropped. For example, the user sends out a first cropped picture with a size of 2000 * 2000 pixels to crop, and the cropping program receives the picture cropping instruction input by the user. The size of the box corresponding to the first cropped picture is the actual pixel value of the box in the display area of the first cropped picture; for example, the first cropped picture and the first cropped picture with a size of 2000 * 2000 pixels are included in the picture cropping instruction The size of the corresponding box is 100* 100 pixels.

S20S20 :根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内。: Perform proportional processing on the first cropped picture according to the preset pop-up layer to obtain a second cropped picture, and display it in the preset pop-up layer.

一般来说,当我们打算对一张图片进行裁剪时,往往有一个“裁剪”按钮,点击“裁剪”按钮,便会在个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备上会弹出一个预设弹出层,预设弹出层是预先设定的,例如,预设弹出层的尺寸为800 * 800像素。Generally speaking, when we plan to crop a picture, there is often a "crop" button. Click the "crop" button, and it will be displayed on personal computers, laptops, smartphones, tablets and portable wearable devices. A preset pop-up layer is popped up. The preset pop-up layer is preset. For example, the size of the preset pop-up layer is 800*800 pixels.

第二裁剪图片是指展示在预设弹出层内的第一裁剪图片经过等比处理的图片。要将尺寸为2000 * 2000像素的第一裁剪图片进行等比缩放展示在尺寸为800 * 800像素的预设弹出层内,需要将尺寸为2000 * 2000像素的第一裁剪图片进行等比缩倍2000/800=2.5倍,即尺寸为2000 * 2000像素的第一裁剪图片进行2.5倍的等比缩小,得到尺寸为800 * 800像素的第二裁剪图片。The second cropped picture refers to a picture in which the first cropped picture displayed in the preset pop-up layer undergoes equal ratio processing. To scale the first cropped image with a size of 2000 * 2000 pixels and display it in the preset pop-up layer with a size of 800 * 800 pixels, you need to scale the first cropped image with a size of 2000 * 2000 pixels. 2000/800=2.5 times, that is, the first cropped picture with a size of 2000 * 2000 pixels is reduced by 2.5 times to obtain a second cropped picture with a size of 800 * 800 pixels.

S30S30 :在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸。: Create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture.

裁剪操作台是指当第一裁剪图片等比放大或缩小绘制在预设弹出层后时,这张第一裁剪图片在预设弹出层中实际占用位置和大小的区域,后面用户的对裁剪框的操作均不能超出这个裁剪操作台的范围。The cropping console refers to the area where the first cropped picture actually occupies the position and size of the preset pop-up layer when the first cropped picture is scaled up or down and drawn on the preset pop-up layer, and the user’s subsequent crop frame None of the operations can exceed the scope of this cutting console.

例如,在尺寸为800 * 800像素的预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,所述第二裁剪图片的尺寸为800 * 800像素,也即裁剪操作台的像素为第二裁剪图片的像素,也即裁剪操作台的尺寸也为800 * 800像素。For example, create a cropping console for setting cropping parameters in a preset pop-up layer with a size of 800*800 pixels, where the size of the second cropped picture is 800*800 pixels, that is, the pixels of the cropping console The pixels of the second cropped picture, that is, the size of the cropping console is also 800 * 800 pixels.

S40S40 :接收用户设置的裁剪框的尺寸。: Receive the size of the cropping frame set by the user.

所述裁剪框为矩形裁剪框,所述第二裁剪图片为矩形图片,以裁剪操作台上显示的第二裁剪图片的左上角顶点作为原点建立直角坐标系,裁剪框的像素包括以裁剪框左上角顶点横坐标的像素为裁剪框的最左边距离裁剪操作台的最左边的左偏移量、以裁剪框左上角顶点纵坐标为裁剪框的最上边距离裁剪操作台的最上边的上偏移量、裁剪框的宽和裁剪框的高。例如,裁剪框的参数包括裁剪框的左偏移量left为400像素,上偏移量为top为500像素,宽width为400像素,高为height为300像素。The cropping frame is a rectangular cropping frame, and the second cropping picture is a rectangular picture. A rectangular coordinate system is established with the top-left vertex of the second cropping picture displayed on the cropping console as the origin. The pixels of the cropping frame include the top left of the cropping frame. The pixel of the abscissa of the corner vertex is the left offset of the leftmost corner of the cropping frame from the leftmost left of the cutting console, and the ordinate of the top left corner of the cropping frame is the topmost distance of the cropping frame. The upper offset of the top edge of the cropping console The amount, the width of the cropping frame and the height of the cropping frame. For example, the parameters of the cropping frame include that the left offset of the cropping frame is 400 pixels, the top offset is 500 pixels, the width is 400 pixels, and the height is 300 pixels.

S50S50 :对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸。: Calculate the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture.

例如,根据裁剪操作台的尺寸也为800 * 800像素,对裁剪框的左偏移量left为400像素,上偏移量top为500像素,宽width为400像素,高height为300像素的参数进行计算,根据裁剪框的左偏移量left与所述裁剪操作台的宽的之间的比率:|400/800|,对所述裁剪框的左偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际左偏移量_left=2000*|(400/800)|=1000像素;根据裁剪框的上偏移量top与所述裁剪操作台的高的之间的比率:|500/800|,对所述裁剪框的上偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际上偏移量_top=2000*|(500/800)|=1250像素;根据裁剪框的宽width与所述裁剪操作台的宽的之间的比率:|400/800|,对所述裁剪框的宽进行计算,得到所述裁剪框在所述第一裁剪图片的实际宽_width=2000*|(400/800)|=1000像素;根据裁剪框的高top与所述裁剪操作台的高的之间的比率:|300/800|,对所述裁剪框的高进行计算,得到所述裁剪框在所述第一裁剪图片的实际高_height=2000*|(300/800)|=750像素。For example, according to the size of the cropping console is 800 * 800 pixels, the left offset of the crop frame is 400 pixels, the top offset is 500 pixels, the width is 400 pixels, and the height is 300 pixels. Calculate, according to the ratio between the left offset of the crop frame and the width of the cropping console: |400/800|, calculate the left offset of the crop frame to obtain the crop frame The actual left offset of the first cropped picture _left=2000*|(400/800)|=1000 pixels; according to the upper offset top of the cropping frame and the height of the cropping console Ratio: |500/800|, calculate the upper offset of the cropping frame to obtain the actual offset of the cropping frame in the first cropped picture_top=2000*|(500/800) |=1250 pixels; According to the ratio between the width of the cropping frame and the width of the cropping console: |400/800|, the width of the cropping frame is calculated to obtain that the cropping frame is in the first The actual width of a cropped picture_width=2000*|(400/800)|=1000 pixels; according to the ratio between the height of the cropping frame and the height of the cropping console: |300/800|, for all The height of the cropping frame is calculated to obtain the actual height of the cropping frame in the first cropped picture_height=2000*|(300/800)|=750 pixels.

S60S60 :根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子。: According to the ratio between the width and the height of the cropping frame, crop the box corresponding to the first cropped picture to obtain the cropped box corresponding to the ratio.

例如,裁剪框的宽与高之间的比率为|400:300|,即|4:3|,且第一裁剪图片对应的盒子的尺寸为100 * 100像素,则按照裁剪框的宽与高之间4:3的比率,得到与比率对应裁剪后的盒子的尺寸为100 * 75像素。For example, the ratio between the width and height of the cropping frame is |400:300|, that is |4:3|, and the size of the box corresponding to the first cropped picture is 100 * 100 pixels, then according to the width and height of the cropping frame With the ratio of 4:3, the size of the box after cropping corresponding to the ratio is 100 * 75 pixels.

S70S70 :计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例。: Calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and use the magnification as the zoom ratio of the first cropped picture.

例如,其中,裁剪框在第一裁剪图片的实际宽_width=1000像素,实际高_height=750像素,裁剪后的盒子的尺寸为100 * 75像素,因此裁剪框在所述第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率为1000/100=10倍,也即得到第一裁剪图片的缩放比例为10倍。For example, where the actual width of the cropping frame in the first cropped picture is _width=1000 pixels, the actual height _height=750 pixels, and the size of the cropped box is 100*75 pixels, so the cropping frame is in the first cropped picture. The magnification ratio between the actual size of and the size of the cropped box is 1000/100=10 times, that is, the zoom ratio of the first cropped picture is 10 times.

S80S80 :按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片。: Correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture.

例如,按照10倍的缩放比例将尺寸为2000 * 2000像素的第一裁剪图片进行对应缩放,得到按照所述缩放比例后的目标裁剪图片的尺寸为200* 200像素。For example, the first cropped picture with a size of 2000*2000 pixels is correspondingly scaled according to a zoom ratio of 10 times, and the size of the target cropped picture obtained according to the zoom ratio is 200*200 pixels.

S90S90 :按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量。: Calculate the actual pixels of the cropping frame in the first cropped picture according to the zoom ratio to obtain a cropped area, where the cropped area includes a left offset of the cropped area and an upper offset of the cropped area.

例如,按照10倍的缩小比例对所述裁剪框在所述第一裁剪图片的实际上偏移量_left=-1000像素,实际上偏移量_top=-1250像素进行计算,得到裁剪区域的左偏移量为-1000/10= -100像素,上偏移量-1250/10= -125像素。For example, the actual offset _left=-1000 pixels of the cropping frame in the first cropped picture and the actual offset _top=-1250 pixels of the cropping frame in the first cropped picture are calculated according to a reduction ratio of 10 times to obtain the cropped area The left offset is -1000/10= -100 pixels, and the upper offset is -1250/10= -125 pixels.

S100S100 :根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片。: Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area, and obtain a cropped picture.

例如,其中,裁剪区域的左偏移量为-100像素,上偏移量为-125像素,目标裁剪图片的尺寸为200* 200像素,裁剪后的盒子的尺寸为100 * 75像素,利用div盒子的overflow:hidden样式属性,即隐藏所述裁剪区域以外的图像,得到展示的图片为裁剪后的图片,也即第一裁剪图片<img width=‘100px’; height=‘100px’;src=‘2000*2000px’>经过裁剪后,变为裁剪后的图片:For example, where the left offset of the crop area is -100 pixels, the upper offset is -125 pixels, the size of the target cropped image is 200*200 pixels, and the size of the cropped box is 100*75 pixels, using div The overflow: hidden style attribute of the box, that is, hide the image outside the cropped area, and the displayed image is the cropped image, that is, the first cropped image <img width='100px'; height='100px'; src= '2000*2000px'>After being cropped, it becomes a cropped picture:

<div style=‘width:100px;height:75px;overflow:hidden’><div style=‘width:100px;height:75px;overflow:hidden’>

<img style=‘width:200px;height:200px;left:-100px;top:-125px’><img style=‘width:200px;height:200px;left:-100px;top:-125px’>

</div></div> .

S110S110 :展示裁剪后的图片。: Show the cropped picture.

将裁剪后的图片发送至客户端,以使所述客户端显示所述裁剪后的图片,裁剪后的图片可以在个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备上展示。The cropped picture is sent to the client, so that the client displays the cropped picture, and the cropped picture can be displayed on a personal computer, a notebook computer, a smart phone, a tablet computer, and a portable wearable device.

在本实施例中,以快捷生成HTML5页面工具为例,用户需要制作HTML5页面时,需要添加大量的图片和文本,其中在使用图片时,就会产生对图片进行裁剪的需求,以达到编辑图文的目的;本方案是针对图片裁剪提出的一种技术实现,该图片裁剪过程中避免了canvas读图片内容,并在内存中操作图片,最终还要重新输出一张新的图的问题,实现了在不生成新图的情况下就可以对图片进行图片裁剪的功能,从而提高图片裁剪并输出的效率,减少计算资源的损耗。In this embodiment, taking the tool for quickly generating HTML5 pages as an example, when users need to create HTML5 pages, they need to add a large number of pictures and texts. When using pictures, there will be a need to crop the pictures to achieve editing. The purpose of the article; this solution is a technical implementation proposed for image cropping. The image cropping process avoids the problem of canvas reading the image content, operating the image in the memory, and finally outputting a new image. In order to improve the efficiency of image cropping and output, it can reduce the loss of computing resources.

在图1对应的实施例中,本方案在不需要重新输出一张新的图的情况下得到裁剪后的图片;当用户停止在裁剪操作台中对裁剪框的拉伸定位后,接收用户在裁剪操作台中设置的裁剪框的尺寸,得到裁剪区域的左偏移量和上偏移量的数值的参数,从而确定所述裁剪区域在目标裁剪图片中的位置,再根据上述参数得到控制原图的部分显示,不需要将整个图片的所有像素内容读入内存,因此是节省了大量的计算资源的,故而本方案能够在不需要重新输出一张新的图的情况下,实现图片的裁剪功能,从而提高图片裁剪的效率,减少计算资源的损耗。In the embodiment corresponding to Figure 1, this solution does not need to re-output a new image to obtain the cropped picture; when the user stops stretching and positioning the crop frame in the cropping console, the receiving user is cropping The size of the cropping frame set in the console is used to obtain the left offset and upper offset parameters of the cropped area, so as to determine the position of the cropped area in the target cropped image, and then obtain the control of the original image according to the above parameters Partial display does not need to read all the pixel content of the entire picture into the memory, so it saves a lot of computing resources, so this solution can realize the cropping function of the picture without re-outputting a new picture. Thereby improving the efficiency of picture cropping and reducing the loss of computing resources.

在一实施例中,在步骤S100之后S110之前,也即在所述得到裁剪后的图片之后,所述展示裁剪后的图片之前,具体还包括如下步骤:In one embodiment, after step S100 and before S110, that is, after the cropped picture is obtained, and before the cropped picture is displayed, the following steps are specifically included:

S120S120 :接收用户输入的图片重新裁剪指令,其中,图片重新裁剪指令包括所述用于设置裁剪参数的裁剪操作台。: Receive a picture re-cropping instruction input by the user, where the picture re-cropping instruction includes the cropping console for setting cropping parameters.

裁剪程序接收到重新裁剪指令后,重新裁剪指令包括用于设置裁剪参数的裁剪操作台,能够直接对同一张图片进行重新裁剪,不需要重新计算裁剪操作台的尺寸。After the cropping program receives the re-cropping instruction, the re-cropping instruction includes a cropping console for setting cropping parameters, which can directly re-crop the same picture without recalculating the size of the cropping console.

S130S130 :根据所述裁剪操作台,重新执行设置裁剪框的尺寸的步骤。: According to the cutting operation table, re-execute the step of setting the size of the cutting frame.

根据裁剪操作台的尺寸,重新执行设置裁剪框的尺寸的步骤及其以后的步骤,本步骤已在上文中作详细介绍,故在此不做赘述。According to the size of the cutting operation table, re-execute the steps of setting the size of the crop frame and the subsequent steps. This step has been described in detail above, so I will not repeat it here.

在本实施例中,接收用户输入的图片重新裁剪指令,其中,图片重新裁剪指令包括所述用于设置裁剪参数的裁剪操作台,同一张图片进行重新裁剪能够直接得到用于设置裁剪参数的裁剪操作台,不需要重新计算,提高裁剪效率。In this embodiment, the picture re-cropping instruction input by the user is received, where the picture re-cropping instruction includes the cropping console for setting cropping parameters. Re-cropping the same picture can directly obtain cropping for setting cropping parameters. The operating table does not need to be recalculated, which improves cutting efficiency.

在一实施例中,在步骤S20中,也即所述根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,具体包括如下步骤:In one embodiment, in step S20, that is, performing equal ratio processing on the first cropped picture according to the preset pop-up layer to obtain the second cropped picture, specifically includes the following steps:

若所述第一裁剪图片的宽比所述预设弹出层的宽小,且所述第一裁剪图片的高比所述预设弹出层的高小,则将所述第一裁剪图片作为第二裁剪图片。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 smaller than the height of the preset pop-up layer, then the first cropped picture is taken as the first cropped picture. 2. Crop the picture.

例如,所述第一裁剪图片的尺寸为100 * 100像素,预设弹出层的尺寸为800*800像素,此时所述第一裁剪图片的宽100像素比所述预设弹出层的宽800像素小,且第一裁剪图片的高100像素比所述预设弹出层的高800像素小,则将所述第一裁剪图片不需要拉伸或缩小,直接作为第二裁剪图片。For example, the size of the first cropped picture is 100*100 pixels, and the size of the preset pop-up layer is 800*800 pixels. At this time, the width of the first cropped picture is 100 pixels wider than that of the preset pop-up layer by 800 pixels. If the pixels are small, 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, the first cropped picture does not need to be stretched or reduced, and it is directly used as the second cropped picture.

若所述第一裁剪图片的宽与所述预设弹出层的宽相等,且所述第一裁剪图片的高与所述预设弹出层的高相等,则将所述第一裁剪图片作为第二裁剪图片。If the width of the first cropped picture is equal to the width of the preset pop-up layer, and the height of the first cropped picture is equal to the height of the preset pop-up layer, then the first cropped picture is taken as the first cropped picture. 2. Crop the picture.

例如,所述第一裁剪图片的尺寸为100 * 100像素,预设弹出层的尺寸为100*100像素,此时所述第一裁剪图片的宽100像素与所述预设弹出层的宽100像素相等,且第一裁剪图片的高100像素于所述预设弹出层的高100像素相等,则将所述第一裁剪图片不需要拉伸或缩小,直接作为第二裁剪图片。For example, the size of the first cropped picture is 100*100 pixels, and the size of the preset pop-up layer is 100*100 pixels. At this time, the width of the first cropped picture is 100 pixels and the width of the preset pop-up layer is 100 pixels. If the pixels are equal, and the height of 100 pixels of the first cropped picture is equal to the height of 100 pixels of the preset pop-up layer, the first cropped picture does not need to be stretched or reduced, and it is directly used as the second cropped picture.

在本实施例中分别将第一裁剪图片的宽、高与预设弹出层的宽、高进行对比,根据两者的比值来确定第一裁剪图片的宽、高的等比缩放的值,从而得到第二裁剪图片,能够使得第一裁剪图片没有拉伸变形地展示在裁剪操作台中。In this embodiment, the width and height of the first cropped image are compared with the width and height of the preset pop-up layer, and the ratio of the width and height of the first cropped image is determined according to the ratio of the two. Obtaining the second cropped picture can enable the first cropped picture to be displayed in the cropping console without being stretched or deformed.

在一实施例中,若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高小,则计算第一裁剪图片的宽与所述预设弹出层的宽的第一比值。按照第一比值对第一裁剪图片进行缩小,得到第二裁剪图片。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, then the first crop is calculated The first ratio of the width of the picture to the width of the preset pop-up layer. The first cropped picture is reduced according to the first ratio to obtain the second cropped picture.

假如,第一裁剪图片的尺寸为2000 * 1000像素,预设弹出层的尺寸为1366 * 1560,此时,所述第一裁剪图片的宽2000像素比所述预设弹出层的宽1566像素大,且第一裁剪图片的高1000像素比所述预设弹出层的高1560像素小,则计算第一裁剪图片的宽与所述预设弹出层的宽的第一比值: 2000 / 1366 = 1.464。Suppose that the size of the first cropped picture is 2000 * 1000 pixels, and the size of the preset pop-up layer is 1366 * 1560. At this time, the width of the first cropped picture is 2000 pixels larger than the width of the preset pop-up layer of 1566 pixels. , And the height of the first cropped picture of 1000 pixels is smaller than the height of 1560 pixels of the preset pop-up layer, then the first ratio of the width of the first cropped picture to the width of the preset pop-up layer is calculated: 2000 / 1366 = 1.464.

也就是说需要把第一裁剪图片的宽和高同时缩小1.464倍,预设弹出层才能完整放得下第一裁剪图片,按照第一比值1.464倍对第一裁剪图片进行缩小,得到第二裁剪图片的宽:2000/1.464=1366像素,第二裁剪图片的高: 1000/1.464=683像素,得到第二裁剪图片的尺寸为1366*683像素。That is to say, the width and height of the first cropped picture need to be reduced by 1.464 times at the same time, so that the preset pop-up layer can fully place the first cropped picture, and the first cropped picture is reduced according to the first ratio of 1.464 times to obtain the second crop. The width of the picture: 2000/1.464=1366 pixels, the height of the second cropped picture: 1000/1.464=683 pixels, and the size of the second cropped picture is 1366*683 pixels.

在本实施例中,将第一裁剪图片的宽、高与所述预设弹出层的宽、高进行对比,根据两者的比值来确定第一裁剪图片的宽、高的等比缩放的值,从而得到第二裁剪图片,按照第一比值对第一裁剪图片进行缩小,使预设弹出层能包裹下这张图片,进一步使得第一裁剪图片没有变形地展示在裁剪操作台中。In this embodiment, the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer, and the ratio of the width and height of the first cropped picture is determined according to the ratio of the two. , So as to obtain the second cropped picture, and reduce the first cropped picture according to the first ratio, so that the preset pop-up layer can wrap the picture, and further enable the first cropped picture to be displayed in the cropping console 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 greater than the height of the preset pop-up layer, then the first crop is calculated The second ratio of the height of the picture to the height of the preset pop-up layer. The first cropped picture is reduced according to the second ratio to obtain the second cropped picture.

假如,第一裁剪图片的尺寸为2000 * 1000像素,预设弹出层的尺寸为2600* 768,此时,所述第一裁剪图片的宽2000像素比所述预设弹出层的宽2600像素小,且第一裁剪图片的高1000像素比所述预设弹出层的高768像素大,则计算第一裁剪图片的宽与所述预设弹出层的高的第二比值: 1000 / 768= 1.302。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 of the first cropped picture is 2000 pixels smaller than the width of the preset pop-up layer of 2600 pixels , And the height of the first cropped picture is 1000 pixels larger than the height of the preset pop-up layer by 768 pixels, then the second ratio of the width of the first cropped picture to the height of the preset pop-up layer is calculated: 1000 / 768 = 1.302.

也就是说需要把第一裁剪图片的宽和高同时缩小1.302倍,预设弹出层才能完整放得下第一裁剪图片,按照第一比值1.302倍对第一裁剪图片进行缩小,得到第二裁剪图片的宽:2000/1.302=1512像素,第二裁剪图片的高: 1000/1.302=768像素,得到第二裁剪图片的尺寸为1512*768像素。That is to say, the width and height of the first cropped image need to be reduced by 1.302 times at the same time, so that the preset pop-up layer can fully place the first cropped image, and the first cropped image is reduced according to the first ratio of 1.302 times to obtain the second crop. The width of the picture: 2000/1.302=1512 pixels, the height of the second cropped picture: 1000/1.302=768 pixels, the size of the second cropped picture is 1512*768 pixels.

在本实施例中,将第一裁剪图片的宽、高分别与预设弹出层的宽、高进行对比,根据两者的比值来确定第一裁剪图片的等比缩放的值,从而得到第二裁剪图片,预设弹出层能包裹下这张图片,进一步使得第一裁剪图片没有变形地展示在裁剪操作台中。In this embodiment, the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer respectively, and the proportional zoom value of the first cropped picture is determined according to the ratio of the two, so as to obtain the second The picture is cropped, and the preset pop-up layer can wrap the picture, further making the first cropped picture displayed in the cropping console without distortion.

在一实施例中,若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高大,则计算第一裁剪图片的宽与所述预设弹出层的宽的第三比值。计算所述第一裁剪图片的高与所述预设弹出层的高的第四比值。将所述第三比值与所述第四比值的大小进行对比,取数值大的为缩放比值。按照所述缩放比值对第一裁剪图片进行缩小,得到第二裁剪图片。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 greater than the height of the preset pop-up layer, then the first cropped picture is calculated The third ratio of the width of and the width of the preset pop-up layer. Calculate a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer. The third ratio is compared with the fourth ratio, and the larger value is the zoom ratio. The first cropped picture is reduced according to the zoom ratio to obtain the second cropped picture.

假如,第一裁剪图片的尺寸为2000 * 1000像素,预设弹出层的尺寸为1366 * 768像素,此时所述第一裁剪图片的宽2000像素比所述预设弹出层的宽1366 像素大,且所述第一裁剪图片的高1000像素比所述预设弹出层的高768像素大,则计算第一裁剪图片的宽与所述预设弹出层的宽的第三比值 2000 / 1366 = 1.464。Suppose that the size of the first cropped picture is 2000 * 1000 pixels, and the size of the preset pop-up layer is 1366 * 768 pixels. At this time, the width of the first cropped picture is 2000 pixels larger than the width of the preset pop-up layer of 1366 pixels. , And the height of the first cropped picture is 1000 pixels larger than the height of the preset pop-up layer is 768 pixels, then the third ratio of the width of the first cropped picture to the width of the preset pop-up layer is calculated as 2000/ 1366 = 1.464.

计算所述第一裁剪图片的高与所述预设弹出层的高的第四比值:1000 / 768 = 1.302。Calculate a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer: 1000/768=1.302.

也就是说需要把第一裁剪图片的宽缩小1.464倍,预设弹出层才能完整放得下该图片,同时在高度维度上,需要缩小1.302倍才能完整放的下第一裁剪图片,因此取数值大的为缩放比值,即将图像宽和高同时缩小1.464倍。That is to say, the width of the first cropped picture needs to be reduced by 1.464 times, so that the preset pop-up layer can fully place the picture. At the same time, in the height dimension, the first cropped picture needs to be reduced by 1.302 times to fully place the first cropped picture, so take the value The larger is the zoom ratio, that is, the image width and height are reduced by 1.464 times at the same time.

按照所述缩放比值1.464倍对第一裁剪图片进行缩小,得到第二裁剪图片的宽:2000 / 1.464 = 1366像素,第二裁剪图片的高:1000 / 1.464 = 683像素,也即得到第二裁剪图片的尺寸为1366*683像素。The first cropped image is reduced according to the zoom ratio of 1.464 times, and the width of the second cropped image is obtained: 2000 / 1.464 = 1366 pixels, and the height of the second cropped image: 1000 / 1.464 = 683 pixels, that is, the size of the second cropped picture is 1366*683 pixels.

在本实施例中,将第一裁剪图片的宽、高分别与预设弹出层的宽、高进行对比,根据两者的比值来确定第一裁剪图片的等比缩放的值,从而得到第二裁剪图片,使预设弹出层能包裹下这张图片,进一步使得第一裁剪图片没有变形地展示在裁剪操作台中。In this embodiment, the width and height of the first cropped picture are compared with the width and height of the preset pop-up layer respectively, and the proportional zoom value of the first cropped picture is determined according to the ratio of the two, so as to obtain the second The picture is cropped so that the preset pop-up layer can wrap the picture, so that the first cropped picture is displayed in the cropping console without deformation.

在一实施例中,如图2所示,所述裁剪框参数包括以裁剪框左上角顶点横坐标的像素为裁剪框的最左边距离裁剪操作台的最左边的左偏移量、以裁剪框左上角顶点纵坐标为裁剪框的最上边距离裁剪操作台的最上边的上偏移量、裁剪框的宽和裁剪框的高,在步骤S50中,也即所述对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸,具体包括如下步骤:In one embodiment, as shown in FIG. 2, the cropping frame parameters include taking the pixel of the abscissa of the vertex of the upper left corner of the cropping frame as the leftmost offset of the cropping frame from the leftmost left of the cropping console, and taking the cropping frame The ordinate of the upper left corner vertex is the upper offset of the uppermost edge of the cropping frame from the uppermost edge of the cutting console, the width of the cropping frame, and the height of the cropping frame. In step S50, it is the size of the cropping frame. Performing calculations to obtain the actual size of the cropping frame in the first cropped picture specifically includes the following steps:

S51S51 :采用如下公式对所述裁剪框的宽进行计算,得到所述裁剪框在所述第一裁剪图片的实际宽:: Calculate the width of the cropping frame using the following formula to obtain the actual width of the cropping frame in the first cropped picture:

实际宽Actual width == 第一裁剪图片的宽*裁剪框的宽/裁剪操作台的宽。The width of the first cropped picture * the width of the cropping frame/the width of the cropping console.

例如,裁剪框的宽width为400像素,第一裁剪图片的尺寸为2000*1000像素,裁剪操作台的尺寸为800*800像素,则所述第一裁剪图片的实际宽_width=2000*|(400/800)|=1000像素。For example, if the width of the cropping frame is 400 pixels, the size of the first cropped picture is 2000*1000 pixels, and the size of the cropping console is 800*800 pixels, then the actual width of the first cropped picture_width=2000*| (400/800)|=1000 pixels.

S52S52 :采用如下公式对所述裁剪框的高进行计算,得到所述裁剪框在所述第一裁剪图片的实际高:: Calculate the height of the cropping frame using the following formula to obtain the actual height of the cropping frame in the first cropped picture:

实际高=第一裁剪图片的高*裁剪框的高/裁剪操作台的高。The actual height = the height of the first cropped picture * the height of the cropping frame / the height of the cropping console.

例如,裁剪框的高height为300像素,则所述裁剪框在所述第一裁剪图片的实际高_height=2000*|(300/800)|=750像素。For example, if the height of the cropping frame is 300 pixels, then the actual height of the cropping frame in the first cropped picture_height=2000*|(300/800)|=750 pixels.

S53S53 :采用如下公式对所述裁剪框的左偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际左偏移量:: Use the following formula to calculate the left offset of the cropping frame to obtain the actual left offset of the cropping frame in the first cropped picture:

实际左Actual left 偏移量=第一裁剪图片的宽*裁剪框的左偏移量/裁剪操作台的宽。Offset = the width of the first cropped picture * the left offset of the cropping frame / the width of the cropping console.

例如,裁剪框的左偏移量left为400像素,则第一裁剪图片的实际左偏移量_left=2000*|(400/800)|=1000像素。For example, if the left offset left of the cropping frame is 400 pixels, the actual left offset of the first cropped picture is _left=2000*|(400/800)|=1000 pixels.

S54S54 :采用如下公式对所述裁剪框的上偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际上偏移量:: Use the following formula to calculate the upper offset of the cropping frame to obtain the actual offset of the cropping frame in the first cropped picture:

例如,裁剪框的上偏移量top为500像素,则第一裁剪图片的实际上偏移量_top=2000*|(500/800)|=1250像素。For example, if the top offset top of the crop frame is 500 pixels, the actual offset of the first cropped picture is _top=2000*|(500/800)|=1250 pixels.

实际上偏移量=第一裁剪图片的高*裁剪框的上偏移量/裁剪操作台的高。Actual offset=height of the first cropped picture*upper offset of cropping frame/height of cropping console.

可见,在图2对应的实施例中,设置裁剪操作台中裁剪框的参数,并按照对应的公式对裁剪操作台中裁剪框的参数进行相应的计算,能够准确地得到裁剪框在所述第一裁剪图片的实际像素。It can be seen that in the embodiment corresponding to FIG. 2, setting the parameters of the cropping frame in the cropping console, and performing corresponding calculations on the parameters of the cropping frame in the cropping console according to the corresponding formula, can accurately obtain that the cropping frame is in the first crop The actual pixels of the picture.

在一实施例中,在步骤S40中,所述接收用户设置的裁剪框的尺寸,具体包括如下步骤:In an embodiment, in step S40, the receiving the size of the crop frame set by the user specifically includes the following steps:

S41S41 :接收所述用户在所述裁剪框的框线上设置的触点的移动操作,并根据所述移动操作调整裁剪框的尺寸。: Receive a moving operation of the contact set by the user on the frame line of the cropping frame, and adjust the size of the cropping frame according to the moving operation.

本实施例所述裁剪框为矩形裁剪框,矩形裁剪框在四个顶点和四条边线的中间各设置有一个触点,通过移动触点能够调整裁剪框所框选的裁剪区域。The cropping frame in this embodiment is a rectangular cropping frame. The rectangular cropping frame is provided with a contact point each in the middle of the four vertices and four edges, and the cropping area selected by the cropping frame can be adjusted by moving the contact points.

在本实施例中,通过接收所述用户在所述裁剪框的框线上设置的触点的移动操作,并根据所述移动操作调整裁剪框的尺寸能够便于用户快速准确地裁剪出需要的图片,以及方便用户对裁剪框进行微调,提高图片裁剪效率。In this embodiment, by receiving the moving operation of the contact set by the user on the border line of the cropping frame, and adjusting the size of the cropping frame according to the moving operation, it is convenient for the user to quickly and accurately crop out the desired picture. , And it is convenient for users to fine-tune the cropping frame to improve the efficiency of picture cropping.

应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请的实施过程构成任何限定。It should be understood that the size of the sequence number of each step in the foregoing embodiment does not mean the sequence of execution. The execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of this application.

 To

在一实施例中,提供一种图片裁剪装置,该图片裁剪装置与上述实施例中图片裁剪方法一一对应。如图3所示,该图片裁剪装置包括接收图片裁剪指令模块10、等比处理模块20、创建裁剪操作台模块30、接收裁剪框尺寸模块40、第一计算模块50、裁剪模块60、第二计算模块70、缩放模块80、第三计算模块90、确定位置模块100和展示模块110。各功能模块详细说明如下:接收图片裁剪指令模块10,接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;等比处理模块20,根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;创建裁剪操作台模块30,在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收裁剪框尺寸模块40,接收用户设置的裁剪框的尺寸;第一计算模块50,对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;裁剪模块60,根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;第二计算模块70,计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;缩放模块80,按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;第三计算模块90,按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;确定位置模块100,根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示模块110,展示裁剪后的图片。In one embodiment, a picture cropping device is provided, and the picture cropping device corresponds to the picture cropping method in the above-mentioned embodiment one-to-one. As shown in FIG. 3, the picture cropping device includes a picture cropping instruction module 10, a ratio processing module 20, a cropping console creation module 30, a crop frame size receiving module 40, a first calculation module 50, a cropping module 60, and a second The calculation module 70, the zoom module 80, the third calculation module 90, the position determination module 100, and the display module 110. The detailed description of each functional module is as follows: the picture cropping instruction module 10 receives the picture cropping instruction input by the user, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; etc. The ratio processing module 20 performs equal ratio processing on the first cropped picture according to a preset pop-up layer to obtain a second cropped picture, which is displayed in the preset pop-up layer; creates a cropping console module 30, Suppose that a cropping console for setting cropping parameters is created in the pop-up layer, where the size of the cropping console is the size of the second cropped picture; the cropping frame size receiving module 40 receives the size of the cropping frame set by the user; A calculation module 50 calculates the size of the crop frame to obtain the actual size of the crop frame in the first cropped picture; the crop module 60 calculates the size of the crop frame according to the ratio between the width and the height of the crop frame The box corresponding to the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the second calculation module 70 calculates the difference between the actual size of the cropped frame in the first cropped picture and the size of the cropped box The zoom ratio of the first cropped picture; the zoom module 80 correspondingly zooms the first cropped picture according to the zoom ratio to obtain the target cropped picture; the third calculation module 90 is configured to The zoom ratio calculates the actual pixels of the cropping frame in the first cropped picture to obtain a cropped area, where the cropped area includes the left offset of the cropped area and the upper offset of the cropped area; the position determining module 100 Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area to obtain the cropped picture; display module 110 To display the cropped picture.

关于图片裁剪装置的具体限定可以参见上文中对于图片裁剪方法的限定,在此不再赘述。上述图片裁剪装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the picture cropping device, please refer to the above limitation on the picture cropping method, which will not be repeated here. Each module in the above-mentioned picture cropping device can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules may be embedded in the form of hardware or independent of the processor in the computer equipment, or may be stored in the memory of the computer equipment in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned modules.

在一个实施例中,提供了一种计算机设备,该计算机设备可以是终端,其内部结构图可以如图4所示。该计算机设备包括通过系统总线连接的处理器、存储器、显示屏和输入装置。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机可读指令。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机可读指令被处理器执行时以实现一种图片裁剪方法。In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. 4. The computer equipment includes a processor, a memory, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer readable instructions. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The computer readable instruction is executed by the processor to realize a picture cropping method.

在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现以下步骤:接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收用户设置的裁剪框的尺寸;对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示裁剪后的图片。In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and running on the processor, and the processor implements the following steps when the computer-readable instructions are executed: The inputted picture cropping instruction, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer, Obtain the second cropped picture and display it in the preset pop-up layer; create a cropping operation table for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping operation table is the second cropping The size of the picture; receiving the size of the cropping frame set by the user; calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; according to the width and height of the cropping frame The ratio of the first cropped picture is cropped to obtain the cropped box corresponding to the ratio; the cropping box is calculated between the actual size of the first cropped picture and the size of the cropped box The magnification, and the magnification is used as the zoom ratio of the first cropped picture; correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; according to the zoom ratio, the crop frame is set in the The actual pixels of the first cropped picture are calculated to obtain the cropped area, where the cropped area includes the left offset of the cropped area and the upper offset of the cropped area; according to the left offset and the upper offset of the cropped area, Determine the position of the cropped area in the target cropped picture, hide images outside the cropped area, and obtain the cropped picture; and display the cropped picture.

在一个实施例中,提供了一个或多个存储有计算机可读指令的可读存储介质,该可读存储介质上存储有计算机可读指令,本实施例所提供的可读存储介质包括非易失性可读存储介质和易失性可读存储介质,该计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器实现以下步骤:接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;接收用户设置的裁剪框的尺寸;对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;展示裁剪后的图片。In one embodiment, one or more readable storage media storing computer readable instructions are provided. The readable storage medium stores computer readable instructions. The readable storage media provided in this embodiment include non-transitory A volatile readable storage medium and a volatile readable storage medium. When the computer readable instructions are executed by one or more processors, the one or more processors implement the following steps: receiving a picture cropping instruction input by a user, wherein , The picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; the first cropped picture is processed in equal proportions according to the preset pop-up layer to obtain the second cropped picture, and Displayed in the preset pop-up layer; create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; receiving user settings The size of the cropping frame; the size of the cropping frame is calculated to obtain the actual size of the cropping frame in the first cropped picture; according to the ratio between the width and height of the cropping frame, the first A box corresponding to a cropped picture is cropped to obtain a cropped box corresponding to the ratio; the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box is calculated, and the magnification is calculated As the zoom ratio of the first cropped picture; correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; according to the zoom ratio, the actual pixels of the crop frame in the first cropped picture The calculation is performed to obtain the cropping area, where the cropping area includes the left offset of the cropping area and the upper offset of the cropping area; according to the left offset and the upper offset of the cropping area, it is determined that the cropping area is in the The position of the target cropped picture is hidden, the image outside the cropped area is hidden, and the cropped picture is obtained; the cropped picture is displayed.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink) DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the methods of the foregoing embodiments can be implemented by instructing relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Wherein, any reference to memory, storage, database, or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the division of the above functional units and modules is used as an example. In practical applications, the above functions can be allocated to different functional units and modules as needed. Module completion, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.

以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内 The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still implement the foregoing The technical solutions recorded in the examples are modified, or some of the technical features are equivalently replaced; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the application, and should be included in Within the scope of protection of this application .

Claims (20)

一种图片裁剪方法,其中,包括:A picture cropping method, which includes: 接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;Receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; 根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;Perform equal ratio processing on the first cropped picture according to the preset pop-up layer to obtain a second cropped picture, and display it in the preset pop-up layer; 在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,所述裁剪操作台的尺寸为所述第二裁剪图片的尺寸;Creating a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; 接收用户设置的裁剪框的尺寸;Receive the size of the crop frame set by the user; 对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;Calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; 根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;Cropping the box corresponding to the first cropped picture according to the ratio between the width and the height of the cropping frame to obtain a cropped box corresponding to the ratio; 计算所述裁剪框在第一裁剪图片的实际尺寸与所述裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;Calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and use the magnification as the zoom ratio of the first cropped picture; 按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;Correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; 按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;Calculating the actual pixels of the cropping frame in the first cropped picture according to the zoom ratio to obtain a cropping area, where the cropping area includes a left offset of the cropping area and an upper offset of the cropping area; 根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area, and obtain a cropped picture; 展示所述裁剪后的图片。Show the cropped picture. 如权利要求1所述的图片裁剪方法,其中,在所述得到裁剪后的图片之后,所述展示裁剪后的图片之前,还包括:5. The picture cropping method according to claim 1, wherein after said obtaining the cropped picture and before said displaying the cropped picture, the method further comprises: 接收用户输入的图片重新裁剪指令,其中,所述图片重新裁剪指令包括所述用于设置裁剪参数的裁剪操作台;Receiving a picture re-cropping instruction input by a user, where the picture re-cropping instruction includes the cropping console for setting cropping parameters; 根据所述裁剪操作台,重新执行设置裁剪框的尺寸的步骤。According to the cutting operation table, the step of setting the size of the cutting frame is re-executed. 如权利要求1所述的图片裁剪方法,其中,所述根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,包括:8. The picture cropping method of claim 1, wherein said performing equal ratio processing 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 cropped picture is smaller 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, then the first cropped picture is taken as the first cropped picture. 2. Crop the picture; 若所述第一裁剪图片的宽与所述预设弹出层的宽相等,且所述第一裁剪图片的高与所述预设弹出层的高相等,则将所述第一裁剪图片作为所述第二裁剪图片。If the width of the first cropped picture is equal to the width of the preset pop-up layer, and the height of the first cropped picture is equal to the height of the preset pop-up layer, then the first cropped picture is used as the Describe the second cropped picture. 如权利要求3所述的图片裁剪方法,其中,所述方法还包括:8. The picture cropping method according to claim 3, wherein the method further comprises: 若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高小,则计算所述第一裁剪图片的宽与所述预设弹出层的宽的第一比值;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, then the width and the width of the first cropped picture are calculated The first ratio of the width of the preset pop-up layer; 按照所述第一比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the first ratio to obtain the second cropped picture. 如权利要求4所述的图片裁剪方法,其中,所述方法还包括:5. The picture cropping method according to claim 4, wherein the method further comprises: 若所述第一裁剪图片的宽比所述预设弹出层的宽小,且所述第一裁剪图片的高比所述预设弹出层的高大,则计算所述第一裁剪图片的高与所述预设弹出层的高的第二比值;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, then the height and the height of the first cropped picture are calculated The second ratio of the height of the preset pop-up layer; 按照所述第二比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the second ratio to obtain the second cropped picture. 如权利要求5所述的图片裁剪方法,其中,所述方法还包括:8. The picture cropping method according to claim 5, wherein the method further comprises: 若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高大,则计算所述第一裁剪图片的宽与所述预设弹出层的宽的第三比值;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, then the width and the width of the first cropped picture are calculated. The third ratio of the width of the preset pop-up layer; 计算所述第一裁剪图片的高与所述预设弹出层的高的第四比值;Calculating a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer; 将所述第三比值与所述第四比值的大小进行对比,取数值大的为缩放比值;Comparing the magnitude of the third ratio with the magnitude of the fourth ratio, and the larger value is the scaling ratio; 按照所述缩放比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the zoom ratio to obtain the second cropped picture. 如权利要求1所述的图片裁剪方法,其中,所述裁剪框参数包括以裁剪框左上角顶点横坐标的像素为裁剪框的最左边距离裁剪操作台的最左边的左偏移量、以裁剪框左上角顶点纵坐标为裁剪框的最上边距离裁剪操作台的最上边的上偏移量、裁剪框的宽和裁剪框的高,所述对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸,包括:The picture cropping method according to claim 1, wherein the cropping frame parameters include taking the pixel of the abscissa of the vertex of the upper left corner of the cropping frame as the leftmost left offset of the cropping frame from the leftmost left offset of the cropping operation platform, and cutting The vertical coordinate of the vertex of the upper left corner of the frame is the upper offset of the uppermost edge of the cropping frame from the uppermost edge of the cutting console, the width of the cropping frame, and the height of the cropping frame. The size of the cropping frame is calculated to obtain the The actual size of the cropping frame in the first cropped picture includes: 采用如下公式对所述裁剪框的宽进行计算,得到所述裁剪框在所述第一裁剪图片的实际宽:The width of the cropping frame is calculated using the following formula to obtain the actual width of the cropping frame in the first cropped picture: 实际宽=第一裁剪图片的宽*裁剪框的宽/裁剪操作台的宽;Actual width = the width of the first cropped picture * the width of the cropping frame/the width of the cropping console; 采用如下公式对所述裁剪框的高进行计算,得到所述裁剪框在所述第一裁剪图片的实际高:The following formula is used to calculate the height of the cropping frame to obtain the actual height of the cropping frame in the first cropped picture: 实际高=第一裁剪图片的高*裁剪框的高/裁剪操作台的高;Actual height = the height of the first cropped picture * the height of the cropping frame/the height of the cropping console; 采用如下公式对所述裁剪框的左偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际左偏移量:The following formula is used to calculate the left offset of the cropping frame to obtain the actual left offset of the cropping frame in the first cropped picture: 实际左偏移量=第一裁剪图片的宽*裁剪框的左偏移量/裁剪操作台的宽;The actual left offset = the width of the first cropped picture * the left offset of the cropping frame / the width of the cropping console; 采用如下公式对所述裁剪框的上偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际上偏移量:The upper offset of the cropping frame is calculated using the following formula to obtain the actual offset of the cropping frame in the first cropped picture: 实际上偏移量=第一裁剪图片的高*裁剪框的上偏移量/裁剪操作台的高。Actual offset=height of the first cropped picture*upper offset of cropping frame/height of cropping console. 如权利要求1所述的图片裁剪方法,其中,所述接收用户设置的裁剪框的尺寸,包括:The picture cropping method according to claim 1, wherein said receiving the size of the cropping frame set by the user comprises: 接收所述用户在所述裁剪框的框线上设置的触点的移动操作,并根据所述移动操作调整裁剪框的尺寸。Receive a movement operation of the touch point set by the user on the frame line of the cropping frame, and adjust the size of the cropping frame according to the movement operation. 一种图片裁剪装置,其中,包括:A picture cropping device, which includes: 接收图片裁剪指令模块,接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;A picture cropping instruction module receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries the first cropped picture and the size of the box corresponding to the first cropped picture; 等比处理模块,根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;A proportional processing module, which performs proportional processing on the first cropped picture according to a preset pop-up layer to obtain a second cropped picture, and displays it in the preset pop-up layer; 创建裁剪操作台模块,在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,裁剪操作台的尺寸为所述第二裁剪图片的尺寸;Creating a cropping console module to create a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; 接收裁剪框尺寸模块,接收用户设置的裁剪框的尺寸;Receive the crop frame size module to receive the size of the crop frame set by the user; 第一计算模块,对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;The first calculation module calculates the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; 裁剪模块,根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;A cropping module, according to the ratio between the width and the height of the cropping frame, crop the box corresponding to the first cropped picture to obtain a cropped box corresponding to the ratio; 第二计算模块,计算所述裁剪框在第一裁剪图片的实际尺寸与裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;The second calculation module calculates the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and uses the magnification as the zoom ratio of the first cropped picture; 缩放模块,按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;A zooming module, correspondingly zooming the first cropped picture according to the zoom ratio to obtain a target cropped picture; 第三计算模块,按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;The third calculation module calculates the actual pixels of the crop frame in the first cropped picture according to the zoom ratio to obtain a cropped area, wherein the cropped area includes the left offset of the cropped area and the upper offset of the cropped area quantity; 确定位置模块,根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;The position determining module determines the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hides images outside the cropped area, and obtains the cropped picture; 展示模块,展示所述裁剪后的图片。The display module displays the cropped picture. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其中,所述处理器执行所述计算机可读指令时实现如下步骤:A computer device includes a memory, a processor, and computer-readable instructions that are stored in the memory and can run on the processor, wherein the processor implements the following steps when the processor executes the computer-readable instructions: 接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;Receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; 根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;Perform equal ratio processing on the first cropped picture according to the preset pop-up layer to obtain a second cropped picture, and display it in the preset pop-up layer; 在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,所述裁剪操作台的尺寸为所述第二裁剪图片的尺寸;Creating a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; 接收用户设置的裁剪框的尺寸;Receive the size of the crop frame set by the user; 对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;Calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; 根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;Cropping the box corresponding to the first cropped picture according to the ratio between the width and the height of the cropping frame to obtain a cropped box corresponding to the ratio; 计算所述裁剪框在第一裁剪图片的实际尺寸与所述裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;Calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and use the magnification as the zoom ratio of the first cropped picture; 按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;Correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; 按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;Calculating the actual pixels of the cropping frame in the first cropped picture according to the zoom ratio to obtain a cropping area, where the cropping area includes a left offset of the cropping area and an upper offset of the cropping area; 根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area, and obtain a cropped picture; 展示所述裁剪后的图片。Show the cropped picture. 如权利要求10所述的计算机设备,其中,在所述得到裁剪后的图片之后,所述展示裁剪后的图片之前,所述处理器执行所述计算机可读指令时还实现如下步骤: 10. The computer device according to claim 10, wherein, after the cropped picture is obtained and before the cropped picture is displayed, the processor further implements the following steps when executing the computer readable instruction: 接收用户输入的图片重新裁剪指令,其中,所述图片重新裁剪指令包括所述用于设置裁剪参数的裁剪操作台;Receiving a picture re-cropping instruction input by a user, where the picture re-cropping instruction includes the cropping console for setting cropping parameters; 根据所述裁剪操作台,重新执行设置裁剪框的尺寸的步骤。According to the cutting operation table, the step of setting the size of the cutting frame is re-executed. 如权利要求10所述的计算机设备,其中,所述根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,包括:10. The computer device according to claim 10, wherein said performing equal-ratio processing 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 cropped picture is smaller 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, then the first cropped picture is taken as the first cropped picture. 2. Crop the picture; 若所述第一裁剪图片的宽与所述预设弹出层的宽相等,且所述第一裁剪图片的高与所述预设弹出层的高相等,则将所述第一裁剪图片作为所述第二裁剪图片。If the width of the first cropped picture is equal to the width of the preset pop-up layer, and the height of the first cropped picture is equal to the height of the preset pop-up layer, then the first cropped picture is used as the Describe the second cropped picture. 如权利要求12所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还实现如下步骤:The computer device of claim 12, wherein the processor further implements the following steps when executing the computer-readable instructions: 若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高小,则计算所述第一裁剪图片的宽与所述预设弹出层的宽的第一比值;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, then the width and the width of the first cropped picture are calculated The first ratio of the width of the preset pop-up layer; 按照所述第一比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the first ratio to obtain the second cropped picture. 如权利要求13所述的计算机设备,其中,所述处理器执行所述计算机可读指令时还实现如下步骤:The computer device according to claim 13, wherein the processor further implements the following steps when executing the computer readable instruction: 若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高大,则计算所述第一裁剪图片的宽与所述预设弹出层的宽的第三比值;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, then the width and the width of the first cropped picture are calculated. The third ratio of the width of the preset pop-up layer; 计算所述第一裁剪图片的高与所述预设弹出层的高的第四比值;Calculating a fourth ratio of the height of the first cropped picture to the height of the preset pop-up layer; 将所述第三比值与所述第四比值的大小进行对比,取数值大的为缩放比值;Comparing the magnitude of the third ratio with the magnitude of the fourth ratio, and the larger value is the scaling ratio; 按照所述缩放比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the zoom ratio to obtain the second cropped picture. 如权利要求10所述的计算机设备,其中,所述裁剪框参数包括以裁剪框左上角顶点横坐标的像素为裁剪框的最左边距离裁剪操作台的最左边的左偏移量、以裁剪框左上角顶点纵坐标为裁剪框的最上边距离裁剪操作台的最上边的上偏移量、裁剪框的宽和裁剪框的高,所述对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸,包括:The computer device according to claim 10, wherein the cropping frame parameter comprises taking the pixel of the abscissa of the vertex at the upper left corner of the cropping frame as the leftmost offset of the cropping frame from the leftmost left of the cropping console, and the cropping frame The ordinate of the upper left corner vertex is the upper offset of the uppermost edge of the cropping frame from the uppermost edge of the cutting console, the width of the cropping frame, and the height of the cropping frame. The size of the cropping frame is calculated to obtain the cropping The actual size of the frame in the first cropped picture includes: 采用如下公式对所述裁剪框的宽进行计算,得到所述裁剪框在所述第一裁剪图片的实际宽:The width of the cropping frame is calculated using the following formula to obtain the actual width of the cropping frame in the first cropped picture: 实际宽=第一裁剪图片的宽*裁剪框的宽/裁剪操作台的宽;Actual width = the width of the first cropped picture * the width of the cropping frame/the width of the cropping console; 采用如下公式对所述裁剪框的高进行计算,得到所述裁剪框在所述第一裁剪图片的实际高:The following formula is used to calculate the height of the cropping frame to obtain the actual height of the cropping frame in the first cropped picture: 实际高=第一裁剪图片的高*裁剪框的高/裁剪操作台的高;Actual height = the height of the first cropped picture * the height of the cropping frame/the height of the cropping console; 采用如下公式对所述裁剪框的左偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际左偏移量:The following formula is used to calculate the left offset of the cropping frame to obtain the actual left offset of the cropping frame in the first cropped picture: 实际左偏移量=第一裁剪图片的宽*裁剪框的左偏移量/裁剪操作台的宽;The actual left offset = the width of the first cropped picture * the left offset of the cropping frame / the width of the cropping console; 采用如下公式对所述裁剪框的上偏移量进行计算,得到所述裁剪框在所述第一裁剪图片的实际上偏移量:The upper offset of the cropping frame is calculated using the following formula to obtain the actual offset of the cropping frame in the first cropped picture: 实际上偏移量=第一裁剪图片的高*裁剪框的上偏移量/裁剪操作台的高。Actual offset=height of the first cropped picture*upper offset of cropping frame/height of cropping console. 一个或多个存储有计算机可读指令的可读存储介质,其中,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:One or more readable storage media storing computer readable instructions, where when the computer readable instructions are executed by one or more processors, the one or more processors execute the following steps: 接收用户输入的图片裁剪指令,其中,所述图片裁剪指令中带有第一裁剪图片和所述第一裁剪图片对应的盒子的尺寸;Receiving a picture cropping instruction input by a user, wherein the picture cropping instruction carries a first cropped picture and the size of a box corresponding to the first cropped picture; 根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,并展示在所述预设弹出层内;Perform equal ratio processing on the first cropped picture according to the preset pop-up layer to obtain a second cropped picture, and display it in the preset pop-up layer; 在所述预设弹出层内创建一用于设置裁剪参数的裁剪操作台,其中,所述裁剪操作台的尺寸为所述第二裁剪图片的尺寸;Creating a cropping console for setting cropping parameters in the preset pop-up layer, wherein the size of the cropping console is the size of the second cropped picture; 接收用户设置的裁剪框的尺寸;Receive the size of the crop frame set by the user; 对所述裁剪框的尺寸进行计算,得到所述裁剪框在所述第一裁剪图片的实际尺寸;Calculating the size of the cropping frame to obtain the actual size of the cropping frame in the first cropped picture; 根据所述裁剪框的宽与高之间的比率,对所述第一裁剪图片对应的盒子进行裁剪得到与所述比率对应的裁剪后的盒子;Cropping the box corresponding to the first cropped picture according to the ratio between the width and the height of the cropping frame to obtain a cropped box corresponding to the ratio; 计算所述裁剪框在第一裁剪图片的实际尺寸与所述裁剪后的盒子的尺寸之间的倍率,并将所述倍率作为第一裁剪图片的缩放比例;Calculate the magnification of the cropping frame between the actual size of the first cropped picture and the size of the cropped box, and use the magnification as the zoom ratio of the first cropped picture; 按照所述缩放比例将所述第一裁剪图片进行对应缩放,得到目标裁剪图片;Correspondingly zoom the first cropped picture according to the zoom ratio to obtain the target cropped picture; 按照所述缩放比例对所述裁剪框在所述第一裁剪图片的实际像素进行计算,得到裁剪区域,其中,裁剪区域包括裁剪区域的左偏移量和裁剪区域上偏移量;Calculating the actual pixels of the cropping frame in the first cropped picture according to the zoom ratio to obtain a cropping area, where the cropping area includes a left offset of the cropping area and an upper offset of the cropping area; 根据所述裁剪区域的左偏移量和上偏移量,确定所述裁剪区域在所述目标裁剪图片中的位置,隐藏所述裁剪区域以外的图像,得到裁剪后的图片;Determine the position of the cropped area in the target cropped picture according to the left offset and the top offset of the cropped area, hide images outside the cropped area, and obtain a cropped picture; 展示所述裁剪后的图片。Show the cropped picture. 如权利要求16所述的可读存储介质,其中,在所述得到裁剪后的图片之后,所述展示裁剪后的图片之前,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:The readable storage medium according to claim 16, wherein, after the cropped picture is obtained and before the cropped picture is displayed, when the computer-readable instructions are executed by one or more processors, such that The one or more processors further execute the following steps: 接收用户输入的图片重新裁剪指令,其中,所述图片重新裁剪指令包括所述用于设置裁剪参数的裁剪操作台;Receiving a picture re-cropping instruction input by a user, where the picture re-cropping instruction includes the cropping console for setting cropping parameters; 根据所述裁剪操作台,重新执行设置裁剪框的尺寸的步骤。According to the cutting operation table, the step of setting the size of the cutting frame is re-executed. 如权利要求16所述的可读存储介质,其中,所述根据预设弹出层对所述第一裁剪图片进行等比处理,得到第二裁剪图片,包括:15. The readable storage medium according to claim 16, wherein said performing equal-ratio processing 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 cropped picture is smaller 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, then the first cropped picture is taken as the first cropped picture. 2. Crop the picture; 若所述第一裁剪图片的宽与所述预设弹出层的宽相等,且所述第一裁剪图片的高与所述预设弹出层的高相等,则将所述第一裁剪图片作为所述第二裁剪图片。If the width of the first cropped picture is equal to the width of the preset pop-up layer, and the height of the first cropped picture is equal to the height of the preset pop-up layer, then the first cropped picture is used as the Describe the second cropped picture. 如权利要求18所述的可读存储介质,其中,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:The readable storage medium of claim 18, wherein when the computer-readable instructions are executed by one or more processors, the one or more processors further execute the following steps: 若所述第一裁剪图片的宽比所述预设弹出层的宽大,且所述第一裁剪图片的高比所述预设弹出层的高小,则计算所述第一裁剪图片的宽与所述预设弹出层的宽的第一比值;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, then the width and the width of the first cropped picture are calculated The first ratio of the width of the preset pop-up layer; 按照所述第一比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the first ratio to obtain the second cropped picture. 如权利要求19所述的可读存储介质,其中,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:The readable storage medium according to claim 19, wherein, when the computer-readable instructions are executed by one or more processors, the one or more processors further execute the following steps: 若所述第一裁剪图片的宽比所述预设弹出层的宽小,且所述第一裁剪图片的高比所述预设弹出层的高大,则计算所述第一裁剪图片的高与所述预设弹出层的高的第二比值;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, then the height and the height of the first cropped picture are calculated The second ratio of the height of the preset pop-up layer; 按照所述第二比值对所述第一裁剪图片进行缩小,得到所述第二裁剪图片。The first cropped picture is reduced according to the second ratio to obtain the second cropped picture.
PCT/CN2020/118001 2020-04-29 2020-09-27 Picture cropping method and apparatus, computer device, and storage medium Ceased WO2021218016A1 (en)

Applications Claiming Priority (2)

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

Publications (1)

Publication Number Publication Date
WO2021218016A1 true WO2021218016A1 (en) 2021-11-04

Family

ID=72382897

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/118001 Ceased WO2021218016A1 (en) 2020-04-29 2020-09-27 Picture cropping method and apparatus, computer device, and storage medium

Country Status (2)

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

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114463169A (en) * 2021-12-24 2022-05-10 深圳万兴软件有限公司 Image data enhancement method, device, equipment and storage medium
CN114693518A (en) * 2022-02-15 2022-07-01 杭州印鸽科技有限公司 Picture printing-oriented intelligent picture cutting method
CN115131197A (en) * 2022-04-11 2022-09-30 广州宇中网络科技有限公司 A kind of image preprocessing method, system and device based on network service middle layer
CN116228533A (en) * 2022-12-22 2023-06-06 五八有限公司 Graphic code display method, device, electronic device and storage medium
CN117893639A (en) * 2022-10-14 2024-04-16 荣耀终端有限公司 Image processing method and related device

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111667487B (en) * 2020-04-29 2024-08-13 平安科技(深圳)有限公司 Picture clipping method and device and computer equipment
CN112700454B (en) * 2020-12-28 2024-05-14 北京达佳互联信息技术有限公司 Image cropping method and device, electronic equipment and storage medium
CN112541919B (en) * 2020-12-29 2024-09-17 申建常 Picture segmentation processing method and processing system
CN114842031B (en) * 2022-05-12 2025-07-01 深圳市康冠商用科技有限公司 Image cropping method, device, computer equipment and storage medium
CN116095249B (en) * 2022-05-30 2023-10-20 荣耀终端有限公司 Video processing method and electronic equipment
CN117173194A (en) * 2023-09-05 2023-12-05 北京字跳网络技术有限公司 Method for cropping pictures and related equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106296760A (en) * 2015-05-21 2017-01-04 腾讯科技(深圳)有限公司 The method of cutting out of picture and device
US20170320336A1 (en) * 2016-04-20 2017-11-09 Butt Nouman Idris Under-glass digital printing method of multilayer synthetic leather
CN107544730A (en) * 2017-08-25 2018-01-05 广州视源电子科技股份有限公司 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

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9438818B2 (en) * 2012-06-20 2016-09-06 Qualcomm Incorporated Device and method for multimedia communications with picture orientation information
CN110599445A (en) * 2019-07-24 2019-12-20 安徽南瑞继远电网技术有限公司 Target robust detection and defect identification method and device for power grid nut and pin

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106296760A (en) * 2015-05-21 2017-01-04 腾讯科技(深圳)有限公司 The method of cutting out of picture and device
US20170320336A1 (en) * 2016-04-20 2017-11-09 Butt Nouman Idris Under-glass digital printing method of multilayer synthetic leather
CN107544730A (en) * 2017-08-25 2018-01-05 广州视源电子科技股份有限公司 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 (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114463169A (en) * 2021-12-24 2022-05-10 深圳万兴软件有限公司 Image data enhancement method, device, equipment and storage medium
CN114693518A (en) * 2022-02-15 2022-07-01 杭州印鸽科技有限公司 Picture printing-oriented intelligent picture cutting method
CN115131197A (en) * 2022-04-11 2022-09-30 广州宇中网络科技有限公司 A kind of image preprocessing method, system and device based on network service middle layer
CN117893639A (en) * 2022-10-14 2024-04-16 荣耀终端有限公司 Image processing method and related device
CN116228533A (en) * 2022-12-22 2023-06-06 五八有限公司 Graphic code display method, device, electronic device and storage medium

Also Published As

Publication number Publication date
CN111667487A (en) 2020-09-15
CN111667487B (en) 2024-08-13

Similar Documents

Publication Publication Date Title
WO2021218016A1 (en) Picture cropping method and apparatus, computer device, and storage medium
US11373275B2 (en) Method for generating high-resolution picture, computer device, and storage medium
CN111107418B (en) Video data processing method, device, computer equipment and storage medium
US9772771B2 (en) Image processing for introducing blurring effects to an image
US9916641B2 (en) Picture display method and apparatus
CN108228050B (en) Picture scaling method and device and electronic equipment
KR102121905B1 (en) Method and apparatus for setting background of ui control, and terminal
WO2022149746A1 (en) Method and system for image retargeting
WO2017088605A1 (en) Method and device for controlling picture display in picture editing
CN110457102B (en) Blur method, rendering method and computing device for visible objects
WO2021243788A1 (en) Screenshot method and apparatus
WO2017032233A1 (en) Image generation method and device
CN113835651B (en) Data display processing method, device, computer equipment and storage medium
WO2024222356A1 (en) Special-effect generation method and apparatus, and computer device and storage medium
CN101650824B (en) Content erotic image zooming method based on conformal energy
CN113055592B (en) Image display method and device, electronic equipment and computer readable storage medium
WO2023151214A1 (en) Image generation method and system, electronic device, storage medium, and product
WO2023001188A1 (en) Image processing method and apparatus, and readable storage medium
CN113012028B (en) Image processing method, device, equipment and storage medium
CN113379768A (en) Image processing method, image processing device, storage medium and computer equipment
US20250191122A1 (en) Image generation method for eliminating splicing seams, computer device and storage medium
TW202536806A (en) Electronic apparatus and wallpaper generation method thereof
CN115599488A (en) Page display method and device, electronic equipment and storage medium
CN115963966A (en) Image display method, image display device, storage medium, and electronic apparatus
CN113934391A (en) A data processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20933864

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20933864

Country of ref document: EP

Kind code of ref document: A1