CN104574264A - Picture processing method and device - Google Patents

Picture processing method and device Download PDF

Info

Publication number
CN104574264A
CN104574264A CN201310484745.5A CN201310484745A CN104574264A CN 104574264 A CN104574264 A CN 104574264A CN 201310484745 A CN201310484745 A CN 201310484745A CN 104574264 A CN104574264 A CN 104574264A
Authority
CN
China
Prior art keywords
picture
path
picture file
client
asked
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201310484745.5A
Other languages
Chinese (zh)
Inventor
胡勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Peking University Founder Group Co Ltd
Beijing Founder Electronics Co Ltd
Original Assignee
Peking University Founder Group Co Ltd
Beijing Founder Electronics 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 Peking University Founder Group Co Ltd, Beijing Founder Electronics Co Ltd filed Critical Peking University Founder Group Co Ltd
Priority to CN201310484745.5A priority Critical patent/CN104574264A/en
Publication of CN104574264A publication Critical patent/CN104574264A/en
Pending legal-status Critical Current

Links

Abstract

The invention provides a picture processing method and device. The method comprises steps as follows: a picture resource acquisition request sent by a client is received and carries a path of a to-be-requested picture file; a preset suffix in the path is deleted, and the to-be-requested picture file is acquired according to the path in which the preset suffix is deleted; the to-be-requested picture file and a pre-configured cache strategy are returned to the client, so that the client can perform cache processing on the to-be-requested picture file according to the cache strategy.

Description

Image processing method and device
Technical field
The present invention relates to computer technology, particularly relate to a kind of image processing method and device.
Background technology
Network (can be referred to as a Web) system is often at Cascading Style Sheet (Cascading StyleSheet; Be called for short: CSS) innerly use a large amount of picture, to be used for doing the background of interface element, thus make this Web system look more attractive in appearance, professional.In addition, browser is when checking webpage Web page, and figure sector-meeting passes to this locality from server, under the prerequisite that network speed is certain, picture more much larger time, page loading velocity can be caused more and more slower.In order to solve the problem, Internet Information Service (Internet Information Services can be adopted; Be called for short: IIS) technology, namely carry out buffer memory to passing to local picture from server, so that when being again applied to this picture, this picture can being obtained from buffer memory, thus effectively raise the access efficiency of the page.
But, because IIS technology needs to be configured the path of depositing of the picture preserved, therefore, when the path of depositing of the picture of Web system use is not concentrated, when disperseing very much, just need to carry out path configurations to picture one by one, thus cause the loaded down with trivial details of image cache.
Summary of the invention
The invention provides a kind of image processing method and device, for solving the loaded down with trivial details problem of image cache in prior art.
First aspect of the present invention is to provide a kind of image processing method, comprising:
Receive the picture resource acquisition request that client sends, described picture resource obtains in request the path of carrying and waiting to ask picture file;
Delete the default suffix in described path, and wait to ask picture file described in obtaining according to the path after the described default suffix of deletion;
Picture file described to be asked and pre-configured cache policy are returned to described client, for described client according to described cache policy, caching process is carried out to picture file described to be asked.
Another aspect of the present invention is to provide a kind of picture processing device, comprising:
Transceiver module, the picture resource sent for receiving client obtains request, and described picture resource obtains in request the path of carrying and waiting to ask picture file;
Processing module, for deleting the default suffix in described path, and waits to ask picture file described in obtaining according to the path after the described default suffix of deletion;
Described transceiver module, also for picture file described to be asked and pre-configured cache policy are returned to described client, for described client according to described cache policy, carries out caching process to picture file described to be asked.
Technique effect of the present invention is: receive the picture resource acquisition request that client sends, this picture resource obtains in request the path of carrying and waiting to ask picture file; Delete the default suffix in this path, and obtain this wait to ask picture file according to deleting the path after this default suffix, and this picture file to be asked and pre-configured cache policy return to client, for this client according to cache policy, caching process is carried out to the picture file of this request, to to configure one by one the picture of buffer memory relative to adopting IIS technology in prior art and deposit path, cache way is relatively simple, thus solves the loaded down with trivial details problem of image cache in prior art.
Accompanying drawing explanation
Fig. 1 is the process flow diagram of an embodiment of image processing method of the present invention;
Fig. 2 is the process flow diagram of another embodiment of image processing method of the present invention;
Fig. 3 is the structural representation of an embodiment of picture processing device of the present invention.
Embodiment
Fig. 1 is the process flow diagram of an embodiment of image processing method of the present invention, and as shown in Figure 1, the executive agent of the present embodiment is server, then the method comprises:
The picture resource that step 101, reception client send obtains request, and this picture resource carries the path of waiting to ask picture file in obtaining and asking.
In the present embodiment, the picture of the form suffix such as " .gif ", " .jpg " and " .png " can be set new access path title by client, such as, can be: " .gif.ashx ", " .jpg.ashx " and " .png.ashx ".
Step 102, the default suffix deleted in this path, and obtain this wait to ask picture file according to deleting the path after this default suffix.
In the present embodiment, this default suffix can be specially: .ashx.
Step 103, this picture file to be asked and pre-configured cache policy are returned to this client, for this client according to this cache policy, caching process is carried out to this picture file to be asked.
In the present embodiment, for example, by this picture file to be asked by http response output stream, namely in context.Response.WriteFile, client can be returned to.In addition, can also by cache policy by returning client in picture resource policy response.
In the present embodiment, receive the picture resource acquisition request that client sends, this picture resource obtains in request the path of carrying and waiting to ask picture file; Delete the default suffix in this path, and obtain this wait to ask picture file according to deleting the path after this default suffix, and this picture file to be asked and pre-configured cache policy return to client, for this client according to cache policy, caching process is carried out to the picture file of this request, to to configure one by one the picture of buffer memory relative to adopting IIS technology in prior art and deposit path, cache way is relatively simple, thus solves the loaded down with trivial details problem of image cache in prior art.
Fig. 2 is the process flow diagram of another embodiment of image processing method of the present invention, and as shown in Figure 2, the executive agent of the present embodiment is server, then the method comprises:
The picture resource that step 201, reception client send obtains request, and this picture resource carries the path of waiting to ask picture file in obtaining and asking.
Step 202, triggering process request class CachingHandler, the path that this picture resource obtains picture file to be asked in request is obtained with the ProcessRequest called in this process request class CachingHandler, and the default suffix deleted in this path, obtain this according to the path after this default suffix of deletion and wait to ask picture file.
In the present embodiment, by by the System.Web.DefaultHttpHandler given tacit consent to, self-defining CachingHandler is replaced by the process of request.Concrete, process request class CachingHandler mainly achieves interface HttpHandler, achieves attribute IsReusable and the method ProcessRequest defined in this interface.Owing to not relating to global variable, the write operation of static variable, can ensure thread-safe, and therefore, IsReusable is set to true, and such performance comparatively false will be got well.
ProcessRequest function is responsible for process picture resource and is obtained request, it passes through current context, get the path that picture resource obtains picture file to be asked in request, get rid of default suffix, such as: can be " .ashx ", to obtain this picture file to be asked, namely comprise: filename and extension name.
Step 203, this picture file to be asked and pre-configured cache policy are returned to this client, for this client according to this cache policy, caching process is carried out to this picture file to be asked.
In the present embodiment, this cache policy comprises one or several combination following: the form of instruction cache-time, instruction cache location, instruction buffer memory condition and/or the response of instruction picture resource policy.
Further, in yet another embodiment of the present invention, on above-mentioned Fig. 1 or basis embodiment illustrated in fig. 2, the method can further include:
To pre-set configuration information and send to this client, this configuration information comprises: cache-time and picture format extension name, to make this client according to this cache policy, calls this configuration information, carries out caching process to this picture file to be asked.
In the present embodiment, preferably, pre-set configuration information to arrange in the web.config file of configuration class CachingSection.
In the present embodiment, in order to improve availability, the extensibility of method, realize the MME type of the response content having which picture format and correspondence thereof in the number of days of buffer memory picture, cache file, can be configured above-mentioned information in the web.config file of web system.Configuration class, in order to store these information, defines CachingTimeSpan attribute (being used to specify cache-time) and FileExtensions array attribute (being used to specify the setting in the path that can conduct interviews to the picture file of which suffix form).Such can work after registering in web.config file, and its registration statement is as follows:
In addition, concrete parameter is defined as follows:
In addition, more preferably, the instruction cache location in cache policy can be client, also can be proxy server.Not buffer memory when instruction buffer memory condition can indicate refresh page, needs to read up-to-date picture etc.
Concrete, client, according to this cache policy, calls this configuration information, and the specific implementation of this picture file to be asked being carried out to caching process can have several as follows:
The first: is when cache policy comprises: during instruction cache-time, then client is according to this cache policy, calls this configuration information, and the specific implementation of this picture file to be asked being carried out to caching process is:
context.Response.Cache.SetExpires(DateTime.Now.Add(config.CachingTimeSpan));
The second: when cache policy comprises: during instruction cache location, then client is according to this cache policy, calls this configuration information, and the specific implementation of this picture file to be asked being carried out to caching process is:
context.Response.Cache.SetCacheability(HttpCacheability.Public);
The third: is when cache policy comprises: instruction buffer memory condition, such as, when can be instruction refresh page not buffer memory, when needing to read up-to-date picture, then client is according to this cache policy, call this configuration information, the specific implementation of this picture file to be asked being carried out to caching process is:
context.Response.Cache.SetValidUntilExpires(false);
4th kind: when cache policy comprises: during the form that instruction picture resource policy responds, then client is according to this cache policy, calls this configuration information, and the specific implementation of this picture file to be asked being carried out to caching process is:
context.Response.ContentType=fileExtension.ContentType。
One of ordinary skill in the art will appreciate that: all or part of step realizing above-mentioned each embodiment of the method can have been come by the hardware that programmed instruction is relevant.Aforesaid program can be stored in a computer read/write memory medium.This program, when performing, performs the step comprising above-mentioned each embodiment of the method; And aforesaid storage medium comprises: ROM, RAM, magnetic disc or CD etc. various can be program code stored medium.
Fig. 3 is the structural representation of an embodiment of picture processing device of the present invention, and as shown in Figure 3, the device of the present embodiment comprises: transceiver module 11 and processing module 12; Wherein, the picture resource acquisition request that transceiver module 11 sends for receiving client, this picture resource obtains in request the path of carrying and waiting to ask picture file; Processing module 12 for deleting the default suffix in this path, and obtains this wait to ask picture file according to deleting the path after this default suffix; Transceiver module 11, also for this picture file to be asked and pre-configured cache policy are returned to this client, for this client according to this cache policy, carries out caching process to this picture file to be asked.
The picture processing device of the present embodiment can perform the technical scheme of embodiment of the method shown in Fig. 1, and it is similar that it realizes principle, repeats no more herein.
In the present embodiment, receive the picture resource acquisition request that client sends, this picture resource obtains in request the path of carrying and waiting to ask picture file; Delete the default suffix in this path, and obtain this wait to ask picture file according to deleting the path after this default suffix, and this picture file to be asked and pre-configured cache policy return to client, for this client according to cache policy, caching process is carried out to the picture file of this request, to to configure one by one the picture of buffer memory relative to adopting IIS technology in prior art and deposit path, cache way is relatively simple, thus solves the loaded down with trivial details problem of image cache in prior art.
Further, in another embodiment of the present invention, on above-mentioned basis embodiment illustrated in fig. 3, processing module 12 is specifically for triggering process request class CachingHandler, the path that this picture resource obtains picture file to be asked in request is obtained with the ProcessRequest called in this process request class CachingHandler, and the default suffix deleted in this path, obtain this according to the path after this default suffix of deletion and wait to ask picture file.
Preferably, transceiver module 11 also sends to this client for pre-setting configuration information, and this configuration information comprises: cache-time and picture format extension name, to make this client according to this cache policy, call this configuration information, caching process is carried out to this picture file to be asked.
Last it is noted that above each embodiment is only in order to illustrate technical scheme of the present invention, be not intended to limit; Although with reference to foregoing embodiments to invention has been detailed description, those of ordinary skill in the art is to be understood that: it still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein some or all of technical characteristic; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the scope of various embodiments of the present invention technical scheme.

Claims (8)

1. an image processing method, is characterized in that, comprising:
Receive the picture resource acquisition request that client sends, described picture resource obtains in request the path of carrying and waiting to ask picture file;
Delete the default suffix in described path, and wait to ask picture file described in obtaining according to the path after the described default suffix of deletion;
Picture file described to be asked and pre-configured cache policy are returned to described client, for described client according to described cache policy, caching process is carried out to picture file described to be asked.
2. image processing method according to claim 1, is characterized in that, the default suffix in the described path of described deletion, comprising:
Trigger process request class CachingHandler, obtain with the ProcessRequest called in described process request class CachingHandler the path that described picture resource obtains picture file to be asked in request, and delete the default suffix in described path.
3. image processing method according to claim 1 and 2, is characterized in that, described cache policy comprises one or more combination following: the form of instruction cache-time, instruction cache location, instruction buffer memory condition and/or the response of instruction picture resource policy.
4. image processing method according to claim 3, is characterized in that, also comprises:
Configuration information will be pre-set and send to described client, described configuration information comprises: cache-time and picture format extension name, to make described client according to described cache policy, call described configuration information, caching process is carried out to picture file described to be asked.
5. image processing method according to claim 4, is characterized in that, described in pre-set configuration information configuration class CachingSection web.config file in arrange.
6. a picture processing device, is characterized in that, comprising:
Transceiver module, the picture resource sent for receiving client obtains request, and described picture resource obtains in request the path of carrying and waiting to ask picture file;
Processing module, for deleting the default suffix in described path, and waits to ask picture file described in obtaining according to the path after the described default suffix of deletion;
Described transceiver module, also for picture file described to be asked and pre-configured cache policy are returned to described client, for described client according to described cache policy, carries out caching process to picture file described to be asked.
7. picture processing device according to claim 6, it is characterized in that, described processing module is specifically for triggering process request class CachingHandler, the path that described picture resource obtains picture file to be asked in request is obtained with the ProcessRequest called in described process request class CachingHandler, and the default suffix deleted in described path, wait to ask picture file described in obtaining according to the path after the described default suffix of deletion.
8. picture processing device according to claim 7, it is characterized in that, described transceiver module also sends to described client for pre-setting configuration information, described configuration information comprises: cache-time and picture format extension name, to make described client according to described cache policy, call described configuration information, caching process is carried out to picture file described to be asked.
CN201310484745.5A 2013-10-16 2013-10-16 Picture processing method and device Pending CN104574264A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310484745.5A CN104574264A (en) 2013-10-16 2013-10-16 Picture processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310484745.5A CN104574264A (en) 2013-10-16 2013-10-16 Picture processing method and device

Publications (1)

Publication Number Publication Date
CN104574264A true CN104574264A (en) 2015-04-29

Family

ID=53090252

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310484745.5A Pending CN104574264A (en) 2013-10-16 2013-10-16 Picture processing method and device

Country Status (1)

Country Link
CN (1) CN104574264A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6389460B1 (en) * 1998-05-13 2002-05-14 Compaq Computer Corporation Method and apparatus for efficient storage and retrieval of objects in and from an object storage device
CN102684986A (en) * 2011-04-14 2012-09-19 天脉聚源(北京)传媒科技有限公司 Method and system for displaying pictures at terminal
CN102789470A (en) * 2011-05-20 2012-11-21 腾讯科技(深圳)有限公司 Method and device for uploading pictures in webpage

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6389460B1 (en) * 1998-05-13 2002-05-14 Compaq Computer Corporation Method and apparatus for efficient storage and retrieval of objects in and from an object storage device
CN102684986A (en) * 2011-04-14 2012-09-19 天脉聚源(北京)传媒科技有限公司 Method and system for displaying pictures at terminal
CN102789470A (en) * 2011-05-20 2012-11-21 腾讯科技(深圳)有限公司 Method and device for uploading pictures in webpage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
PXXLCW11: "通过HttpHandle缓存图片", 《百度文库HTTPS://WENKU.BAIDU.COM/VIEW/ C8831117CC7931B764CE1505.HTML?FROM=SEARCH》 *

Similar Documents

Publication Publication Date Title
US11153402B2 (en) Method and apparatus for automatically optimizing the loading of images in a cloud-based proxy service
US9565265B2 (en) Method and apparatus for automatically optimizing the loading of images in a cloud-based proxy service
EP2948846B1 (en) Resource calling for hybrid applications
CN107025234B (en) Information pushing method and cache server
US9277030B2 (en) Stream processing using a client-server architecture
CN105100294B (en) Obtain method, system, the webserver, browser and the GSLB of webpage
CN110096660B (en) Method and device for loading page pictures and electronic equipment
US9432484B1 (en) CIM-based data storage management system having a restful front-end
CN103338249B (en) Caching method and device
US9088462B2 (en) Common web accessible data store for client side page processing
CN102368785B (en) Network file uploading method, device and system
US11436066B2 (en) System for offline object based storage and mocking of rest responses
CN109992406B (en) Picture request method, picture request response method and client
CN106656920B (en) Processing method, device, storage medium and the processor of HTTP service
WO2019000722A1 (en) Hypertext markup language webpage loading method and device
CN106657182B (en) Cloud file processing method and device
CN102624910B (en) Method, the Apparatus and system of the web page contents that process user chooses
US20190370293A1 (en) Method and apparatus for processing information
CN106919595B (en) Cookie mapping method and device and electronic equipment
US10819822B2 (en) Method for recording metadata for web caching in cloud environment and web server using the same
CA2930061A1 (en) Variants of files in a file system
CN116150513A (en) Data processing method, device, electronic equipment and computer readable storage medium
CN107103001B (en) Method, device and system for acquiring target front-end resource file based on browser
CN104574264A (en) Picture processing method and device
CN103605795A (en) Metadata-based file storage method and device

Legal Events

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

Application publication date: 20150429