OSDN Git Service

* Added New Features.
[modchxj/mod_chxj.git] / src / chxj_img_conv_format.c
index 7846f4e..5063a66 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -458,6 +458,7 @@ s_create_cache_file(request_rec          *r,
   apr_finfo_t cache_dir_st;
 
   MagickWand *magick_wand;
+  int        img_count;
 
   if (STRCASEEQ('c','C',"chxj-qrcode",r->handler)) {
     /*------------------------------------------------------------------------*/
@@ -520,6 +521,19 @@ s_create_cache_file(request_rec          *r,
     EXIT_MAGICK_ERROR();
     return HTTP_NOT_FOUND;
   }
+
+  /*------------------*/
+  /* for AnimationGIF */
+  /*------------------*/
+  img_count = MagickGetNumberImages(magick_wand);
+  DBG(r, "REQ[%X] img_count is [%d]", (unsigned int)(apr_size_t)r, img_count);
+  if (img_count > 1) {
+    MagickSetImageIndex(magick_wand, 0);
+    MagickWand *magick_wand2 = MagickGetImage(magick_wand);
+    DestroyMagickWand(magick_wand);
+    magick_wand = magick_wand2;
+  }
+
   if (MagickStripImage(magick_wand) == MagickFalse) {
     ERR(r, "mod_chxj: strip image failure.");
     EXIT_MAGICK_ERROR();
@@ -1930,7 +1944,7 @@ chxj_trans_name(request_rec *r)
           "qrc",    /* QRCode出力用ファイルの拡張子 */
           "",
   };
-  char     *fname;
+  char     *fname = NULL;
   char     *idx;
   char     *filename_sv;
   int      do_ext_check = TRUE;