CN110830716B - Image generation method and device, computer equipment and storage medium - Google Patents

Image generation method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN110830716B
CN110830716B CN201911088732.XA CN201911088732A CN110830716B CN 110830716 B CN110830716 B CN 110830716B CN 201911088732 A CN201911088732 A CN 201911088732A CN 110830716 B CN110830716 B CN 110830716B
Authority
CN
China
Prior art keywords
size
width
screen
height
reference frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911088732.XA
Other languages
Chinese (zh)
Other versions
CN110830716A (en
Inventor
马飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing Xingyun Digital Technology Co Ltd
Original Assignee
Nanjing Xingyun Digital Technology 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 Nanjing Xingyun Digital Technology Co Ltd filed Critical Nanjing Xingyun Digital Technology Co Ltd
Priority to CN201911088732.XA priority Critical patent/CN110830716B/en
Publication of CN110830716A publication Critical patent/CN110830716A/en
Application granted granted Critical
Publication of CN110830716B publication Critical patent/CN110830716B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/04845Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range for image manipulation, e.g. dragging, rotation, expansion or change of colour

Abstract

The present application relates to an image generation method. The method comprises the following steps: the method comprises the steps of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size; determining the size of a first reference frame according to the first size and a preset reference size; determining a second size according to the size of the first reference frame, the first size and the screen size; and acquiring an initial image, and cutting the initial image according to the second size to obtain a target image file. The method and the device have the advantages that the initial image is cut based on the preset reference size, so that the cut image meets the preset size requirement, and meanwhile, the cutting of the image is more intelligent.

Description

Image generation method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer application technologies, and in particular, to an image generation method and apparatus, a computer device, and a storage medium.
Background
With the popularization of intelligent mobile devices, more and more people are used to collect photos with mobile terminals. For example, people like to record beauty moments in life by mobile devices and share the beauty moments in social networks, or people take the mobile devices as collection terminals of identification cards, and information collection experiences which many people have encountered when taking photos and uploading identification cards are also the experience of information collection. However, whether the life photo or the identification photo is collected, the photo taken by people usually needs some processing, such as cutting or filtering, and the like, and then the photo is really needed.
When a photo is cut, part of the current scheme is to directly upload a shot certificate photo after the photo is shot by using a camera of the system, and the certificate photo uploaded in this way does not meet the size requirement of the certificate photo, which easily causes the situation that a displayed image is compressed or amplified after the certificate photo is uploaded on some APPs (applications) which need to upload the certificate photo and have requirements on the size of the certificate photo. And the other part adopts the scheme that the picture is taken firstly, and the user manually cuts the picture after the picture is taken. This solution enables basically cutting out the photos required by the user according to the photo size requirements, but requires manual operation by the user, which reduces the efficiency and increases the size error.
Disclosure of Invention
Therefore, it is necessary to provide a method, an apparatus, a computer device and a storage medium for cropping an initial image based on a preset reference size, so as to automatically crop an image meeting a preset size requirement, and make image cropping more intelligent.
A method of image generation, the method comprising:
the method comprises the steps of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size;
determining the size of a first reference frame according to the first size and a preset reference size;
determining a second size according to the size of the first reference frame, the first size and the screen size;
and acquiring an initial image, and cutting the initial image according to the second size to obtain a target image file.
In one embodiment, the selecting a first size matching the screen size from a preset image size list according to the screen size includes:
acquiring each photo size in the image size list;
selecting a plurality of candidate photo sizes corresponding to the height of the photo size smaller than the height of the screen size and the width of the photo size smaller than the width of the screen size;
calculating a first ratio of width to height in each candidate photo size;
and comparing each first ratio with a second ratio of the width to the height in the screen size to obtain a first ratio with the minimum difference value with the second ratio, and taking the candidate photo size corresponding to the first ratio as the first size.
In one embodiment, the determining the size of the first reference frame according to the first size and a preset reference size includes:
determining the width of the first reference frame according to the width of a screen in the screen size and a preset first interval width;
determining the height of the first reference frame according to the width of the first reference frame, the first size, the screen size and a reference ratio of width to height in the reference sizes;
and taking the width of the first reference frame and the height of the first reference frame as the size of the first reference frame.
In one embodiment, the determining a second size according to the size of the first reference frame, the first size, and the screen size includes:
determining a width in the second size according to a width in the size of the first reference frame, a height in the first size, and a width in the screen size;
determining a height in the second size in accordance with a height in the size of the first reference frame, a width in the first size, and a height in the screen size.
In one embodiment, the acquiring the initial image includes:
and acquiring an image of the current shot object as the initial image.
In one embodiment, before the acquiring the current image of the photographed object as the initial image, the method further includes:
acquiring each preview size in a preset preview size list;
selecting a plurality of candidate preview sizes corresponding to the height of the preview size smaller than the height of the screen size and the width of the preview size smaller than the width of the screen size;
calculating a third ratio of width to height in each candidate preview size;
comparing each third ratio with a second ratio of width to height in the screen size to obtain a third ratio with the minimum difference value with the second ratio, and taking a candidate preview size corresponding to the third ratio as a third size;
determining the width of a second reference frame according to the width in the screen size and a preset second interval width;
determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size and a reference ratio of width to height in the reference sizes;
and drawing the second reference frame on a screen according to the width of the second reference frame and the height of the second reference frame.
In one embodiment, before the acquiring the current image of the photographed object as the initial image, the method further includes:
monitoring a layout change of a screen of the electronic device;
when the layout of the screen is monitored to be changed, a first value of the display state of the virtual key on the current screen and a second value of the display state of the virtual key on the screen before the layout is changed are obtained;
judging whether the first value is the same as the second value;
and if not, judging that the size of the screen of the electronic equipment is changed, returning to the step of acquiring the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
An apparatus for generating a photograph, the apparatus comprising:
the acquisition module is used for acquiring the screen size of the current electronic equipment and selecting a first size matched with the screen size from a preset image size list according to the screen size;
the first determining module is used for determining the size of the first reference frame according to the first size and a preset reference size;
the second determining module is used for determining a second size according to the size of the first reference frame, the first size and the screen size;
and the cutting module is used for obtaining an initial image and cutting the initial image according to the second size to obtain a target image file.
A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of any of the above-described embodiments of the method when executing the computer program.
A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any of the embodiments described above.
According to the image generation method, the image generation device, the computer equipment and the storage medium, the screen size of the current electronic equipment is obtained, and a first size matched with the screen size is selected from a preset image size list according to the screen size; determining the size of a first reference frame according to the first size and a preset reference size; determining a second size according to the size of the first reference frame, the first size and the screen size; and acquiring an initial image, and cutting the initial image according to the second size to obtain a target image file. The method and the device have the advantages that the initial image is cut based on the preset reference size, so that the cut image meets the preset size requirement, and meanwhile, the cutting of the image is more intelligent.
Drawings
FIG. 1 is a diagram of an application environment of an image generation method in an exemplary embodiment of the present application;
FIG. 2 is a schematic flow chart diagram of an image generation method provided in an exemplary embodiment of the present application;
FIG. 3 is a diagram illustrating a second example embodiment of the present application;
fig. 4 is a schematic diagram of a screen structure of an electronic device provided in an exemplary embodiment of the present application.
Fig. 5 is a block diagram of an image processing apparatus provided in an exemplary embodiment of the present application;
fig. 6 is an internal structural diagram of a computer device provided in an exemplary embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The image generation method in the embodiment of the application can be applied to electronic equipment. The electronic device may be, but is not limited to, a mobile phone, a notebook, a tablet computer, and the like. Fig. 1 is a schematic diagram of an internal structure of an electronic device in an embodiment. The electronic device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor is configured to provide computational and control capabilities. The memory includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and further includes an image generation apparatus for implementing an image generation method. The internal memory provides an environment for running the computer program in the nonvolatile storage medium. The display screen is used for displaying a target image generated by the current application program, and the display screen can be a liquid crystal display screen or an electronic ink display screen. The input device in the application can be an image acquisition device, such as a camera, a touch layer covered on a display screen, a key, a track ball or a touch pad arranged on an electronic equipment shell, and an external keyboard, a touch pad or a mouse.
In one embodiment, as shown in fig. 2, an image generation method is provided, which is described by taking the method as an example of the application program in fig. 1, and comprises the following steps:
s11, acquiring the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
In the present application, the current application program may be called by another application program that has previously accessed the application program. When the current application program receives a call instruction of other application programs, the image generation method can be executed.
In the present application, initialization is started when the current application is called. In the initialization process, the screen size of the current electronic equipment is obtained, and a first size matched with the screen size is selected from a preset image size list according to the screen size.
And S12, determining the size of the first reference frame according to the first size and a preset reference size.
In the application, the first reference frame is a virtual frame, and the second size for subsequent cutting is obtained through the first reference frame.
And S13, determining a second size according to the size of the first reference frame, the first size and the screen size.
In the present application, the second size may be determined by a width and a height in the size of the first reference frame, a width and a height in the first size, and a width and a height in the screen size. In the application, when the subsequent cropping is executed, the cropping is specifically executed on the initial image according to the second size.
And S14, acquiring the initial image, and cutting the initial image according to the second size to obtain the target image file.
In the application, the initial image is acquired after the second size is acquired, and the initial image is cut according to the second size. The method and the device can call the camera to acquire the image of the current shot object as the initial image when the initial image is acquired.
In another embodiment, the method and the device for generating the target image file can also obtain the initial image after obtaining the first size, determine the second size according to the size of the first reference frame, the first size and the screen size, and then cut the initial image according to the second size to obtain the target image file.
In one embodiment, the selecting a first size matching the screen size from the preset image size list according to the screen size includes:
acquiring each photo size in the image size list;
selecting a plurality of candidate photo sizes corresponding to the height of the photo size smaller than the height of the screen size and the width of the photo size smaller than the width of the screen size;
calculating a first ratio of width to height in each candidate photo size;
and comparing each first ratio with a second ratio of the width to the height in the screen size to obtain a first ratio with the minimum difference value with the second ratio, and taking the candidate photo size corresponding to the first ratio as the first size.
The present application sets in advance an image size list in which a plurality of photograph sizes are included. The application selects an optimal photo size matching the screen size from the plurality of photo sizes as the second size.
Specifically, if the picture size list includes a picture size that is consistent with the screen size, the picture size is directly acquired as a first size; if the picture size consistent with the screen size is not included in the image size list, a picture size consistent with or closest to the scale of the screen size is acquired as the first size. Preferably, in order to ensure memory usage, a photo size smaller than a preset size of a screen size may be selected as the first size.
In one embodiment, the determining the size of the first reference frame according to the first size and a preset reference size includes:
determining the width of a first reference frame according to the width of a screen in the screen size and a preset first interval width;
determining the height of the first reference frame according to the width of the first reference frame, the first size, the screen size and a reference ratio of the width to the height in the reference size;
the width of the first reference frame and the height of the first reference frame are taken as the size of the first reference frame.
Specifically, assuming that the width of the first reference frame is picFrameWidth, the height of the first reference frame is picFrameHeight, and the first interval width is M1, the specific formula for determining the width of the first reference frame according to the width of the screen in the screen size and the preset first interval width is as follows:
picFrameWidth=ScnWi dth-M1
further, the specific calculation formula for determining the height of the first reference frame according to the width of the first reference frame, the first size, the screen size and the reference ratio of the width to the height in the reference size is as follows:
picFrameHeight=picFrameWidth*ratio*picHeight/picWidth*ScnHeight/ScnWidth
wherein picHeight is the height in the first dimension, picWidth is the width in the first dimension, ScnHeight is the height of the screen, ScnWidth is the width of the screen, ratio is width/height, height is the height in the reference dimension, and width is the width in the reference dimension.
In one embodiment, the determining the second size according to the size of the first reference frame, the first size and the screen size includes:
determining a width in the second size according to a width in the size of the first reference frame, a height in the first size, and a width in the screen size;
the height in the second size is determined according to the height in the size of the first reference frame, the width in the first size, and the height in the screen size.
In this application, assuming that the height in the second size is realHeight and the width in the second size is realWidth, a specific calculation formula for determining the width in the second size according to the width in the size of the first reference frame, the height in the first size, and the width in the screen size is as follows:
realWidth=picFrameWidth*picHeight/ScnWidth
further, the height in the second size is determined according to the height in the size of the first reference frame, the width in the first size and the height in the screen size, and a specific calculation formula is as follows:
realHeight=picFrameHeight*picWidth/ScnHeight
wherein, realHeight is the height in the second size, picFrameHeight is the width of the first reference frame, picWidth is the width in the first size, and scnhight is the height of the screen.
In one embodiment, the acquiring the initial image includes: and acquiring an image of the current shot object as an initial image.
According to the method and the device, after the first size is obtained, shooting operation is executed, and a camera is called to collect the image of the current shot object to be used as an initial image.
In another embodiment, after the first size and the second size are obtained, shooting operation is executed, and a camera is called to acquire an image of a current shot object as an initial image.
In one embodiment, before the capturing the current image of the photographed object as the initial image, the method further includes:
acquiring each preview size in a preset preview size list;
selecting a plurality of candidate preview sizes corresponding to the height of the preview size smaller than the height of the screen size and the width of the preview size smaller than the width of the screen size;
calculating a third ratio of width to height in each candidate preview size;
comparing each third ratio with a second ratio of width to height in the screen size to obtain a third ratio with the minimum difference value with the second ratio, and taking the candidate preview size corresponding to the third ratio as a third size;
determining the width of a second reference frame according to the width in the screen size and a preset second interval width;
determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size and the reference ratio of the width to the height in the reference size;
and drawing the second reference frame on the screen according to the width of the second reference frame and the height of the second reference frame.
In this application, it is assumed that the width in the third dimension is preWidth, the height in the third dimension is preHeight, the width in the first dimension is picWidth, the height in the first dimension is picHeight, the width of the second reference frame is preFrameWidth, the height of the second reference frame is preFrameHeight, and the preset second interval width is M2. In the present application, a specific formula for determining the width of the second reference frame according to the width of the screen size and the preset second interval width is as follows:
preFrameWidth=ScnWidth-M2
further, a specific formula for determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size, and a reference ratio of the width to the height in the reference size is as follows:
preFrameHeight=preFrameWidth*ratio*preHeight/preWidth*ScnHeight/ScnWidth
wherein preFrameHeight is the height of the second base frame, preFrameWidth is the width of the second base frame, prefeedt is the height of the third size, preFrameWidth is the width of the third size, ScnHeight is the height of the screen, ScnWidth is the width of the screen, the reference ratio is width/height, height is the height of the reference size, and width is the width of the reference size.
In the application, the second reference frame is obtained, and the second reference frame is drawn on the screen, so that a user can conveniently place a current shot object such as an identity card according to the second reference frame when shooting. Specifically, the current shot object needs to be previewed in the shooting process of the user, taking the current shot object as an identity card as an example, it needs to be ensured that the screen of the electronic device is arranged in a preset distance right above the identity card during shooting, and meanwhile, the identity card is ensured to be in the second reference frame during previewing, and four sides of the identity card are respectively overlapped with four sides of the second reference frame.
Referring to fig. 3, fig. 3 is a screen diagram illustrating a second reference frame according to an embodiment. In fig. 3, the screen 2 on which the second reference frame is drawn includes the second reference frame 21 and the screen area 22, and the second reference frame 21 includes the width 211 of the second reference frame and the height 212 of the second reference frame.
In one embodiment, before the capturing the current image of the photographed object as the initial image, the method further includes:
monitoring a layout change of a screen of the electronic device;
when the layout of the screen is monitored to be changed, a first value of the display state of the virtual key on the current screen and a second value of the display state of the virtual key on the screen before the layout is changed are obtained;
judging whether the first value is the same as the second value;
if not, judging that the size of the screen of the electronic equipment is changed, returning to the step of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
In this application, because electronic equipment is various, electronic equipment's screen size is also various. In the present Application, if the electronic device is a mobile phone, the vertical screen of the mobile phone is taken as a standard direction, that is, the default screen direction of the mobile phone, the shorter side is wide, and the longer side is high, and the width and the height of the screen of the mobile phone are obtained through an Application Programming Interface (API) provided by the system.
Furthermore, some electronic devices have a navigation bar inside the screen, and the navigation bar can also control the hidden and revealed state thereof through gestures at any time, and the height of the screen acquired in the application does not include the height of the navigation bar, so that when the navigation bar is in the displayed state, the height of the navigation bar needs to be removed to acquire the required height of the screen.
Further, the change of the screen size needs to be monitored before the initial image is acquired, and when the change of the screen size is monitored, the screen size needs to be obtained again, and other sizes, such as the size of the second reference frame and the size of the first reference frame, also need to be recalculated. In addition, because the screen size is not changed in a large range, when the screen size is monitored to be changed, the first size and the third size can be obtained by using the data obtained before, and the data do not need to be obtained again.
Referring to fig. 4, fig. 4 is a schematic diagram of a screen structure of an electronic device according to an embodiment. In fig. 4, the screen structure 3 of the electronic device includes a screen portion 31 and a navigation bar portion 32. The screen portion includes a width 311 of the screen and a height 312 of the screen. In the present application, the navigation bar portion 32 should be removed when calculating the screen size.
In one embodiment, as shown in fig. 5, there is provided an image processing apparatus including:
the acquisition module 11 is configured to acquire a screen size of the current electronic device, and select a first size matched with the screen size from a preset image size list according to the screen size;
a first determining module 12, configured to determine a size of the first reference frame according to the first size and a preset reference size;
a second determining module 13, configured to determine a second size according to the size of the first reference frame, the first size, and the screen size;
and the cutting module 14 is configured to obtain an initial image, and cut the initial image according to a second size to obtain a target image file.
In one embodiment, the obtaining module 11 includes:
an acquisition unit configured to acquire each photo size in the image size list;
selecting a plurality of candidate photo sizes corresponding to the height of the photo size smaller than the height of the screen size and the width of the photo size smaller than the width of the screen size;
calculating a first ratio of width to height in each candidate photo size;
and comparing each first ratio with a second ratio of the width to the height in the screen size to obtain a first ratio with the minimum difference value with the second ratio, and taking the candidate photo size corresponding to the first ratio as the first size.
In one embodiment, the first determining module 12 includes:
the first determining unit is used for determining the width of the first reference frame according to the width of the screen in the screen size and a preset first interval width;
determining the height of the first reference frame according to the width of the first reference frame, the first size, the screen size and a reference ratio of the width to the height in the reference size;
the width of the first reference frame and the height of the first reference frame are taken as the size of the first reference frame.
In one embodiment, the second determining module 13 includes:
a second determination unit for determining a width in the second size in accordance with a width in the size of the first reference frame, a height in the first size, and a width in the screen size;
the height in the second size is determined according to the height in the size of the first reference frame, the width in the first size, and the height in the screen size.
In one embodiment, the clipping module 14 includes:
and the acquisition unit is used for acquiring the image of the current shot object as an initial image.
In one embodiment, before the capturing the current image of the photographed object as the initial image, the method further includes:
acquiring each preview size in a preset preview size list;
selecting a plurality of candidate preview sizes corresponding to the height of the preview size smaller than the height of the screen size and the width of the preview size smaller than the width of the screen size;
calculating a third ratio of width to height in each candidate preview size;
comparing each third ratio with a second ratio of width to height in the screen size to obtain a third ratio with the minimum difference value with the second ratio, and taking the candidate preview size corresponding to the third ratio as a third size;
determining the width of a second reference frame according to the width in the screen size and a preset second interval width;
determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size and the reference ratio of the width to the height in the reference size;
and drawing the second reference frame on the screen according to the width of the second reference frame and the height of the second reference frame.
In one embodiment, before the capturing the current image of the photographed object as the initial image, the method further includes:
monitoring a layout change of a screen of the electronic device;
when the layout of the screen is monitored to be changed, a first value of the display state of the virtual key on the current screen and a second value of the display state of the virtual key on the screen before the layout is changed are obtained;
judging whether the first value is the same as the second value;
if not, judging that the size of the screen of the electronic equipment is changed, returning to the step of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide the determining and controlling capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an image generation method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size; determining the size of the first reference frame according to the first size and a preset reference size; determining a second size according to the size of the first reference frame, the first size and the screen size; and acquiring an initial image, and cutting the initial image according to a second size to obtain a target image file.
In one embodiment, the processor executes the computer program to select the first size matching the screen size from the preset image size list according to the screen size, and specifically implements the following steps:
acquiring each photo size in the image size list;
selecting a plurality of candidate photo sizes corresponding to the height of the photo size smaller than the height of the screen size and the width of the photo size smaller than the width of the screen size;
calculating a first ratio of width to height in each candidate photo size;
and comparing each first ratio with a second ratio of the width to the height in the screen size to obtain a first ratio with the minimum difference value with the second ratio, and taking the candidate photo size corresponding to the first ratio as the first size.
In an embodiment, the processor executes the computer program to determine the size of the first reference frame according to the first size and the preset reference size, and specifically implements the following steps:
determining the width of a first reference frame according to the width of a screen in the screen size and a preset first interval width;
determining the height of the first reference frame according to the width of the first reference frame, the first size, the screen size and a reference ratio of the width to the height in the reference size;
the width of the first reference frame and the height of the first reference frame are taken as the size of the first reference frame.
In an embodiment, the processor executes the computer program to determine the second size according to the size of the first reference frame, the first size, and the screen size, and specifically implements the following steps:
determining a width in the second size according to a width in the size of the first reference frame, a height in the first size, and a width in the screen size;
the height in the second size is determined according to the height in the size of the first reference frame, the width in the first size, and the height in the screen size.
In one embodiment, the processor executes the computer program to obtain the initial image, and specifically implements the following steps:
and acquiring an image of the current shot object as an initial image.
In an embodiment, before the processor executes the computer program to acquire the current image of the photographed object as the initial image, the following steps are specifically implemented:
acquiring each preview size in a preset preview size list;
selecting a plurality of candidate preview sizes corresponding to the height of the preview size smaller than the height of the screen size and the width of the preview size smaller than the width of the screen size;
calculating a third ratio of width to height in each candidate preview size;
comparing each third ratio with a second ratio of width to height in the screen size to obtain a third ratio with the minimum difference value with the second ratio, and taking the candidate preview size corresponding to the third ratio as a third size;
determining the width of a second reference frame according to the width in the screen size and a preset second interval width;
determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size and the reference ratio of the width to the height in the reference size;
and drawing the second reference frame on the screen according to the width of the second reference frame and the height of the second reference frame.
In an embodiment, before the processor executes the computer program to acquire the current image of the photographed object as the initial image, the following steps are specifically implemented:
monitoring a layout change of a screen of the electronic device;
when the layout of the screen is monitored to be changed, a first value of the display state of the virtual key on the current screen and a second value of the display state of the virtual key on the screen before the layout is changed are obtained;
judging whether the first value is the same as the second value;
if not, judging that the size of the screen of the electronic equipment is changed, returning to the step of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (8)

1. A method of image generation, the method comprising:
the method comprises the steps of obtaining the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size;
determining the size of a first reference frame according to the first size and a preset reference size; determining a second size according to the size of the first reference frame, the first size and the screen size; acquiring an initial image, and cutting the initial image according to the second size to obtain a target image file;
wherein, the determining the size of the first reference frame according to the first size and a preset reference size includes: determining the width of the first reference frame according to the width of a screen in the screen size and a preset first interval width, determining the height of the first reference frame according to the width of the first reference frame, the ratio of the height in the first size to the width in the first size, the ratio of the height of the screen in the screen size to the width of the screen and a reference ratio of the width to the height in the reference size, and taking the width of the first reference frame and the height of the first reference frame as the size of the first reference frame;
the determining a second size according to the size of the first reference frame, the first size and the screen size includes: the width in the second size is determined according to the width of the first reference frame and the ratio of the height in the first size to the width in the screen size, and the height in the second size is determined according to the height of the first reference frame and the ratio of the width in the first size to the height in the screen size.
2. The method of claim 1, wherein selecting a first size matching the screen size from a list of preset image sizes according to the screen size comprises:
acquiring each photo size in the image size list;
selecting a plurality of candidate photo sizes corresponding to the height of the photo size smaller than the height of the screen size and the width of the photo size smaller than the width of the screen size;
calculating a first ratio of width to height in each candidate photo size;
and comparing each first ratio with a second ratio of the width to the height in the screen size to obtain a first ratio with the minimum difference value with the second ratio, and taking the candidate photo size corresponding to the first ratio as the first size.
3. The method of claim 1, wherein said acquiring an initial image comprises:
and acquiring an image of the current shot object as the initial image.
4. The method of claim 3, wherein prior to said capturing a current image of the subject as the initial image, the method further comprises:
acquiring each preview size in a preset preview size list;
selecting a plurality of candidate preview sizes corresponding to the height of the preview size smaller than the height of the screen size and the width of the preview size smaller than the width of the screen size;
calculating a third ratio of width to height in each candidate preview size;
comparing each third ratio with a second ratio of width to height in the screen size to obtain a third ratio with the minimum difference value with the second ratio, and taking a candidate preview size corresponding to the third ratio as a third size;
determining the width of a second reference frame according to the width in the screen size and a preset second interval width;
determining the height of the second reference frame according to the width of the second reference frame, the third size, the screen size and a reference ratio of width to height in the reference sizes;
drawing the second reference frame on a screen according to the width of the second reference frame and the height of the second reference frame;
wherein the determining the height of the second frame according to the width of the second frame, the third size, the screen size, and a reference ratio of width to height in the reference sizes comprises: and determining the height of the second reference frame according to the width of the second reference frame, the ratio of the height in the third dimension to the width in the third dimension, the ratio of the height of the screen in the screen dimension to the width of the screen and the reference ratio of the width to the height in the reference dimension.
5. The method of claim 3, wherein prior to said capturing a current image of the subject as the initial image, the method further comprises:
monitoring a layout change of a screen of the electronic device;
when the layout of the screen is monitored to be changed, a first value of the display state of the virtual key on the current screen and a second value of the display state of the virtual key on the screen before the layout is changed are obtained;
judging whether the first value is the same as the second value;
and if not, judging that the size of the screen of the electronic equipment is changed, returning to the step of acquiring the screen size of the current electronic equipment, and selecting a first size matched with the screen size from a preset image size list according to the screen size.
6. An apparatus for generating a photograph, the apparatus comprising:
the acquisition module is used for acquiring the screen size of the current electronic equipment and selecting a first size matched with the screen size from a preset image size list according to the screen size;
the first determining module is used for determining the size of the first reference frame according to the first size and a preset reference size;
the second determining module is used for determining a second size according to the size of the first reference frame, the first size and the screen size;
the cutting module is used for obtaining an initial image and cutting the initial image according to the second size to obtain a target image file;
the first determining module comprises a first determining unit, the first determining unit is used for determining the width of the first reference frame according to the width of a screen in the screen size and a preset first interval width, determining the height of the first reference frame according to the width of the first reference frame, the ratio of the height in the first size to the width in the first size, the ratio of the height of the screen in the screen size to the width of the screen and a reference ratio of the width to the height in the reference size, and taking the width of the first reference frame and the height of the first reference frame as the size of the first reference frame;
the second determination module includes a second determination unit configured to determine a width in the second size according to the width of the first reference frame and a ratio of a height in the first size to a width in the screen size, and determine a height in the second size according to the height of the first reference frame and a ratio of the width in the first size to the height in the screen size.
7. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the image generation method according to any of claims 1 to 5 are implemented by the processor when executing the computer program.
8. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the image generation method of any one of claims 1 to 5.
CN201911088732.XA 2019-11-08 2019-11-08 Image generation method and device, computer equipment and storage medium Active CN110830716B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911088732.XA CN110830716B (en) 2019-11-08 2019-11-08 Image generation method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911088732.XA CN110830716B (en) 2019-11-08 2019-11-08 Image generation method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110830716A CN110830716A (en) 2020-02-21
CN110830716B true CN110830716B (en) 2021-08-27

Family

ID=69553641

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911088732.XA Active CN110830716B (en) 2019-11-08 2019-11-08 Image generation method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110830716B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111985017B (en) * 2020-03-03 2024-04-09 广东三维家信息科技有限公司 Method and device for adapting product to wall hole and electronic equipment
CN117012099A (en) * 2020-06-29 2023-11-07 海信视像科技股份有限公司 Display equipment
CN112911152A (en) * 2021-01-29 2021-06-04 北京乐学帮网络技术有限公司 Preview image generation method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103888670A (en) * 2014-02-21 2014-06-25 联想(北京)有限公司 Information processing method and electronic device
CN105303189A (en) * 2014-07-29 2016-02-03 阿里巴巴集团控股有限公司 Method and device for detecting specific identification image in predetermined area
CN105912322A (en) * 2016-04-01 2016-08-31 乐视控股(北京)有限公司 Icon customizing method, device and terminal
CN106168874A (en) * 2016-07-07 2016-11-30 深圳艾派网络科技股份有限公司 A kind of multimedia message editing method based on webpage and device
CN107369130A (en) * 2017-06-30 2017-11-21 维沃移动通信有限公司 A kind of image processing method and terminal
CN110047053A (en) * 2019-04-26 2019-07-23 腾讯科技(深圳)有限公司 Portrait Picture Generation Method, device and computer equipment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105677018A (en) * 2015-12-28 2016-06-15 宇龙计算机通信科技(深圳)有限公司 Screen capture method and apparatus, and electronic device
CN106546581B (en) * 2016-11-02 2019-12-10 长沙云知检信息科技有限公司 Test paper detection card intelligent detection system and test paper detection card intelligent analysis method
CN110209266A (en) * 2019-04-23 2019-09-06 平安科技(深圳)有限公司 A kind of size fit method and device of image

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103888670A (en) * 2014-02-21 2014-06-25 联想(北京)有限公司 Information processing method and electronic device
CN105303189A (en) * 2014-07-29 2016-02-03 阿里巴巴集团控股有限公司 Method and device for detecting specific identification image in predetermined area
CN105912322A (en) * 2016-04-01 2016-08-31 乐视控股(北京)有限公司 Icon customizing method, device and terminal
CN106168874A (en) * 2016-07-07 2016-11-30 深圳艾派网络科技股份有限公司 A kind of multimedia message editing method based on webpage and device
CN107369130A (en) * 2017-06-30 2017-11-21 维沃移动通信有限公司 A kind of image processing method and terminal
CN110047053A (en) * 2019-04-26 2019-07-23 腾讯科技(深圳)有限公司 Portrait Picture Generation Method, device and computer equipment

Also Published As

Publication number Publication date
CN110830716A (en) 2020-02-21

Similar Documents

Publication Publication Date Title
CN110830716B (en) Image generation method and device, computer equipment and storage medium
CN111190558B (en) Screen projection control method and device, computer readable storage medium and computer equipment
EP3125135B1 (en) Picture processing method and device
KR101990089B1 (en) Method for creating for thumbnail and image an electronic device thereof
US10169900B2 (en) Picture processing method and apparatus
US20170034097A1 (en) Photo sharing method and device
US20190037138A1 (en) Method for processing image and electronic device for supporting same
CN106031159A (en) System and method to control screen capture
CN110781859A (en) Image annotation method and device, computer equipment and storage medium
CN109815970B (en) Method and device for identifying copied image, computer equipment and storage medium
CN105338237A (en) Image processing method and device
CN105391940A (en) Image recommendation method and apparatus
CN108388781B (en) Mobile terminal, image data acquisition method and related product
CN111679775B (en) Screen capture method and device, electronic equipment and computer readable storage medium
CN110659376A (en) Picture searching method and device, computer equipment and storage medium
CN111372240B (en) Picture uploading method and device, computer equipment and storage medium
US20190340410A1 (en) Electronic apparatus
CN111522476B (en) Method, device, computer device and storage medium for monitoring window switching
CN113891040A (en) Video processing method, video processing device, computer equipment and storage medium
CN109857888B (en) Image file processing method and device, computer equipment and storage medium
CN113473012A (en) Virtualization processing method and device and electronic equipment
CN113271378A (en) Image processing method and device and electronic equipment
CN112911130A (en) Auxiliary view finding method, device, terminal and storage medium
CN111352983A (en) Service attribute dynamic expansion method and device, computer equipment and storage medium
TWI581174B (en) Method and system for displaying system information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: Room 834, Yingying building, No.99, Tuanjie Road, yanchuangyuan, Jiangbei new district, Nanjing, Jiangsu Province

Applicant after: Nanjing Xingyun Digital Technology Co.,Ltd.

Address before: Room 834, Yingying building, No.99, Tuanjie Road, yanchuangyuan, Jiangbei new district, Nanjing, Jiangsu Province

Applicant before: Suning financial technology (Nanjing) Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant