unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1701: problem computing image dimension of huge jpeg file
@ 2008-12-25 18:19 xah lee
  2008-12-26 17:04 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: xah lee @ 2008-12-25 18:19 UTC (permalink / raw)
  To: bug-gnu-emacs

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/^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#1701: problem computing image dimension of huge jpeg file
  2008-12-25 18:19 bug#1701: problem computing image dimension of huge jpeg file xah lee
@ 2008-12-26 17:04 ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 2008-12-26 17:04 UTC (permalink / raw)
  To: xah lee; +Cc: bug-gnu-emacs, 1701

xah lee <xah@xahlee.org> writes:

> 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.

You should report that to the author of the get-image-dimensions
function.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-26 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-25 18:19 bug#1701: problem computing image dimension of huge jpeg file xah lee
2008-12-26 17:04 ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).