Dynamic graph generation method and device, electronic equipment and storage medium
By framing, compressing and extracting the animation images, the second animation images are generated, which solves the problem of excessive size of the animation images, and achieves the effect of efficiently reducing the file size and improving image clarity.
Patent Information
- Application Number
- CN202510197297.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-21
- Publication Date
- 2025-05-30
AI Technical Summary
The animation file is large in size, and the existing compression methods lead to loss of image clarity, which fails to effectively solve the problem of excessive animation file size.
By obtaining the target image, the first animation image is generated, the frame sequence is obtained by frame processing, the frame sequence is compressed according to the preset compression ratio, the compressed frame sequence is extracted using pixel-level comparison method, and finally the retained frame image is synthesized to generate the second animation image.
Effectively reduce the size of animation files, improve image clarity, improve user experience, and reduce storage resource usage and server bandwidth costs.
Smart Images

Figure CN120075373A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of image processing, and in particular, to a method, device, electronic device, and storage medium for generating animated images. Background Art
[0002] With the development of the Internet, the application of animated images in mobile applications and front-end web pages has become increasingly widespread, bringing a richer and more diverse visual experience to users.
[0003] However, the production of animated images often stems from video transcoding and synthesis, which inevitably leads to the problem of large animated image file sizes. Although current image formats such as webp provide methods of lossy compression and lossless compression to reduce file sizes, due to the high frame rate characteristics of animated images, their file sizes still remain at a relatively high level. In addition, excessive lossy compression will also reduce the clarity of the image, thus damaging the user experience.
[0004] In view of the above problems existing in the related art, no effective solution has been found yet. Summary of the Invention
[0005] In view of this, the embodiments of the present invention provide a method, device, electronic device, and storage medium for generating animated images to solve the above technical problems existing in the related art.
[0006] In a first aspect, the embodiments of the present invention provide a method for generating an animated image, the method comprising:
[0007] Obtain a target image, and generate a first animated image based on the target image;
[0008] Perform frame splitting on the first animated image to obtain a frame sequence;
[0009] Compress each split-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence;
[0010] Perform frame extraction on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining retained frame images in the frame-extracted compressed frame sequence;
[0011] Synthesize the retained frame images to generate a second animated image.
[0012] In a possible implementation manner, generating a first animated image based on the target image includes:
[0013] Respond to the operation of selecting an animation effect element for the target image, and determine the animation effect element in the target image;
[0014] Respond to the operation of selecting an animation effect for the animation effect element, and determine the animation effect of the animation effect element;
[0015] Generate a first animated image based on animation effect elements and animation effects.
[0016] In a possible implementation, the method further includes:
[0017] Display the first animated image on a display interface;
[0018] When responding to a first determination operation on the first animated image, perform the step of frame-dividing the first animated image to obtain a frame sequence.
[0019] In a possible implementation, frame-dividing the first animated image to obtain a frame sequence includes:
[0020] Obtain the current animation frame of the first animated image based on the animation playback state attribute;
[0021] Use a preset static rendering method to perform static rendering on the current animation frame to obtain a frame-divided image;
[0022] Jump to the next animation frame of the current animation frame through the animation delay attribute until the static rendering of each animation frame of the first animation is completed to obtain a frame sequence.
[0023] In a possible implementation, the method further includes:
[0024] Send the compressed frame sequence to the display interface for display.
[0025] In a possible implementation, decimating the compressed frame sequence according to a pixel-level comparison method includes:
[0026] For adjacent compressed frame images in the compressed frame sequence, obtain the image pixel points at each position of the compressed frame image;
[0027] Perform color comparison on the image pixel points at each position of the adjacent compressed frame images;
[0028] Determine the number of image pixel points with consistent color comparison;
[0029] Determine whether the number of image pixel points exceeds a preset number threshold;
[0030] In the case where it is determined that the number of image pixel points exceeds the preset number threshold, perform decimation processing on the duplicate compressed frame images.
[0031] In a possible implementation, the method further includes:
[0032] Highlight the remaining frame images on the display interface;
[0033] When responding to a second determination operation on the remaining frame images, perform the step of synthesizing the remaining frame images to generate a second animated image.
[0034] In a possible implementation, the retained frame images are synthesized to generate a second animated image, including
[0035] obtaining the total number of original frames, the original inter-frame delay, and the number of animation loops of the first animated image, and obtaining the total number of the first retained frames of the retained frame images;
[0036] calculating the retained frame inter-frame delay of the retained frames according to the total number of original frames, the original inter-frame delay, and the total number of the first retained frames;
[0037] synthesizing the retained frame images according to the retained frame inter-frame delay and the number of animation loops to generate a second animated image.
[0038] In a possible implementation, the method further includes:
[0039] sending the compressed frame sequence to a framed picture library for storage, and sending the second animated image to an animated image result repository for storage, and generating a download link for the second animated image, so as to obtain the second animated image from the animated image result repository according to the download link.
[0040] In a second aspect, an embodiment of the present invention provides an apparatus for generating an animated image, the apparatus includes:
[0041] an acquisition generation module, configured to acquire a target picture and generate a first animated image based on the target picture;
[0042] a framing module, configured to perform framing processing on the first animated image to obtain a frame sequence;
[0043] a compression module, configured to compress each framed image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence;
[0044] a frame extraction module, configured to perform frame extraction processing on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining retained frame images in the frame-extracted compressed frame sequence;
[0045] a generation module, configured to synthesize the retained frame images to generate a second animated image.
[0046] In a third aspect, an embodiment of the present invention provides an electronic device, which includes: a processor and a memory, and the processor is configured to execute a program for generating an animated image stored in the memory to implement the above method for generating an animated image.
[0047] In a fourth aspect, an embodiment of the present invention provides a storage medium, where the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above method for generating an animated image.
[0048] The method, device, electronic device and storage medium for generating animated pictures provided by the embodiments of the present invention, the method includes: obtaining a target picture, and generating a first animated picture based on the target picture; performing frame division processing on the first animated picture to obtain a frame sequence; compressing each sub-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence; performing frame extraction processing on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining retained frame images in the compressed frame sequence after frame extraction; synthesizing the retained frame images to generate a second animated picture. Through this application, it is possible to automatically complete processing such as compressing and extracting frames of high-frame-rate animated pictures, effectively reducing the volume of the animated picture file, and solving the technical problem of the currently too large volume of animated picture files. Description of the Drawings
[0049] Figure 1 It is a flowchart of an embodiment of a method for generating an animated picture provided by an embodiment of the present invention;
[0050] Figure 2 It is a schematic diagram of an animated picture generation interface provided by an embodiment of the present invention;
[0051] Figure 3 It is a flowchart of an embodiment of another method for generating an animated picture provided by an embodiment of the present invention;
[0052] Figure 4 It is a flowchart of an embodiment of another method for generating an animated picture provided by an embodiment of the present invention;
[0053] Figure 5 It is a flowchart of an embodiment of another method for generating an animated picture provided by an embodiment of the present invention;
[0054] Figure 6 It is a flowchart of an embodiment of another method for generating an animated picture provided by an embodiment of the present invention;
[0055] Figure 7 It is a schematic diagram of a successful animated picture production display diagram provided by an embodiment of the present invention;
[0056] Figure 8 It is a block diagram of an embodiment of a device for generating an animated picture provided by an embodiment of the present invention;
[0057] Figure 9 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Detailed Embodiments
[0058] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0059] For ease of understanding of the embodiments of the present invention, the following will further explain and illustrate with specific embodiments in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0060] The embodiments of the present invention provide a method for generating a moving picture. Refer to Figure 1 , Figure 1 which is a flowchart of an embodiment of a method for generating a moving picture provided by the embodiments of the present invention. Figure 1 The process shown may include the following steps:
[0061] Step 101, obtain a target picture and generate a first moving picture based on the target picture;
[0062] In practical applications, this method is applied to a moving picture generation system, which provides a moving picture generation interface to facilitate users to upload the target picture required for generating a moving picture to the moving picture generation system through the moving picture generation interface according to actual needs, so as to generate a first moving picture with a high frame rate.
[0063] For ease of understanding, as Figure 2 shown is the moving picture generation interface. The target picture uploaded by the user is shown in the left partition of the moving picture generation interface, and the special effects set for generating the first moving picture corresponding to the target picture are shown in the right area of the moving picture generation interface. In this embodiment, without the need for design software and complex operations, the user can directly generate a high-quality and high-frame-rate first moving picture by selecting special effects on the moving picture generation interface. Compared with the traditional moving picture production that requires professional design software and a long production cycle, this moving picture production method can greatly reduce the manual design cost, reduce the dependence on designers and developers, and significantly shorten the time from the planning to the launch of the operation activity, improving the activity execution efficiency. The specific process of generating the first moving picture using the moving picture generation interface will be specifically described in the following embodiments and will not be elaborated here.
[0064] Step 102, perform frame splitting on the first moving picture to obtain a frame sequence;
[0065] In practical applications, for ease of subsequent compression and frame extraction processing of the first moving picture, it is necessary to perform frame splitting on the first moving picture. Among them, step 102 can be implemented through steps A1 to A3:
[0066] Step A1: Obtain the current animation frame of the first animated image based on the animation play state property.
[0067] The animation play state property (animation-play-state) is an important property in CSS (Cascading Style Sheets) animations. It is used to control the play state of the animation. Specifically, this property has two values: running and paused. When the animation play state property is set to running, the animation will start or continue to play; when the animation play state property is set to paused, the animation will pause. In this embodiment, the animation play state property is set to paused. Since the first animated image has been paused, the currently displayed animation frame is the current animation frame to be obtained.
[0068] Step A2: Use a preset static rendering method to statically render the current animation frame to obtain a frame-divided image.
[0069] In specific implementation, the html2canvas library, which is a preset static rendering method, can be used to statically render the current animation frame into a static frame-divided picture. Among them, the html2canvas library can render HTML (HyperText Markup Language) elements (including animation elements) into a canvas object, and then extract image data from the canvas object and save it as a static frame-divided picture.
[0070] In specific implementation, other preset static rendering methods such as HTMLToImage and Puppeteerd can also be used to statically render the current animation frame to obtain a frame-divided image, which will not be elaborated here one by one.
[0071] Step A3: Jump to the next animation frame of the current animation frame through the animation delay property until the static rendering of each animation frame of the first animation is completed to obtain a frame sequence.
[0072] By modifying the animation delay property (animation-delay) of CSS, the start time of the animation is adjusted to the start time of the next animation frame. This usually involves setting the animation delay property to a negative value to indicate starting to play from a certain time point in the animation sequence. Repeat Step A1 to Step A2 to capture each animation frame of the first animated image frame by frame and render it as a frame-divided image. After each static rendering, update the animation delay property to point to the next animation frame until all frames in the first animation are statically rendered into frame-divided images.
[0073] Step 103: Compress each sub-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence;
[0074] Among them, the preset compression ratio can be set according to actual needs and is not limited herein. In this embodiment, by compressing each sub-frame image in the frame sequence according to the preset compression ratio, the size of the animated image file can be significantly reduced. In actual applications, the compression of the frame sequence can be achieved through the webp-converter library. Specifically, other methods such as ImageOptim, image processing libraries, command-line tools, and video editing software can also be used to compress the frame sequence, which is not limited herein.
[0075] Step 104: Perform frame extraction processing on the compressed frame sequence according to the pixel-level comparison method to obtain the remaining retained frame images in the frame-extracted compressed frame sequence;
[0076] By performing pixel-level comparison on the compressed frame sequence, frames with relatively small differences between adjacent frames are identified and these redundant frames are removed, thereby retaining key frames and reducing the length of the frame sequence to further reduce the size of the animated image file.
[0077] Step 105: Synthesize the retained frame images to generate a second animated image.
[0078] Through steps 103 to 105, a second animated image with a small volume can be automatically generated, which can be quickly loaded during use, ensuring a smooth user experience and reducing losses caused by slow loading of animated images. In addition, the second animated image with a small volume can reduce the occupation of storage resources and lower the server bandwidth cost and cloud storage cost.
[0079] Through this application, the processing such as compression and frame extraction of high-frame-rate animated images can be automatically completed, effectively reducing the volume of the animated image file and solving the technical problem of the currently too large animated image file.
[0080] As Figure 3 shown, as an alternative embodiment, for the method as described above, step 101 of generating the first animated image based on the target picture includes the following steps:
[0081] Step 301: Respond to the operation of selecting dynamic effect elements for the target picture to determine the dynamic effect elements in the target picture;
[0082] The user can select the dynamic effect elements to which the dynamic effect is desired to be added on the target picture through operations such as clicking and dragging. These dynamic effect elements can be any part of the target picture, such as characters, objects, or backgrounds, etc., which is not limited herein. As Figure 2 shown, the patterns of the horn, snap up immediately, the annual gold card at a discount of up to 5.8 folds, and the double-eleven shopping spree in the target picture can be selected as the dynamic effect elements respectively.
[0083] Step 302: In response to a dynamic effect selection operation for a dynamic effect element, determine the dynamic effect of the dynamic effect element.
[0084] After determining the dynamic effect elements, the user can select specific dynamic effects for these dynamic effect elements. The dynamic effects can include various types such as size, positioning, zooming in and out, flashing, moving, rotating, scaling, color changing, etc., which are specifically set according to actual needs and are not limited here. When responding to the user's dynamic effect selection operation, the selected dynamic effect will be associated with the corresponding dynamic effect element to facilitate the generation of animated gifs.
[0085] For ease of understanding, as Figure 2 shown, for the dynamic effect element of the speaker, dynamic effects of size and positioning are set for it, and no animation is set; for the dynamic effect element of "Grab Now", dynamic effects of size and positioning are set for it, and the animation is set to a 2-second light swipe; for the dynamic effect element of "Annual Gold Card as low as 5.8 discount", dynamic effects of size and positioning are set for it, and the animation is set to a 1-second zooming in and out; for "Double Eleven Carnival Purchase", dynamic effects of size and positioning are set for it, and no animation is set (not shown in the figure).
[0086] As Figure 2 shown, in the right area of the animated gif generation interface, in addition to setting the dynamic effects corresponding to the dynamic effect elements, the user can also set the picture name, frames per second, clarity, etc. of the target picture, which are not limited here.
[0087] Compared with the traditional animated gif production that requires professional design software and a long production cycle, through the animated gif production process of this embodiment, only by selecting the dynamic effects and dynamic effect elements, the required animated gif can be quickly generated. This animated gif production process significantly shortens the time from the planning to the launch of the operation activity, improves the activity execution efficiency, and reduces the dependence on professional design software.
[0088] Step 303: Generate a first animated gif based on the dynamic effect element and the dynamic effect.
[0089] Based on the dynamic effect elements selected by the user and the dynamic effects specified for them, an animated gif containing these dynamic effects can be generated. During the process of generating the animated gif, frame-by-frame calculation and rendering of the dynamic effect elements will be performed according to the type and parameters of the dynamic effects, so as to create a first animated gif with a smooth and coherent animation effect.
[0090] As Figure 4 shown, as an optional implementation manner, in the method as described above, step 104 for performing frame extraction processing on the compressed frame sequence according to the pixel-level comparison method includes the following steps:
[0091] Step 401: For adjacent compressed frame images in the compressed frame sequence, obtain the image pixel points at each position of the compressed frame image.
[0092] For adjacent compressed frame images in the compressed frame sequence, the animated image generation system needs to access each frame and obtain the image pixel points (i.e., pixel point color values) at each position on each compressed frame image.
[0093] Step 402: Compare the colors of the image pixel points at each position of the adjacent compressed frame images.
[0094] The animated image generation system compares whether the image pixel points at the same position on two adjacent compressed frame images are the same, i.e., whether the color values are the same, in a color comparison.
[0095] Step 403: Determine the number of image pixel points with consistent color comparison.
[0096] After comparing all corresponding image pixel points of adjacent compressed frame images, the animated image generation system counts the number of image pixel points with the same color value or with a difference within an acceptable range. This number reflects the similarity degree between adjacent compressed frame images.
[0097] Step 404: Determine whether the number of image pixel points exceeds a preset number threshold.
[0098] The user can set a preset number threshold according to actual needs to determine whether adjacent compressed frame images are similar enough to be considered duplicates. If the number of pixel points with consistent color comparison exceeds this preset number threshold, then the animated image generation system considers these two adjacent compressed frame images to be duplicates or very similar.
[0099] Step 405: In the case where it is determined that the number of image pixel points exceeds the preset number threshold, perform frame extraction on the duplicate compressed frame images.
[0100] If the animated image generation system determines that adjacent compressed frame images are duplicates, then it will perform a frame extraction operation, i.e., delete or skip these duplicate frames, to reduce redundant information in the animated image file and achieve the purpose of reducing the size of the animated image file.
[0101] In summary, by comparing the pixel point colors of adjacent compressed frame images and judging the similarity of frames based on the number of pixel points with consistent color comparison, the animated image generation system can achieve effective frame extraction processing and achieve the purpose of reducing the size of the animated image file.
[0102] As Figure 5 shown, as an optional implementation manner, for the method as described above, step 105 synthesizes the retained frame images to generate a second animated image, including the following steps:
[0103] Step 501, obtain the total number of original frames, the original inter-frame delay, and the number of animation loops of the first animated image, and obtain the total number of first reserved frames of the reserved frame images;
[0104] Considering that among the mainstream formats of current dynamic images, webp is widely supported and has a higher compression ratio, gif2webp tool is selected to transcode non-webp format gif images into webp. After the transcoding is completed, use the webpinfo tool to obtain the total number of original frames, the original inter-frame delay, and the number of animation loops of the first animated image, and temporarily store this data through global variables.
[0105] Step 502, calculate the reserved frame inter-frame delay of the reserved frames according to the total number of original frames, the original inter-frame delay, and the total number of first reserved frames;
[0106] According to the total number of original frames, the original inter-frame delay, and the total number of first reserved frames, the new time interval between the reserved frames can be calculated, that is, the reserved frame inter-frame delay. This calculation involves ratio adjustment to ensure that the playback speed of the second animated image is similar to that of the first animated image or meets specific requirements.
[0107] Step 503, synthesize the reserved frame images according to the reserved frame inter-frame delay and the number of animation loops to generate the second animated image.
[0108] Use the calculated reserved frame inter-frame delay and the number of animation loops to arrange and synthesize the reserved frame images at the new time interval to generate the second animated image in webp format. This process involves existing technical contents such as image encoding and inter-frame transition processing to ensure the smoothness and quality of the second animated image, which will not be elaborated here.
[0109] In practical applications, the webp-converter library can also be directly used to re-synthesize the reserved frame images into the second animated image in webp format. Specifically in applications, according to requirements, the second animated image can be output as animated image files in other formats such as gif and apng, which are not limited here.
[0110] On the basis of Figure 1 refer to Figure 6 , Figure 6 is the flowchart of another method embodiment for generating an animated image provided by the embodiment of the present invention. Figure 6 The shown process may include the following steps:
[0111] Step 601, obtain a target picture, and generate a first animated image based on the target picture;
[0112] Step 602, display the first animated image on the display interface;
[0113] The display interface can be the above-mentioned moving picture generation interface, or a smart terminal used by the user, such as a mobile phone, a computer, a tablet, etc., so as to facilitate the user to determine whether the first moving picture meets the requirements.
[0114] Step 603, when responding to a first determination operation on the first moving picture, perform frame splitting on the first moving picture to obtain a frame sequence;
[0115] In the case where the user determines that the first moving picture meets the requirements, that is, after the user can perform a first determination operation such as single-clicking or double-clicking on the confirmation control on the display interface, perform the process of performing frame splitting on the first moving picture to obtain a frame sequence. In the case where the user determines that the first moving picture does not meet the requirements, the step of generating the first moving picture based on the target picture can be executed again until the first moving picture is made to meet the requirements.
[0116] Step 604, compress each split-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence;
[0117] Step 605, send the compressed frame sequence to the display interface for display;
[0118] As Figure 7 shown in the figure is the successful display diagram of the moving picture production. The right side shows each compressed frame image in the compressed frame sequence.
[0119] Step 606, perform frame extraction on the compressed frame sequence according to the pixel-level comparison method to obtain the remaining retained frame images in the frame-extracted compressed frame sequence;
[0120] Step 607, highlight the retained frame images on the display interface;
[0121] As Figure 7 shown, the compressed frame images marked with a circled tick in each compressed frame image are the retained frame images. Specifically, when implementing, it is necessary to first obtain the frame numbers of the retained frame images, then query the compressed frame images in the compressed frame sequence with the same frame numbers as the retained frame images, and finally, perform prominent display of the found compressed frame images with preset identifiers (identifiers such as circled ticks, ticks, circles, etc., which are not limited here) to indicate that they are retained frame images.
[0122] Step 608, when responding to a second determination operation on the retained frame images, synthesize the retained frame images to generate a second moving picture;
[0123] When the user determines that the retained frame image is correct, that is, after the user can perform a second confirmation operation such as single-clicking or double-clicking on the confirmation control on the display interface, the retained frame images are synthesized to generate a second animated image. When the user determines that the retained frame image is incorrect, the step of performing frame extraction processing on the compressed frame sequence according to the pixel-level comparison method can be executed again to obtain the remaining retained frame images in the compressed frame sequence after frame extraction until the retained frame image is correct.
[0124] Step 609: Send the compressed frame sequence to the framed picture library for storage, and send the second animated image to the animated image result storage library for storage, and generate a download link for the second animated image so that the second animated image can be obtained from the animated image result storage library according to the download link.
[0125] The animated image generation system includes the above-mentioned framed picture library and animated image result storage library, so as to store the compressed frame sequence in the framed picture library and store the second animated image in the animated image result storage library to ensure the security and manageability of the data.
[0126] In actual application, the user can obtain the second animated image from the animated image result storage library through the download link at any time and place for use, enhancing the flexibility and availability of the data. For ease of understanding, as Figure 7 shown, the download link is displayed in the form of an animated image download control, and when the user clicks on the control, the second animated image can be browsed and displayed in the left area of the animated image production success display diagram.
[0127] See Figure 8 , a device for generating an animated image provided by an embodiment of the present invention. The device includes:
[0128] An acquisition and generation module 801, configured to acquire a target picture and generate a first animated image based on the target picture;
[0129] A framing module 802, configured to perform framing processing on the first animated image to obtain a frame sequence;
[0130] A compression module 803, configured to compress each framed image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence;
[0131] A frame extraction module 804, configured to perform frame extraction processing on the compressed frame sequence according to the pixel-level comparison method to obtain the remaining retained frame images in the compressed frame sequence after frame extraction;
[0132] A generation module 805, configured to synthesize the retained frame images to generate a second animated image.
[0133] The device for generating animated images provided by the embodiment of the present invention includes: acquiring a target image and generating a first animated image based on the target image; performing frame division processing on the first animated image to obtain a frame sequence; compressing each sub-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence; performing frame extraction processing on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining retained frame images in the compressed frame sequence after frame extraction; and synthesizing the retained frame images to generate a second animated image. Through this application, it is possible to automatically complete processing such as compressing and extracting frames of a high-frame-rate animated image, effectively reducing the volume of the animated image file, and solving the technical problem of the currently too large volume of animated image files.
[0134] Figure 9 It is a schematic structural diagram of an electronic device provided by the embodiment of the present invention. Figure 9 The illustrated electronic device 1200 includes: at least one processor 1201, a memory 1202, at least one network interface 1204, and other user interfaces 1203. Each component in the electronic device 1200 is coupled together through a bus system 1205. It can be understood that the bus system 1205 is used to realize the connection and communication between these components. In addition to including a data bus, the bus system 1205 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 9 all kinds of buses are labeled as the bus system 1205.
[0135] Among them, the user interface 1203 may include a display, a keyboard, or a pointing device (such as a mouse, a trackball, a touchpad, or a touch screen, etc.).
[0136] It can be understood that the memory 1202 in the embodiments of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synch link dynamic random access memory (SLDRAM), and direct rambus random access memory (DRRAM). The memory 1202 described herein is intended to include but not be limited to these and any other suitable types of memory.
[0137] In some embodiments, the memory 1202 stores the following elements, executable units or data structures, or subsets or supersets thereof: an operating system 12021 and an application program 12022.
[0138] Among them, the operating system 12021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., and is used to implement various basic services and process hardware-based tasks. The application program 12022 includes various application programs, such as a media player and a browser, etc., and is used to implement various application services. The program for implementing the method of the embodiments of the present invention can be included in the application program 12022.
[0139] In the embodiments of the present invention, by invoking the programs or instructions stored in the memory 1202, specifically, the programs or instructions stored in the application program 12022, the processor 1201 is used to execute the method steps provided in the embodiments of each method.
[0140] The method disclosed in the embodiments of the present invention above can be applied to the processor 1201 or implemented by the processor 1201. The processor 1201 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in hardware or instructions in software form in the processor 1201. The above-mentioned processor 1201 may be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present invention can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software units in the decoding processor. The software unit may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 1202, and the processor 1201 reads the information in the memory 1202 and combines its hardware to complete the steps of the above method.
[0141] It can be understood that these embodiments described herein can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or a combination thereof.
[0142] For software implementation, the techniques described herein can be implemented by units that execute the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented within the processor or external to the processor.
[0143] The electronic device provided in this embodiment may be the electronic device shown in Figure 9 and can execute all steps of the method for generating animated pictures, thereby achieving the technical effects of the method for generating animated pictures. For specific details, please refer to the relevant descriptions of the above embodiments. For the sake of brevity, it will not be elaborated here.
[0144] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). One or more programs are stored in this storage medium. Among them, the storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk or solid-state drive; the memory may also include a combination of the above types of memory.
[0145] When one or more programs in the storage medium can be executed by one or more processors to implement the above method for generating animated pictures.
[0146] The processor is used to execute the program for generating animated pictures stored in the memory to implement the steps of the method for generating animated pictures.
[0147] Those skilled in the art should further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.
[0148] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be implemented by hardware, software modules executed by a processor, or a combination of the two. The software module can be placed in random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0149] The specific embodiments described above further elaborate on the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above is only the specific embodiment of the present invention and is not used to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for generating a dynamic image, characterized in that: The method comprises: Acquire a target image, and generate a first animated image based on the target image; Performing frame processing on the first moving picture to obtain a frame sequence; Compressing each frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence; Performing frame extraction processing on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining retained frame images in the compressed frame sequence after frame extraction; The retained frame images are synthesized to generate a second moving picture.
2. The method according to claim 1, characterized in that The generating a first animated image based on the target image includes: In response to a motion effect element selection operation on the target image, determining a motion effect element in the target image; In response to a motion effect selection operation for the motion effect element, determining a motion effect of the motion effect element; A first animated image is generated based on the animation element and the animation.
3. The method according to claim 1, characterized in that: The method further comprises: Displaying the first animated image on a display interface; In response to a first determination operation on the first animated image, the step of performing frame processing on the first animated image to obtain a frame sequence is performed.
4. The method according to claim 1, characterized in that: The step of performing frame processing on the first moving picture to obtain a frame sequence includes: Obtaining a current animation frame of the first animated image based on an animation play state attribute; Performing static rendering on the current animation frame using a preset static rendering method to obtain the framed image; The animation delay attribute is used to jump to the next animation frame of the current animation frame until the static rendering of each animation frame of the first animation is completed to obtain a frame sequence.
5. The method according to claim 3, characterized in that: The method further comprises: The compressed frame sequence is sent to the display interface for display.
6. The method according to claim 3, characterized in that The step of performing frame extraction processing on the compressed frame sequence according to the pixel level comparison method includes: For adjacent compressed frame images in the compressed frame sequence, obtaining image pixel points at various positions of the compressed frame images; Performing color comparison on image pixels at each position of adjacent compressed frame images; Determine the number of image pixels with consistent color matching; Determining whether the number of pixels in the image exceeds a preset number threshold; When it is determined that the number of pixel points of the image exceeds the preset number threshold, frame extraction is performed on the repeated compressed frame images.
7. The method according to claim 3, characterized in that The method further comprises: Highlighting the retained frame image on the display interface; In response to a second determination operation on the retained frame image, the step of synthesizing the retained frame image to generate a second moving picture is performed.
8. The method according to claim 1, characterized in that The synthesizing of the retained frame images to generate a second moving picture includes: Obtaining the total number of original frames, the delay between original frames, and the number of animation cycles of the first animated image, and obtaining the total number of first retained frames of the retained frame image; Calculating a reserved inter-frame delay of the reserved frames according to the total number of original frames, the original inter-frame delay and the first total number of reserved frames; The retained frame images are synthesized according to the retained inter-frame delay and the number of animation cycles to generate a second animated image.
9. The method according to claim 1, characterized in that: The method further comprises: The compressed frame sequence is sent to a frame image library for storage, and the second animated image is sent to a dynamic image result storage library for storage, and a download link for the second animated image is generated so as to obtain the second animated image from the dynamic image result storage library according to the download link.
10. A device for generating a moving picture, characterized in that: The device comprises: An acquisition generation module is used to acquire a target image and generate a first animated image based on the target image; A frame division module, used for performing frame division processing on the first moving picture to obtain a frame sequence; A compression module, used for compressing each sub-frame image in the frame sequence according to a preset compression ratio to obtain a compressed frame sequence; A frame extraction module, used for performing frame extraction processing on the compressed frame sequence according to a pixel-level comparison method to obtain the remaining reserved frame images in the compressed frame sequence after frame extraction; A generation module is used to synthesize the retained frame image to generate a second moving picture.
11. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is used to execute a program for generating a dynamic image stored in the memory to implement the method for generating a dynamic image according to any one of claims 1 to 9.
12. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the method for generating a dynamic image according to any one of claims 1 to 9.