[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#1701: problem computing image dimension of huge jpeg file
From: |
xah lee |
Subject: |
bug#1701: problem computing image dimension of huge jpeg file |
Date: |
Thu, 25 Dec 2008 10:19:29 -0800 |
this appears to be a bug.
Summary: emacs seems to have some limitation when trying to compute a
jpeg image's width and height when the image is huge.
Sorry i haven't had time to narrow down exactly where is the bug, but
here's a short description with my elisp code that this problem happens.
When using the following code full-size-img-linkify (see code below)
on a large image that is 4248x544, but emacs report it as 30x30.
This has happened to me once before on another image. When i try to
open the image in emacs, emacs doesn't display it. So, the problem
may simply be that emacs can't properly decode the file. (as far as i
know, the image is not corrupt since i can view it in 2 other image
viewer programs)
Here's steps to reproduce:
• download the image here:
wget -U "Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.0.4)
Gecko/2008102920 Firefox/3.0.4" http://xahlee.org/Whirlwheel_dir/
livermore/livermore.jpg
(the image is available here http://xahlee.org/Whirlwheel_dir/
livermore.html but if you use wget you need to give mozilla agent
string)
• save the image to disk in a directory, let's say named xxx.
• create a html file in the dir xxx, say call it test.html
• insert the text “livermore.jpg” (without the quotes) into the
file, then press return.
• now move cursor to the line. Then M-x full-size-img-linkify.
Emacs should change the line to this:
<a class="lgimg" href="livermore.jpg" title="30x30">❐</a>
but what's expected is this:
<a class="lgimg" href="livermore.jpg" title="4248x544">❐</a>
In GNU Emacs 22.2.1 (powerpc-apple-darwin8.11.0, Carbon Version 1.6.0)
of 2008-04-05 on g5.tokyo.stp.isas.jaxa.jp
Windowing system distributor `Apple Inc.', version 10.4.11
pasted below is the function
(defun full-size-img-linkify ()
"Make img file path at cursor point into a img link.
Example:
i/goddesses.jpg
becomes
<a class=\"lgimg\" href=\"i/goddesses.jpg\" title=\"622x800\">❐</a>
If region is active, use region as file name.
"
(interactive)
(let
(imgPath imgfName linkText bds imgDimen width height myResult)
(setq bds
(if (and transient-mark-mode mark-active)
(cons (region-beginning) (region-end))
(bounds-of-thing-at-point 'filename)
))
(setq imgPath
(buffer-substring-no-properties (car bds) (cdr bds))
)
(setq imgfName (file-name-nondirectory imgPath))
;; (setq linkText
;; (if (< (length imgfName) 20)
;; imgfName
;; (concat (substring imgfName 0 5) "..." (substring
imgfName -6) ) ))
(setq imgDimen (get-image-dimensions imgPath))
(setq width (number-to-string (car imgDimen)))
(setq height (number-to-string (car (last imgDimen))))
(setq myResult (concat "<a class=\"lgimg\" href=\"" imgPath "\"
" "title=" "\"" width "x" height "\"" ">❐</a>"))
(delete-region (car bds) (cdr bds))
(insert myResult)
))
Xah
∑ http://xahlee.org/
☄
- bug#1701: problem computing image dimension of huge jpeg file,
xah lee <=