diff options
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/image.el | 8 | ||||
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/image.c | 43 |
7 files changed, 78 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 42b9600a0ac..0d7d13ea4e7 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * display.texi (ImageMagick Images): Mention :content-type and | ||
| 4 | `image-content-type-suffixes'. | ||
| 5 | |||
| 1 | 2013-08-13 Xue Fuqiao <xfq.free@gmail.com> | 6 | 2013-08-13 Xue Fuqiao <xfq.free@gmail.com> |
| 2 | 7 | ||
| 3 | * positions.texi (Word Motion): Remove redundant sentence. | 8 | * positions.texi (Word Motion): Remove redundant sentence. |
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 6b8d24179e7..f2fd51e6ae5 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -4664,6 +4664,14 @@ and if @code{:height} is set it will have precedence over | |||
| 4664 | wish. @code{:max-width} and @code{:max-height} will always preserve | 4664 | wish. @code{:max-width} and @code{:max-height} will always preserve |
| 4665 | the aspect ratio. | 4665 | the aspect ratio. |
| 4666 | 4666 | ||
| 4667 | @item :content-type | ||
| 4668 | ImageMagick tries to auto-detect the image type, but it isn't always | ||
| 4669 | able to. By using @code{:content-type}, we can give ImageMagick a | ||
| 4670 | hint to try to help it. It's used in conjuction with the | ||
| 4671 | @code{image-content-type-suffixes} variable, which provides a mapping | ||
| 4672 | from content types to file name suffixes. This is then given to | ||
| 4673 | ImageMagick as a file name hint. | ||
| 4674 | |||
| 4667 | @item :rotation | 4675 | @item :rotation |
| 4668 | Specifies a rotation angle in degrees. | 4676 | Specifies a rotation angle in degrees. |
| 4669 | 4677 | ||
| @@ -896,6 +896,10 @@ treated as images. | |||
| 896 | *** ImageMagick images now support the :max-width and :max-height | 896 | *** ImageMagick images now support the :max-width and :max-height |
| 897 | keywords. | 897 | keywords. |
| 898 | 898 | ||
| 899 | *** Some data types aren't auto-detected by ImageMagick. Adding | ||
| 900 | :content-type to `create-image' may help if the content type is in the | ||
| 901 | new variable `image-content-type-suffixes'. | ||
| 902 | |||
| 899 | ** Minibuffer | 903 | ** Minibuffer |
| 900 | 904 | ||
| 901 | *** In minibuffer filename prompts, `C-M-f' and `C-M-b' now move to the | 905 | *** In minibuffer filename prompts, `C-M-f' and `C-M-b' now move to the |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 11e5e913398..c6f11fec11a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * image.el (image-content-type-suffixes): New variable. | ||
| 4 | |||
| 1 | 2013-08-13 Fabián Ezequiel Gallina <fgallina@gnu.org> | 5 | 2013-08-13 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 2 | 6 | ||
| 3 | * progmodes/python.el (python-imenu--build-tree) | 7 | * progmodes/python.el (python-imenu--build-tree) |
diff --git a/lisp/image.el b/lisp/image.el index 804dc3af5ea..de69490f5b6 100644 --- a/lisp/image.el +++ b/lisp/image.el | |||
| @@ -99,6 +99,14 @@ AUTODETECT can be | |||
| 99 | - maybe auto-detect only if the image type is available | 99 | - maybe auto-detect only if the image type is available |
| 100 | (see `image-type-available-p').") | 100 | (see `image-type-available-p').") |
| 101 | 101 | ||
| 102 | (defvar image-content-type-suffixes | ||
| 103 | '((image/x-icon "ico")) | ||
| 104 | "Alist of MIME Content-Type headers to file name suffixes. | ||
| 105 | This is used as a hint by the ImageMagick library when detecting | ||
| 106 | image types. If `create-image' is called with a :content-type | ||
| 107 | matching found in this alist, the ImageMagick library will be | ||
| 108 | told that the data would have this suffix if saved to a file.") | ||
| 109 | |||
| 102 | (defcustom image-load-path | 110 | (defcustom image-load-path |
| 103 | (list (file-name-as-directory (expand-file-name "images" data-directory)) | 111 | (list (file-name-as-directory (expand-file-name "images" data-directory)) |
| 104 | 'data-directory 'load-path) | 112 | 'data-directory 'load-path) |
diff --git a/src/ChangeLog b/src/ChangeLog index 1cb8002ccf7..c60b2c19acf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-08-13 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * image.c (imagemagick_filename_hint): New function to possibly | ||
| 4 | apply `image-content-type-suffixes'. | ||
| 5 | (imagemagick_load_image): Use it. | ||
| 6 | |||
| 1 | 2013-08-13 Eli Zaretskii <eliz@gnu.org> | 7 | 2013-08-13 Eli Zaretskii <eliz@gnu.org> |
| 2 | 8 | ||
| 3 | * decompress.c (Fzlib_decompress_region) [WINDOWSNT]: Return Qnil | 9 | * decompress.c (Fzlib_decompress_region) [WINDOWSNT]: Return Qnil |
diff --git a/src/image.c b/src/image.c index ae38b4f7648..35cbbb631ae 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -551,6 +551,7 @@ static Lisp_Object QCheuristic_mask; | |||
| 551 | static Lisp_Object QCcolor_symbols; | 551 | static Lisp_Object QCcolor_symbols; |
| 552 | static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry; | 552 | static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry; |
| 553 | static Lisp_Object QCcrop, QCrotation; | 553 | static Lisp_Object QCcrop, QCrotation; |
| 554 | static Lisp_Object QCcontent_type; | ||
| 554 | 555 | ||
| 555 | /* Other symbols. */ | 556 | /* Other symbols. */ |
| 556 | 557 | ||
| @@ -7740,6 +7741,7 @@ enum imagemagick_keyword_index | |||
| 7740 | IMAGEMAGICK_WIDTH, | 7741 | IMAGEMAGICK_WIDTH, |
| 7741 | IMAGEMAGICK_MAX_HEIGHT, | 7742 | IMAGEMAGICK_MAX_HEIGHT, |
| 7742 | IMAGEMAGICK_MAX_WIDTH, | 7743 | IMAGEMAGICK_MAX_WIDTH, |
| 7744 | IMAGEMAGICK_CONTENT_TYPE, | ||
| 7743 | IMAGEMAGICK_ROTATION, | 7745 | IMAGEMAGICK_ROTATION, |
| 7744 | IMAGEMAGICK_CROP, | 7746 | IMAGEMAGICK_CROP, |
| 7745 | IMAGEMAGICK_LAST | 7747 | IMAGEMAGICK_LAST |
| @@ -7764,6 +7766,7 @@ static struct image_keyword imagemagick_format[IMAGEMAGICK_LAST] = | |||
| 7764 | {":width", IMAGE_INTEGER_VALUE, 0}, | 7766 | {":width", IMAGE_INTEGER_VALUE, 0}, |
| 7765 | {":max-height", IMAGE_INTEGER_VALUE, 0}, | 7767 | {":max-height", IMAGE_INTEGER_VALUE, 0}, |
| 7766 | {":max-width", IMAGE_INTEGER_VALUE, 0}, | 7768 | {":max-width", IMAGE_INTEGER_VALUE, 0}, |
| 7769 | {":content-type", IMAGE_SYMBOL_VALUE, 0}, | ||
| 7767 | {":rotation", IMAGE_NUMBER_VALUE, 0}, | 7770 | {":rotation", IMAGE_NUMBER_VALUE, 0}, |
| 7768 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} | 7771 | {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} |
| 7769 | }; | 7772 | }; |
| @@ -7842,6 +7845,30 @@ imagemagick_error (MagickWand *wand) | |||
| 7842 | description = (char *) MagickRelinquishMemory (description); | 7845 | description = (char *) MagickRelinquishMemory (description); |
| 7843 | } | 7846 | } |
| 7844 | 7847 | ||
| 7848 | /* Possibly give ImageMagick some extra help to determine the image | ||
| 7849 | type by supplying a "dummy" filename based on the Content-Type. */ | ||
| 7850 | |||
| 7851 | static char* | ||
| 7852 | imagemagick_filename_hint (Lisp_Object spec) | ||
| 7853 | { | ||
| 7854 | Lisp_Object content_type = image_spec_value (spec, QCcontent_type, NULL); | ||
| 7855 | Lisp_Object symbol = intern ("image-content-type-suffixes"); | ||
| 7856 | Lisp_Object suffix; | ||
| 7857 | char *name, *prefix = "/tmp/foo."; | ||
| 7858 | |||
| 7859 | if (NILP (Fboundp (symbol))) | ||
| 7860 | return NULL; | ||
| 7861 | |||
| 7862 | suffix = Fcar (Fcdr (Fassq (content_type, Fsymbol_value (symbol)))); | ||
| 7863 | if (! STRINGP (suffix)) | ||
| 7864 | return NULL; | ||
| 7865 | |||
| 7866 | name = xmalloc (strlen (prefix) + SBYTES (suffix) + 1); | ||
| 7867 | strcpy(name, prefix); | ||
| 7868 | strcat(name, SDATA (suffix)); | ||
| 7869 | return name; | ||
| 7870 | } | ||
| 7871 | |||
| 7845 | /* Helper function for imagemagick_load, which does the actual loading | 7872 | /* Helper function for imagemagick_load, which does the actual loading |
| 7846 | given contents and size, apart from frame and image structures, | 7873 | given contents and size, apart from frame and image structures, |
| 7847 | passed from imagemagick_load. Uses librimagemagick to do most of | 7874 | passed from imagemagick_load. Uses librimagemagick to do most of |
| @@ -7875,6 +7902,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7875 | int desired_width, desired_height; | 7902 | int desired_width, desired_height; |
| 7876 | double rotation; | 7903 | double rotation; |
| 7877 | int pixelwidth; | 7904 | int pixelwidth; |
| 7905 | char *filename_hint = NULL; | ||
| 7878 | 7906 | ||
| 7879 | /* Handle image index for image types who can contain more than one image. | 7907 | /* Handle image index for image types who can contain more than one image. |
| 7880 | Interface :index is same as for GIF. First we "ping" the image to see how | 7908 | Interface :index is same as for GIF. First we "ping" the image to see how |
| @@ -7888,6 +7916,12 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7888 | ping_wand = NewMagickWand (); | 7916 | ping_wand = NewMagickWand (); |
| 7889 | /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */ | 7917 | /* MagickSetResolution (ping_wand, 2, 2); (Bug#10112) */ |
| 7890 | 7918 | ||
| 7919 | if (! filename) | ||
| 7920 | filename_hint = imagemagick_filename_hint (img->spec); | ||
| 7921 | |||
| 7922 | if (filename_hint) | ||
| 7923 | MagickSetFilename (ping_wand, filename_hint); | ||
| 7924 | |||
| 7891 | status = filename | 7925 | status = filename |
| 7892 | ? MagickPingImage (ping_wand, filename) | 7926 | ? MagickPingImage (ping_wand, filename) |
| 7893 | : MagickPingImageBlob (ping_wand, contents, size); | 7927 | : MagickPingImageBlob (ping_wand, contents, size); |
| @@ -7920,6 +7954,9 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7920 | 7954 | ||
| 7921 | image_wand = NewMagickWand (); | 7955 | image_wand = NewMagickWand (); |
| 7922 | 7956 | ||
| 7957 | if (filename_hint) | ||
| 7958 | MagickSetFilename (image_wand, filename_hint); | ||
| 7959 | |||
| 7923 | if ((filename | 7960 | if ((filename |
| 7924 | ? MagickReadImage (image_wand, filename) | 7961 | ? MagickReadImage (image_wand, filename) |
| 7925 | : MagickReadImageBlob (image_wand, contents, size)) | 7962 | : MagickReadImageBlob (image_wand, contents, size)) |
| @@ -8163,11 +8200,16 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 8163 | /* `MagickWandTerminus' terminates the imagemagick environment. */ | 8200 | /* `MagickWandTerminus' terminates the imagemagick environment. */ |
| 8164 | MagickWandTerminus (); | 8201 | MagickWandTerminus (); |
| 8165 | 8202 | ||
| 8203 | if (filename_hint) | ||
| 8204 | free (filename_hint); | ||
| 8205 | |||
| 8166 | return 1; | 8206 | return 1; |
| 8167 | 8207 | ||
| 8168 | imagemagick_error: | 8208 | imagemagick_error: |
| 8169 | DestroyMagickWand (image_wand); | 8209 | DestroyMagickWand (image_wand); |
| 8170 | if (bg_wand) DestroyPixelWand (bg_wand); | 8210 | if (bg_wand) DestroyPixelWand (bg_wand); |
| 8211 | if (filename_hint) | ||
| 8212 | free (filename_hint); | ||
| 8171 | 8213 | ||
| 8172 | MagickWandTerminus (); | 8214 | MagickWandTerminus (); |
| 8173 | /* TODO more cleanup. */ | 8215 | /* TODO more cleanup. */ |
| @@ -9105,6 +9147,7 @@ non-numeric, there is no explicit limit on the size of images. */); | |||
| 9105 | DEFSYM (Qpostscript, "postscript"); | 9147 | DEFSYM (Qpostscript, "postscript"); |
| 9106 | DEFSYM (QCmax_width, ":max-width"); | 9148 | DEFSYM (QCmax_width, ":max-width"); |
| 9107 | DEFSYM (QCmax_height, ":max-height"); | 9149 | DEFSYM (QCmax_height, ":max-height"); |
| 9150 | DEFSYM (QCcontent_type, ":content-type"); | ||
| 9108 | #ifdef HAVE_GHOSTSCRIPT | 9151 | #ifdef HAVE_GHOSTSCRIPT |
| 9109 | ADD_IMAGE_TYPE (Qpostscript); | 9152 | ADD_IMAGE_TYPE (Qpostscript); |
| 9110 | DEFSYM (QCloader, ":loader"); | 9153 | DEFSYM (QCloader, ":loader"); |