2 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3 * Copyright (C) 2005 Atsushi Konno All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include "chxj_img_conv_format.h"
20 #include "chxj_specified_device.h"
21 #include "chxj_str_util.h"
22 #include "chxj_qr_code.h"
23 #include "chxj_apply_convrule.h"
24 #include "qs_parse_string.h"
26 #include "http_core.h"
28 #include <wand/magick_wand.h>
30 #define EXIT_MAGICK_ERROR() \
32 char *description; ExceptionType severity; \
33 description=MagickGetException(magick_wand,&severity); \
34 ap_log_rerror(APLOG_MARK,APLOG_DEBUG, 0, r,"%s %s %d %s\n",__FILE__,(__func__),__LINE__,description); \
35 description=(char *) MagickRelinquishMemory(description); \
36 DestroyMagickWand(magick_wand); \
39 typedef enum img_conv_mode_t {
40 IMG_CONV_MODE_NORMAL = 0,
41 IMG_CONV_MODE_THUMBNAIL,
42 IMG_CONV_MODE_WALLPAPER,
46 /*----------------------------------------------------------------------------*/
47 /* User-Agent use flag */
48 /*----------------------------------------------------------------------------*/
49 typedef enum _ua_use_flag_t {
50 UA_USE=0, /* User-Agent is used. */
51 UA_IGN, /* User-Agent is disregarded. */
54 /*----------------------------------------------------------------------------*/
55 /* Request parameter maintenance structure */
56 /*----------------------------------------------------------------------------*/
57 typedef struct _query_string_param_t {
60 ua_use_flag_t ua_flag;
62 char* name; /* for EZGET */
63 long offset; /* for EZGET */
64 long count; /* for EZGET */
67 } query_string_param_t;
69 /*----------------------------------------------------------------------------*/
70 /* Device_spec when User-Agent is disregarded */
71 /*----------------------------------------------------------------------------*/
72 static device_table v_ignore_spec = {
93 /*----------------------------------------------------------------------------*/
94 /* CRC calculation table for AU */
95 /*----------------------------------------------------------------------------*/
96 static unsigned short AU_CRC_TBL[256] = {
97 0x0000,0x1021,0x2042,0x3063,0x4084,0x50A5,0x60C6,0x70E7,
98 0x8108,0x9129,0xA14A,0xB16B,0xC18C,0xD1AD,0xE1CE,0xF1EF,
99 0x1231,0x0210,0x3273,0x2252,0x52B5,0x4294,0x72F7,0x62D6,
100 0x9339,0x8318,0xB37B,0xA35A,0xD3BD,0xC39C,0xF3FF,0xE3DE,
101 0x2462,0x3443,0x0420,0x1401,0x64E6,0x74C7,0x44A4,0x5485,
102 0xA56A,0xB54B,0x8528,0x9509,0xE5EE,0xF5CF,0xC5AC,0xD58D,
103 0x3653,0x2672,0x1611,0x0630,0x76D7,0x66F6,0x5695,0x46B4,
104 0xB75B,0xA77A,0x9719,0x8738,0xF7DF,0xE7FE,0xD79D,0xC7BC,
105 0x48C4,0x58E5,0x6886,0x78A7,0x0840,0x1861,0x2802,0x3823,
106 0xC9CC,0xD9ED,0xE98E,0xF9AF,0x8948,0x9969,0xA90A,0xB92B,
107 0x5AF5,0x4AD4,0x7AB7,0x6A96,0x1A71,0x0A50,0x3A33,0x2A12,
108 0xDBFD,0xCBDC,0xFBBF,0xEB9E,0x9B79,0x8B58,0xBB3B,0xAB1A,
109 0x6CA6,0x7C87,0x4CE4,0x5CC5,0x2C22,0x3C03,0x0C60,0x1C41,
110 0xEDAE,0xFD8F,0xCDEC,0xDDCD,0xAD2A,0xBD0B,0x8D68,0x9D49,
111 0x7E97,0x6EB6,0x5ED5,0x4EF4,0x3E13,0x2E32,0x1E51,0x0E70,
112 0xFF9F,0xEFBE,0xDFDD,0xCFFC,0xBF1B,0xAF3A,0x9F59,0x8F78,
113 0x9188,0x81A9,0xB1CA,0xA1EB,0xD10C,0xC12D,0xF14E,0xE16F,
114 0x1080,0x00A1,0x30C2,0x20E3,0x5004,0x4025,0x7046,0x6067,
115 0x83B9,0x9398,0xA3FB,0xB3DA,0xC33D,0xD31C,0xE37F,0xF35E,
116 0x02B1,0x1290,0x22F3,0x32D2,0x4235,0x5214,0x6277,0x7256,
117 0xB5EA,0xA5CB,0x95A8,0x8589,0xF56E,0xE54F,0xD52C,0xC50D,
118 0x34E2,0x24C3,0x14A0,0x0481,0x7466,0x6447,0x5424,0x4405,
119 0xA7DB,0xB7FA,0x8799,0x97B8,0xE75F,0xF77E,0xC71D,0xD73C,
120 0x26D3,0x36F2,0x0691,0x16B0,0x6657,0x7676,0x4615,0x5634,
121 0xD94C,0xC96D,0xF90E,0xE92F,0x99C8,0x89E9,0xB98A,0xA9AB,
122 0x5844,0x4865,0x7806,0x6827,0x18C0,0x08E1,0x3882,0x28A3,
123 0xCB7D,0xDB5C,0xEB3F,0xFB1E,0x8BF9,0x9BD8,0xABBB,0xBB9A,
124 0x4A75,0x5A54,0x6A37,0x7A16,0x0AF1,0x1AD0,0x2AB3,0x3A92,
125 0xFD2E,0xED0F,0xDD6C,0xCD4D,0xBDAA,0xAD8B,0x9DE8,0x8DC9,
126 0x7C26,0x6C07,0x5C64,0x4C45,0x3CA2,0x2C83,0x1CE0,0x0CC1,
127 0xEF1F,0xFF3E,0xCF5D,0xDF7C,0xAF9B,0xBFBA,0x8FD9,0x9FF8,
128 0x6E17,0x7E36,0x4E55,0x5E74,0x2E93,0x3EB2,0x0ED1,0x1EF0
131 /*----------------------------------------------------------------------------*/
132 /* Download page for AU */
133 /*----------------------------------------------------------------------------*/
134 static const char* HDML_FIRST_PAGE =
135 "<HDML VERSION=3.0 TTL=0 PUBLIC=TRUE>\r\n"
137 " <ACTION TYPE=ACCEPT TASK=GOSUB DEST=\"device:data/dnld?url=%s&name=%s%s&size=%ld&disposition=%s&title=%s\">\r\n"
141 static const char* HDML_SUCCESS_PAGE =
142 "<HDML VERSION=3.0 TTL=0 PUBLIC=TRUE>\r\n"
144 " <ACTION TYPE=ACCEPT TASK=RETURN>\r\n"
145 " \x83\x5f\x83\x45\x83\x93\x83\x8d\x81\x5b\x83\x68\x82\xc9\x90\xac\x8c\xf7\x82\xb5\x82\xdc\x82\xb5\x82\xbd\r\n"
149 static const char* HDML_FAIL_PAGE =
150 "<HDML VERSION=3.0 TTL=0 PUBLIC=TRUE>\r\n"
152 " <ACTION TYPE=ACCEPT TASK=RETURN>\r\n"
153 " \x83\x5f\x83\x45\x83\x93\x83\x8d\x81\x5b\x83\x68\x82\xc9\x8e\xb8\x94\x73\x82\xb5\x82\xdc\x82\xb5\x82\xbd\r\n"
157 /*----------------------------------------------------------------------------*/
158 /* Prototype declaration */
159 /*----------------------------------------------------------------------------*/
160 static char* s_create_workfile( request_rec*, mod_chxj_config* ,
162 query_string_param_t*);
163 static apr_status_t s_create_cache_file(request_rec* r,
167 query_string_param_t *qsp);
168 static apr_status_t s_send_cache_file( device_table* spec,
169 query_string_param_t* query_string,
171 const char* tmpfile);
172 static apr_status_t s_header_only_cache_file(
174 query_string_param_t* query_string,
176 const char* tmpfile);
177 static query_string_param_t* s_get_query_string_param(request_rec *r);
178 static unsigned short s_add_crc( const char* writedata,
179 apr_size_t witebyte);
180 static MagickWand* s_fixup_size(MagickWand* ,
183 query_string_param_t *qsp);
184 static MagickWand* s_fixup_color(MagickWand* magick_wand,
187 img_conv_mode_t mode);
188 static MagickWand* s_fixup_depth(MagickWand* magick_wand,
189 request_rec* r, device_table* spec);
190 static MagickWand* s_img_down_sizing(MagickWand* magick_wand,
191 request_rec* r, device_table* spec);
192 static MagickWand* s_add_copyright(
193 MagickWand* magick_wand,
196 static char* s_create_blob_data(request_rec* r,
198 query_string_param_t *qsp,
202 static int s_img_conv_format_from_file(
204 mod_chxj_config* conf,
205 const char* user_agent,
206 query_string_param_t* qsp,
210 chxj_img_conv_format_handler(request_rec* r)
212 mod_chxj_config* conf;
213 query_string_param_t* qsp;
216 chxjconvrule_entry* entryp;
218 if ((*r->handler != 'c' && *r->handler != 'C')
219 || (strcasecmp(r->handler, "chxj-picture")
220 && strcasecmp(r->handler, "chxj-qrcode")))
223 qsp = s_get_query_string_param(r);
224 conf = ap_get_module_config(r->per_dir_config, &chxj_module);
226 if (strcasecmp(r->handler, "chxj-qrcode") == 0 && conf->image == CHXJ_IMG_OFF)
230 /*------------------------------------------------------------------------*/
231 /* get UserAgent from http header */
232 /*------------------------------------------------------------------------*/
233 /*--------------------------------------------------------------------------*/
234 /* User-Agent to spec */
235 /*--------------------------------------------------------------------------*/
236 if (qsp->user_agent) {
237 user_agent = apr_pstrdup(r->pool, qsp->user_agent);
240 entryp = chxj_apply_convrule(r, conf->convrules);
241 if (entryp && entryp->user_agent) {
242 user_agent = (char*)apr_table_get(r->headers_in, "CHXJ_HTTP_USER_AGENT");
245 user_agent = (char*)apr_table_get(r->headers_in, "User-Agent");
251 if (qsp->ua_flag == UA_IGN)
252 spec = &v_ignore_spec;
254 spec = chxj_specified_device(r, user_agent);
256 DBG1(r,"found device_name=[%s]", spec->device_name);
257 DBG1(r,"User-Agent=[%s]", user_agent);
259 if (spec->width == 0 || spec->heigh == 0)
262 return s_img_conv_format_from_file(r, conf, user_agent, qsp, spec);
268 * It converts it from ImageData corresponding to each model.
271 * @param src [i] It is former image binary data.
272 * @param len [i/o] It is length of former image binary data.
275 chxj_exchange_image(request_rec *r, const char** src, apr_size_t* len)
277 mod_chxj_config* conf;
278 query_string_param_t* qsp;
282 chxjconvrule_entry* entryp;
285 qsp = s_get_query_string_param(r);
286 conf = ap_get_module_config(r->per_dir_config, &chxj_module);
288 /*--------------------------------------------------------------------------*/
289 /* User-Agent to spec */
290 /*--------------------------------------------------------------------------*/
291 if (qsp->user_agent) {
292 user_agent = apr_pstrdup(r->pool, qsp->user_agent);
295 entryp = chxj_apply_convrule(r, conf->convrules);
296 if (entryp && entryp->user_agent) {
297 user_agent = (char*)apr_table_get(r->headers_in, "CHXJ_HTTP_USER_AGENT");
300 user_agent = (char*)apr_table_get(r->headers_in, "User-Agent");
304 if (qsp->ua_flag == UA_IGN)
305 spec = &v_ignore_spec;
307 spec = chxj_specified_device(r, user_agent);
309 DBG1(r,"found device_name=[%s]", spec->device_name);
310 DBG1(r, "User-Agent=[%s]", user_agent);
312 if (spec->width == 0 || spec->heigh == 0)
315 dst = s_create_blob_data(r, spec, qsp, (char*)*src, len);
323 s_img_conv_format_from_file(
325 mod_chxj_config* conf,
326 const char* user_agent,
327 query_string_param_t* qsp,
332 apr_finfo_t cache_st;
335 /*--------------------------------------------------------------------------*/
336 /* Create Workfile Name */
337 /*--------------------------------------------------------------------------*/
338 tmpfile = s_create_workfile(r, conf, user_agent, qsp);
339 DBG1(r,"workfile=[%s]", tmpfile);
341 rv = apr_stat(&st, r->filename, APR_FINFO_MIN, r->pool);
342 if (rv != APR_SUCCESS)
343 return HTTP_NOT_FOUND;
346 DBG1(r,"found [%s]", r->filename);
347 rv = apr_stat(&cache_st, tmpfile, APR_FINFO_MIN, r->pool);
348 DBG1(r,"found [%s]", r->filename);
350 if (rv != APR_SUCCESS || cache_st.ctime < st.mtime) {
351 /*------------------------------------------------------------------------*/
352 /* It tries to make the cash file when it doesn't exist or there is */
353 /* change time later since the making time of the cash file. */
354 /*------------------------------------------------------------------------*/
355 rv = s_create_cache_file(r,tmpfile, spec, &st, qsp);
360 DBG1(r,"color=[%d]", spec->color);
361 if (! r->header_only) {
362 rv = s_send_cache_file(spec, qsp,r, tmpfile);
367 rv = s_header_only_cache_file(spec, qsp, r, tmpfile);
372 DBG(r,"end chxj_img_conv_format");
379 s_create_cache_file(request_rec* r,
383 query_string_param_t *qsp)
387 apr_size_t writebyte;
389 img_conv_mode_t mode = qsp->mode;
391 char* writedata = NULL;
392 char* readdata = NULL;
397 MagickWand* magick_wand;
399 if ((*r->handler == 'c' || *r->handler == 'C')
400 && strcasecmp(r->handler, "chxj-qrcode") == 0) {
401 /*------------------------------------------------------------------------*/
402 /* QRCODEÍѤΥե¡¥¤¥ë¤Î¾ì¹ç */
403 /*------------------------------------------------------------------------*/
409 memset(&doc, 0, sizeof(Doc));
410 memset(&qrcode, 0, sizeof(qr_code_t));
412 doc.parse_mode = PARSE_MODE_CHTML;
416 qs_init_malloc(&doc);
418 root = qs_parse_file(&doc, r->filename);
420 chxj_qrcode_node_to_qrcode(&qrcode, root);
422 qs_all_free(&doc,QX_LOGMARK);
424 sts = chxj_qrcode_create_image_data(&qrcode, &readdata, &readbyte);
426 ERR(r, "qrcode create failed.");
431 /*------------------------------------------------------------------------*/
432 /* Ä̾ï¤Î¥¤¥á¡¼¥¸¥Õ¥¡¥¤¥ë¤Î¾ì¹ç */
433 /*------------------------------------------------------------------------*/
434 rv = apr_file_open(&fin,
436 APR_READ|APR_BINARY ,
439 if (rv != APR_SUCCESS) {
440 DBG1(r,"file open failed.[%s]", r->filename);
441 return HTTP_NOT_FOUND;
444 readdata = apr_palloc(r->pool, st->size);
445 rv = apr_file_read_full(fin, (void*)readdata, st->size, &readbyte);
446 if (rv != APR_SUCCESS || readbyte != st->size) {
447 DBG1(r,"file read failed.[%s]", r->filename);
450 return HTTP_NOT_FOUND;
453 DBG(r,"start img convert");
456 magick_wand = NewMagickWand();
457 if (MagickReadImageBlob(magick_wand,readdata, readbyte) == MagickFalse) {
459 return HTTP_NOT_FOUND;
463 * The size of the image is changed.
465 DBG(r,"call s_fixup_size()");
467 if ((magick_wand = s_fixup_size(magick_wand, r, spec, qsp)) == NULL)
468 return HTTP_NOT_FOUND;
471 * The colors of the image is changed.
473 DBG(r,"call s_fixup_color()");
475 if ((magick_wand = s_fixup_color(magick_wand, r,spec, mode)) == NULL)
476 return HTTP_NOT_FOUND;
479 * DEPTH of the image is changed.
481 DBG(r,"call s_fixup_depth()");
483 if ((magick_wand = s_fixup_depth(magick_wand, r, spec)) == NULL)
484 return HTTP_NOT_FOUND;
488 DBG(r,"start convert and compression");
490 if (spec->available_jpeg) {
491 if (MagickSetImageCompression(magick_wand,JPEGCompression) == MagickFalse) {
493 return HTTP_NOT_FOUND;
496 if (MagickSetImageFormat(magick_wand, "jpg") == MagickFalse) {
498 return HTTP_NOT_FOUND;
501 if (MagickStripImage(magick_wand) == MagickFalse) {
503 return HTTP_NOT_FOUND;
506 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
507 return HTTP_NOT_FOUND;
509 r->content_type = apr_psprintf(r->pool, "image/jpeg");
510 DBG(r,"convert to jpg");
513 if (spec->available_png) {
515 if (MagickSetImageCompression(magick_wand,ZipCompression) == MagickFalse) {
517 return HTTP_NOT_FOUND;
520 if (MagickSetImageFormat(magick_wand, "png") == MagickFalse) {
522 return HTTP_NOT_FOUND;
525 if (MagickStripImage(magick_wand) == MagickFalse) {
527 return HTTP_NOT_FOUND;
530 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
531 return HTTP_NOT_FOUND;
533 r->content_type = apr_psprintf(r->pool, "image/png");
534 DBG(r, "convert to png");
537 if (spec->available_gif) {
539 if (MagickSetImageCompression(magick_wand,LZWCompression) == MagickFalse) {
541 return HTTP_NOT_FOUND;
544 if (MagickSetImageFormat(magick_wand, "gif") == MagickFalse) {
546 return HTTP_NOT_FOUND;
549 if (MagickStripImage(magick_wand) == MagickFalse) {
551 return HTTP_NOT_FOUND;
554 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
555 return HTTP_NOT_FOUND;
557 r->content_type = apr_psprintf(r->pool, "image/gif");
559 DBG(r,"convert to gif");
562 if (spec->available_bmp2 || spec->available_bmp4) {
564 if (MagickSetImageCompression(magick_wand,NoCompression) == MagickFalse) {
566 return HTTP_NOT_FOUND;
569 if (MagickSetImageFormat(magick_wand, "bmp") == MagickFalse) {
571 return HTTP_NOT_FOUND;
574 if (MagickStripImage(magick_wand) == MagickFalse) {
576 return HTTP_NOT_FOUND;
579 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
580 return HTTP_NOT_FOUND;
582 r->content_type = apr_psprintf(r->pool, "image/bmp");
584 DBG(r, "convert to bmp(unsupported)");
588 * Add Comment (Copyright and so on.)
590 DBG(r, "call s_add_copyright()");
592 if ((magick_wand = s_add_copyright(magick_wand, r, spec)) == NULL)
593 return HTTP_NOT_FOUND;
595 writedata = (char*)MagickGetImageBlob(magick_wand, &writebyte);
598 DestroyMagickWand(magick_wand);
599 ERR1(r,"convert failure to Jpeg [%s]", tmpfile);
601 return HTTP_INTERNAL_SERVER_ERROR;
604 DBG(r, "end convert and compression");
607 rv = apr_file_open(&fout, tmpfile,
608 APR_WRITE| APR_CREATE | APR_BINARY | APR_SHARELOCK ,APR_OS_DEFAULT,
610 if (rv != APR_SUCCESS) {
611 DestroyMagickWand(magick_wand);
612 ERR1(r,"file open error.[%s]", tmpfile);
613 return HTTP_INTERNAL_SERVER_ERROR;
616 rv = apr_file_write(fout, (void*)writedata, &writebyte);
617 if (rv != APR_SUCCESS) {
618 DestroyMagickWand(magick_wand);
619 apr_file_close(fout);
620 return HTTP_INTERNAL_SERVER_ERROR;
624 * CRC is added for AU for EzGET.
626 if (spec->html_spec_type == CHXJ_SPEC_XHtml_Mobile_1_0
627 || spec->html_spec_type == CHXJ_SPEC_Hdml ) {
629 crc = s_add_crc(writedata, writebyte);
631 rv = apr_file_putc((crc >> 8) & 0xff, fout);
632 if (rv != APR_SUCCESS) {
633 DestroyMagickWand(magick_wand);
634 return HTTP_INTERNAL_SERVER_ERROR;
637 rv = apr_file_putc( crc & 0xff, fout);
638 if (rv != APR_SUCCESS) {
639 DestroyMagickWand(magick_wand);
640 return HTTP_INTERNAL_SERVER_ERROR;
644 DestroyMagickWand(magick_wand);
646 rv = apr_file_close(fout);
647 if (rv != APR_SUCCESS) {
648 DBG1(r,"file write error.[%s]", tmpfile);
649 return HTTP_INTERNAL_SERVER_ERROR;
657 s_create_blob_data(request_rec* r,
659 query_string_param_t *qsp,
663 apr_size_t writebyte;
665 img_conv_mode_t mode = qsp->mode;
667 char* writedata = NULL;
670 MagickWand* magick_wand;
672 magick_wand = NewMagickWand();
674 if (MagickReadImageBlob(magick_wand,indata, *len) == MagickFalse) {
680 * The size of the image is changed.
682 DBG(r, "call s_fixup_size()");
684 if ((magick_wand = s_fixup_size(magick_wand, r, spec, qsp)) == NULL)
688 * The colors of the image is changed.
690 DBG(r, "call s_fixup_color()");
692 if ((magick_wand = s_fixup_color(magick_wand, r,spec, mode)) == NULL)
696 * DEPTH of the image is changed.
699 DBG(r,"call s_fixup_depth()");
701 if ((magick_wand = s_fixup_depth(magick_wand, r, spec)) == NULL)
706 DBG(r,"start convert and compression");
708 if (spec->available_jpeg) {
709 if (MagickSetImageCompression(magick_wand,JPEGCompression) == MagickFalse) {
714 if (MagickSetImageFormat(magick_wand, "jpg") == MagickFalse) {
719 if (MagickStripImage(magick_wand) == MagickFalse) {
724 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
727 r->content_type = apr_psprintf(r->pool, "image/jpeg");
729 DBG(r, "convert to jpg");
732 if (spec->available_png) {
733 if (MagickSetImageCompression(magick_wand,ZipCompression) == MagickFalse) {
738 if (MagickSetImageFormat(magick_wand, "png") == MagickFalse) {
743 if (MagickStripImage(magick_wand) == MagickFalse) {
748 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
751 r->content_type = apr_psprintf(r->pool, "image/png");
753 DBG(r,"convert to png");
756 if (spec->available_gif) {
758 if (MagickSetImageCompression(magick_wand,LZWCompression) == MagickFalse) {
763 if (MagickSetImageFormat(magick_wand, "gif") == MagickFalse) {
768 if (MagickStripImage(magick_wand) == MagickFalse) {
773 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
776 r->content_type = apr_psprintf(r->pool, "image/gif");
778 DBG(r,"convert to gif");
781 if (spec->available_bmp2 || spec->available_bmp4) {
782 if (MagickSetImageCompression(magick_wand,NoCompression) == MagickFalse) {
787 if (MagickSetImageFormat(magick_wand, "bmp") == MagickFalse) {
792 if (MagickStripImage(magick_wand) == MagickFalse) {
797 if ((magick_wand = s_img_down_sizing(magick_wand, r, spec)) == NULL)
800 r->content_type = apr_psprintf(r->pool, "image/bmp");
802 DBG(r,"convert to bmp(unsupported)");
804 /*--------------------------------------------------------------------------*/
805 /* Add Comment (Copyright and so on.) */
806 /*--------------------------------------------------------------------------*/
807 DBG(r,"call s_add_copyright()");
809 if ((magick_wand = s_add_copyright(magick_wand, r, spec)) == NULL)
812 writedata = (char*)MagickGetImageBlob(magick_wand, &writebyte);
815 DestroyMagickWand(magick_wand);
816 DBG(r,"convert failure to Jpeg ");
820 DBG(r,"end convert and compression");
824 dst = apr_palloc(r->pool, writebyte+2);
826 memcpy(dst, writedata, writebyte);
827 /*--------------------------------------------------------------------------*/
828 /* CRC is added for AU for EzGET. */
829 /*--------------------------------------------------------------------------*/
830 if (spec->html_spec_type == CHXJ_SPEC_XHtml_Mobile_1_0
831 || spec->html_spec_type == CHXJ_SPEC_Hdml) {
832 crc = s_add_crc(writedata, writebyte);
833 dst[writebyte + 0] = (crc >> 8) & 0xff;
834 dst[writebyte + 1] = (crc ) & 0xff;
838 DestroyMagickWand(magick_wand);
845 s_fixup_size(MagickWand* magick_wand,
848 query_string_param_t *qsp)
850 img_conv_mode_t mode = qsp->mode;
858 oldw = MagickGetImageWidth(magick_wand);
859 oldh = MagickGetImageHeight(magick_wand);
861 DBG1(r,"detect width=[%d]", oldw);
862 DBG1(r,"detect heigh=[%d]", oldh);
867 DBG1(r,"detect spec width=[%d]", spec->width);
868 DBG1(r,"detect spec heigh=[%d]", spec->heigh);
870 c_width = spec->width;
871 c_heigh = spec->heigh;
874 case IMG_CONV_MODE_THUMBNAIL:
876 DBG(r,"**** detect thumbnail mode ****");
878 if (neww > c_width) {
879 newh = (int)((double)newh * (double)((double)c_width / (double)neww));
880 neww = (int)((double)neww * (double)((double)c_width / (double)neww));
882 if (newh > c_heigh) {
883 neww = (int)((double)neww * (double)((double)c_heigh / (double)newh));
884 newh = (int)((double)newh * (double)((double)c_heigh / (double)newh));
887 neww = (int)((double)(neww / 3) * 0.8);
888 newh = (int)((double)(newh / 3) * 0.8);
891 case IMG_CONV_MODE_WALLPAPER:
892 case IMG_CONV_MODE_EZGET:
894 DBG(r,"**** detect wallpaper mode ****");
896 if (spec->wp_width && spec->wp_heigh) {
897 c_width = spec->wp_width;
898 c_heigh = spec->wp_heigh;
901 DBG(r,"calc new width and height");
903 neww = (int)((double)neww * (double)((double)c_heigh / (double)newh));
904 newh = (int)((double)newh * (double)((double)c_heigh / (double)newh));
906 DBG2(r,"newh = [%d] neww = [%d]", newh, neww);
911 DBG(r,"**** detect normal mode ****");
913 if (qsp->ua_flag != UA_IGN) {
914 if (neww > c_width) {
915 newh = (int)((double)newh * (double)((double)c_width / (double)neww));
916 neww = (int)((double)neww * (double)((double)c_width / (double)neww));
919 if (newh > c_heigh) {
920 neww = (int)((double)neww * (double)((double)c_heigh / (double)newh));
921 newh = (int)((double)newh * (double)((double)c_heigh / (double)newh));
927 DBG2(r,"convert width=[%d --> %d]", oldw, neww);
928 DBG2(r,"convert heigh=[%d --> %d]", oldh, newh);
930 MagickResetIterator(magick_wand);
932 while (MagickNextImage(magick_wand) != MagickFalse) {
934 case IMG_CONV_MODE_WALLPAPER:
935 case IMG_CONV_MODE_EZGET:
937 if (MagickResizeImage(magick_wand,neww,newh,LanczosFilter,1.0) == MagickFalse) {
942 if (MagickCropImage(magick_wand,
943 (unsigned long)c_width,
944 (unsigned long)c_heigh,
945 (long)((neww - c_width) / 2),
946 (long)((newh - c_heigh) / 2)) == MagickFalse) {
952 case IMG_CONV_MODE_NORMAL:
954 DBG2(r,"convert width=[%d --> %d]", neww, qsp->width);
958 DBG2(r,"convert heigh=[%d --> %d]", newh, qsp->height);
963 if (MagickResizeImage(magick_wand,neww,newh,LanczosFilter,1.0) == MagickFalse) {
970 if (MagickSetImageUnits(magick_wand, PixelsPerInchResolution) == MagickFalse) {
975 if (MagickSetImageResolution(magick_wand,
976 (double)spec->dpi_width,
977 (double)spec->dpi_heigh) == MagickFalse) {
982 if (MagickSetImageDispose(magick_wand, BackgroundDispose) == MagickFalse) {
992 s_fixup_color(MagickWand* magick_wand, request_rec* r, device_table* spec, img_conv_mode_t mode)
994 DBG(r,"start chxj_fixup_clor()");
996 if (spec->color >= 256) {
998 DBG1(r,"call MagickQuantizeImage() spec->color=[%d]",spec->color);
1000 if (MagickQuantizeImage(magick_wand,
1005 0) == MagickFalse) {
1006 EXIT_MAGICK_ERROR();
1010 DBG1(r,"call end MagickQuantizeImage() spec->color=[%d]",spec->color);
1014 DBG1(r,"call MagickQuantizeImage() spec->color=[%d]",spec->color);
1016 if (MagickQuantizeImage(magick_wand,
1021 0) == MagickFalse) {
1022 EXIT_MAGICK_ERROR();
1026 DBG1(r,"call end MagickQuantizeImage() spec->color=[%d]",spec->color);
1030 DBG(r,"end chxj_fixup_clor()");
1038 s_fixup_depth(MagickWand* magick_wand, request_rec* r, device_table* spec)
1040 if (spec->color == 15680000) {
1041 if (MagickSetImageDepth(magick_wand, 24) == MagickFalse) {
1042 EXIT_MAGICK_ERROR();
1047 if (spec->color == 262144) {
1048 if (MagickSetImageDepth(magick_wand, 18) == MagickFalse) {
1049 EXIT_MAGICK_ERROR();
1054 if (spec->color == 65536) {
1055 if (MagickSetImageDepth(magick_wand, 16) == MagickFalse) {
1056 EXIT_MAGICK_ERROR();
1061 if (spec->color == 4096) {
1062 if (MagickSetImageDepth(magick_wand, 12) == MagickFalse) {
1063 EXIT_MAGICK_ERROR();
1068 if (spec->color == 256) {
1069 if (MagickSetImageDepth(magick_wand, 8) == MagickFalse) {
1070 EXIT_MAGICK_ERROR();
1075 if (spec->color == 4) {
1076 if (MagickSetImageDepth(magick_wand, 2) == MagickFalse) {
1077 EXIT_MAGICK_ERROR();
1082 if (spec->color == 2) {
1083 if (MagickSetImageDepth(magick_wand, 1) == MagickFalse) {
1084 EXIT_MAGICK_ERROR();
1094 s_add_copyright(MagickWand* magick_wand, request_rec* r, device_table* spec)
1096 mod_chxj_config* conf = ap_get_module_config(r->per_dir_config, &chxj_module);
1098 if (conf->image_copyright) {
1100 DBG1(r, "Add COPYRIGHT [%s]", conf->image_copyright);
1102 if (spec->html_spec_type == CHXJ_SPEC_Jhtml) {
1103 apr_table_setn(r->headers_out, "x-jphone-copyright", "no-transfer");
1104 if (MagickCommentImage(magick_wand,
1105 apr_psprintf(r->pool,
1107 conf->image_copyright)) == MagickFalse)
1111 if (spec->html_spec_type == CHXJ_SPEC_XHtml_Mobile_1_0
1112 || spec->html_spec_type == CHXJ_SPEC_Hdml) {
1113 if (MagickCommentImage(magick_wand,
1114 apr_psprintf(r->pool,
1115 "kddi_copyright=on,%s",
1116 conf->image_copyright)) == MagickFalse)
1120 if (MagickCommentImage(magick_wand,
1121 apr_psprintf(r->pool,
1123 conf->image_copyright)) == MagickFalse)
1128 if (MagickCommentImage(magick_wand, "mod_chxj") == MagickFalse)
1134 EXIT_MAGICK_ERROR();
1139 s_img_down_sizing(MagickWand* magick_wand, request_rec* r, device_table* spec)
1141 MagickBooleanType status;
1142 unsigned long quality = 70;
1143 apr_size_t writebyte = 0;
1145 apr_size_t prev_size = 0;
1146 int revers_flag = 0;
1148 writedata = (char*)MagickGetImageBlob(magick_wand, &writebyte);
1149 prev_size = writebyte;
1152 if (MagickSetImageCompressionQuality(magick_wand, quality) == MagickFalse) {
1153 EXIT_MAGICK_ERROR();
1157 writedata = (char*)MagickGetImageBlob(magick_wand, &writebyte);
1158 if (writebyte >= prev_size || revers_flag) {
1159 DBG2(r, "quality=[%ld] size=[%d]", (long)quality, writebyte);
1162 if (quality > 100) {
1163 if (MagickSetImageCompression(magick_wand,NoCompression) == MagickFalse) {
1164 EXIT_MAGICK_ERROR();
1169 prev_size = writebyte;
1173 DBG2(r, "quality=[%ld] size=[%d]", (long)quality, writebyte);
1175 if (spec->cache == 0)
1178 if (writebyte <= spec->cache)
1183 if (quality == 0 || quality > 100)
1191 && writebyte > spec->cache) {
1192 unsigned long now_color = spec->color;
1193 unsigned long depth = 0;
1196 case 2: depth = 1; break;
1197 case 4: now_color = 2; depth = 1; break;
1198 case 8: now_color = 4; depth = 2; break;
1199 case 16: now_color = 8; depth = 3; break;
1200 case 256: now_color = 16; depth = 4; break;
1201 case 4096: now_color = 256; depth = 8; break;
1202 case 65536: now_color = 4096; depth = 12; break;
1203 case 262144: now_color = 65536; depth = 16; break;
1204 case 15680000: now_color = 262144; depth = 18; break;
1210 if (now_color <= 2) break;
1212 if (now_color >= 8) {
1213 status = MagickQuantizeImage(magick_wand,
1221 status = MagickQuantizeImage(magick_wand,
1227 MagickSetImageType(magick_wand, GrayscaleType);
1229 if (status == MagickFalse) {
1230 EXIT_MAGICK_ERROR();
1234 if (MagickSetImageDepth(magick_wand, depth) == MagickFalse) {
1235 EXIT_MAGICK_ERROR();
1239 writedata = (char*)MagickGetImageBlob(magick_wand, &writebyte);
1241 DBG2(r,"now_color=[%ld] size=[%d]", (long)now_color, writebyte);
1243 /* Once per request */
1246 while(now_color > 2);
1253 s_send_cache_file(device_table* spec, query_string_param_t* query_string, request_rec* r, const char* tmpfile)
1258 apr_size_t sendbyte;
1259 char* contentLength;
1261 rv = apr_stat(&st, tmpfile, APR_FINFO_MIN, r->pool);
1262 if (rv != APR_SUCCESS)
1263 return HTTP_NOT_FOUND;
1265 DBG1(r, "mode:[%d]", query_string->mode);
1266 DBG1(r, "name:[%s]", query_string->name);
1267 DBG1(r, "offset:[%ld]", query_string->offset);
1268 DBG1(r, "count:[%ld]", query_string->count);
1270 if (spec->available_jpeg) {
1271 r->content_type = apr_psprintf(r->pool, "image/jpeg");
1274 if (spec->available_png) {
1275 r->content_type = apr_psprintf(r->pool, "image/png");
1278 if (spec->available_gif) {
1279 r->content_type = apr_psprintf(r->pool, "image/gif");
1282 if (spec->available_bmp2 || spec->available_bmp4) {
1283 r->content_type = apr_psprintf(r->pool, "image/bmp");
1286 if (query_string->mode != IMG_CONV_MODE_EZGET && query_string->name == NULL) {
1287 contentLength = apr_psprintf(r->pool, "%d", (int)st.size);
1288 apr_table_setn(r->headers_out, "Content-Length", (const char*)contentLength);
1290 DBG1(r,"Content-Length:[%d]", (int)st.size);
1292 rv = apr_file_open(&fout, tmpfile,
1293 APR_READ | APR_BINARY, APR_OS_DEFAULT, r->pool);
1294 if (rv != APR_SUCCESS) {
1295 DBG1(r, "tmpfile open failed[%s]", tmpfile);
1296 return HTTP_NOT_FOUND;
1299 ap_send_fd(fout, r, 0, st.size, &sendbyte);
1300 apr_file_close(fout);
1302 DBG1(r, "send file data[%d]byte", sendbyte);
1305 if (query_string->mode == IMG_CONV_MODE_EZGET) {
1306 char* name = apr_pstrdup(r->pool, basename(r->filename));
1307 name[strlen(name)-4] = 0;
1308 if (strcasecmp(r->content_type, "image/jpeg") == 0) {
1310 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1311 ap_rprintf(r, HDML_FIRST_PAGE, r->uri, name, ".jpg", (long)st.size, "devjaww", name);
1314 if (strcasecmp(r->content_type, "image/bmp") == 0) {
1315 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1316 ap_rprintf(r, HDML_FIRST_PAGE, r->uri, name, ".bmp", (long)st.size, "devabm", name);
1319 if (strcasecmp(r->content_type, "image/png") == 0) {
1320 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1321 ap_rprintf(r, HDML_FIRST_PAGE, r->uri, name, ".png", (long)st.size, "dev8aww", name);
1324 if (strcasecmp(r->content_type, "image/gif") == 0) {
1325 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1326 ap_rprintf(r, HDML_FIRST_PAGE, r->uri, name, ".gif", (long)st.size, "devgi0z", name);
1330 if (query_string->mode == IMG_CONV_MODE_WALLPAPER && query_string->name != NULL) {
1331 if (query_string->count == -1 && query_string->offset == -1) {
1332 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1333 ap_rprintf(r, HDML_SUCCESS_PAGE);
1337 if (query_string->count == -2 && query_string->offset == -1) {
1338 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1339 ap_rprintf(r, HDML_FAIL_PAGE);
1343 ap_set_content_type(r, "application/x-up-download");
1344 contentLength = apr_psprintf(r->pool, "%ld", query_string->count);
1345 apr_table_setn(r->headers_out, "Content-Length", (const char*)contentLength);
1347 DBG1(r, "Content-Length:[%d]", (int)st.size);
1349 rv = apr_file_open(&fout, tmpfile,
1350 APR_READ | APR_BINARY, APR_OS_DEFAULT, r->pool);
1352 if (rv != APR_SUCCESS) {
1353 DBG1(r,"tmpfile open failed[%s]", tmpfile);
1354 return HTTP_NOT_FOUND;
1357 ap_send_fd(fout, r, query_string->offset, query_string->count, &sendbyte);
1358 apr_file_close(fout);
1360 DBG1(r, "send file data[%d]byte", sendbyte);
1368 s_header_only_cache_file(device_table* spec, query_string_param_t* query_string, request_rec* r, const char* tmpfile)
1372 char* contentLength;
1374 rv = apr_stat(&st, tmpfile, APR_FINFO_MIN, r->pool);
1375 if (rv != APR_SUCCESS)
1376 return HTTP_NOT_FOUND;
1378 DBG1(r, "mode:[%d]", query_string->mode);
1379 DBG1(r, "name:[%s]", query_string->name);
1380 DBG1(r, "offset:[%ld]", query_string->offset);
1381 DBG1(r, "count:[%ld]", query_string->count);
1383 if (spec->available_jpeg) {
1384 r->content_type = apr_psprintf(r->pool, "image/jpeg");
1387 if (spec->available_png) {
1388 r->content_type = apr_psprintf(r->pool, "image/png");
1391 if (spec->available_gif) {
1392 r->content_type = apr_psprintf(r->pool, "image/gif");
1395 if (spec->available_bmp2 || spec->available_bmp4) {
1396 r->content_type = apr_psprintf(r->pool, "image/bmp");
1399 if (query_string->mode != IMG_CONV_MODE_EZGET && query_string->name == NULL) {
1400 contentLength = apr_psprintf(r->pool, "%d", (int)st.size);
1401 apr_table_setn(r->headers_out, "Content-Length", (const char*)contentLength);
1403 DBG1(r,"Content-Length:[%d]", (int)st.size);
1406 if (query_string->mode == IMG_CONV_MODE_EZGET) {
1407 char* name = apr_pstrdup(r->pool, basename(r->filename));
1408 name[strlen(name)-4] = 0;
1409 if (strcasecmp(r->content_type, "image/jpeg") == 0) {
1411 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1414 if (strcasecmp(r->content_type, "image/bmp") == 0) {
1415 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1418 if (strcasecmp(r->content_type, "image/png") == 0) {
1419 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1422 if (strcasecmp(r->content_type, "image/gif") == 0) {
1423 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1427 if (query_string->mode == IMG_CONV_MODE_WALLPAPER && query_string->name != NULL) {
1428 if (query_string->count == -1 && query_string->offset == -1) {
1429 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1432 if (query_string->count == -2 && query_string->offset == -1) {
1433 ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
1436 ap_set_content_type(r, "application/x-up-download");
1437 contentLength = apr_psprintf(r->pool, "%ld", query_string->count);
1438 apr_table_setn(r->headers_out, "Content-Length", (const char*)contentLength);
1440 DBG1(r, "Content-Length:[%d]", (int)st.size);
1452 mod_chxj_config* conf,
1453 const char* user_agent,
1454 query_string_param_t *qsp)
1459 char* w = apr_palloc(r->pool, 256);
1463 switch (qsp->mode) {
1464 case IMG_CONV_MODE_THUMBNAIL:
1465 fname = apr_psprintf(r->pool, "%s.%s.thumbnail", r->filename, user_agent);
1466 DBG1(r, "mode=thumbnail [%s]", fname);
1468 case IMG_CONV_MODE_WALLPAPER:
1469 case IMG_CONV_MODE_EZGET:
1470 fname = apr_psprintf(r->pool, "%s.%s.wallpaper", r->filename, user_agent);
1471 DBG1(r, "mode=WallPaper [%s]", fname);
1473 case IMG_CONV_MODE_NORMAL:
1476 fname = apr_psprintf(r->pool, "%s.%s", r->filename, user_agent);
1479 fname = apr_psprintf(r->pool, "%s.w%d", fname, qsp->width);
1482 fname = apr_psprintf(r->pool, "%s.h%d", fname, qsp->height);
1484 DBG1(r,"mode=normal [%s]", fname);
1487 if (qsp->ua_flag == UA_IGN) {
1488 fname = apr_psprintf(r->pool, "%s.IGN", fname);
1491 len = strlen(fname);
1493 for (ii=0; ii<len; ii++) {
1494 if (fname[ii] == '/'
1498 || fname[ii] == ')') {
1502 w[jj++] = fname[ii];
1506 return apr_psprintf(r->pool, "%s/%s", conf->image_cache_dir,w);
1509 static unsigned short
1510 s_add_crc(const char* writedata, apr_size_t writebyte)
1512 unsigned short crc = 0xffff;
1516 for(ii=0;ii<writebyte;ii++) {
1518 crc = AU_CRC_TBL[(crc>>8^ch)&0xff]^(crc<<8);
1524 chxj_trans_name(request_rec *r)
1531 mod_chxj_config* conf;
1539 "qrc", /* QRCode½ÐÎÏÍÑ¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò */
1545 int do_ext_check = TRUE;
1546 int next_ok = FALSE;
1548 conf = ap_get_module_config(r->per_dir_config, &chxj_module);
1550 if (conf->image != CHXJ_IMG_ON)
1553 DBG1(r,"Match URI[%s]", r->uri);
1556 if (r->filename == NULL)
1557 r->filename = apr_pstrdup(r->pool, r->uri);
1560 if ((idx = strchr(r->filename, ':')) != NULL)
1561 filename_sv = idx+1;
1563 filename_sv = r->filename;
1565 DBG1(r,"r->filename[%s]", filename_sv);
1567 ccp = ap_document_root(r);
1569 return HTTP_INTERNAL_SERVER_ERROR;
1571 docroot = apr_pstrdup(r->pool, ccp);
1572 len = strlen(docroot);
1574 if (docroot[len-1] == '/')
1575 docroot[len-1] = '\0';
1579 && *filename_sv == *r->server->path
1580 && strncmp(filename_sv, r->server->path, r->server->pathlen) == 0)
1581 filename_sv = apr_pstrcat(r->pool, docroot, (filename_sv + r->server->pathlen), NULL);
1583 filename_sv = apr_pstrcat(r->pool, docroot, filename_sv, NULL);
1585 DBG1(r,"URI[%s]", filename_sv);
1587 do_ext_check = TRUE;
1588 for (ii=0; ii<7-1; ii++) {
1589 char* pos = strrchr(filename_sv, '.');
1591 if (strcasecmp(pos, ext[ii]) == 0) {
1592 do_ext_check = FALSE;
1593 fname = apr_psprintf(r->pool, "%s", filename_sv);
1600 for (ii=0; ii<7; ii++) {
1601 if (strlen(ext[ii]) == 0) {
1602 fname = apr_psprintf(r->pool, "%s", filename_sv);
1605 fname = apr_psprintf(r->pool, "%s.%s", filename_sv, ext[ii]);
1607 DBG1(r,"search [%s]", fname);
1609 rv = apr_stat(&st, fname, APR_FINFO_MIN, r->pool);
1610 if (rv == APR_SUCCESS) {
1611 if (st.filetype != APR_DIR)
1618 if (fname == NULL) {
1619 DBG1(r,"NotFound [%s]", r->filename);
1622 for (ii=0; ii<7-1; ii++) {
1623 char* pos = strrchr(fname, '.');
1625 if (strcasecmp(pos, ext[ii]) == 0) {
1633 DBG1(r,"NotFound [%s]", r->filename);
1637 if (r->handler == NULL || strcasecmp(r->handler, "chxj-qrcode") != 0) {
1638 DBG1(r,"Found [%s]", fname);
1640 r->filename = apr_psprintf(r->pool, "%s", fname);
1642 if (strcasecmp("qrc", ext[ii]) == 0)
1643 r->handler = apr_psprintf(r->pool, "chxj-qrcode");
1645 r->handler = apr_psprintf(r->pool, "chxj-picture");
1653 * It converts it from QUERYSTRING.
1657 static query_string_param_t*
1658 s_get_query_string_param(request_rec *r)
1666 query_string_param_t* param;
1668 s = apr_pstrdup(r->pool, r->parsed_uri.query);
1669 param = apr_palloc(r->pool, sizeof(query_string_param_t));
1670 param->mode = IMG_CONV_MODE_NORMAL;
1671 param->user_agent = NULL;
1672 param->ua_flag = UA_USE;
1679 if (s == NULL) return param;
1682 if ((pair = apr_strtok(s, "&", &pstate)) == NULL) break;
1685 name = apr_strtok(pair, "=", &vstate);
1686 value = apr_strtok(NULL, "=", &vstate);
1691 if (value && (strcasecmp(name, "mode") == 0 || strcasecmp(name, "m") == 0)) {
1696 if (strcasecmp(value, "thumbnail") == 0 || strcasecmp(value, "tb") == 0)
1697 param->mode = IMG_CONV_MODE_THUMBNAIL;
1702 if (strcasecmp(value, "WP") == 0 || strcasecmp(value, "WallPaper") == 0)
1703 param->mode = IMG_CONV_MODE_WALLPAPER;
1708 if (strcasecmp(value, "EZGET") == 0)
1709 param->mode = IMG_CONV_MODE_EZGET;
1719 if (value && (strcasecmp(name, "ua") == 0 || strcasecmp(name, "user-agent") == 0)) {
1720 ap_unescape_url(value);
1722 if ((*value == 'i' || *value == 'I') && strcasecmp(value, "IGN") == 0)
1723 param->ua_flag = UA_IGN;
1725 param->user_agent = apr_pstrdup(r->pool, value);
1731 if (value && strcasecmp(name, "name") == 0)
1732 param->name = apr_pstrdup(r->pool, value);
1737 if (value && strcasecmp(name, "offset") == 0 && (! chxj_chk_numeric(value)))
1738 param->offset = chxj_atoi(value);
1744 if (value && strcasecmp(name, "count") == 0 && (! chxj_chk_numeric(value)))
1745 param->count = chxj_atoi(value);
1750 if (value && strcasecmp(name, "w") == 0 && (! chxj_chk_numeric(value)))
1751 param->width = chxj_atoi(value);
1756 if (value && strcasecmp(name, "h") == 0 && (! chxj_chk_numeric(value)))
1757 param->height = chxj_atoi(value);
1765 if (param->mode == IMG_CONV_MODE_NORMAL && param->name)
1766 param->mode = IMG_CONV_MODE_WALLPAPER;