unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: Chong Yidong <cyd@stupidchicken.com>,
	emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	rms@gnu.org
Subject: Re: image size limit?
Date: Wed, 19 Oct 2005 14:51:33 +0200	[thread overview]
Message-ID: <m3d5m1brfu.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <85ek6hitq3.fsf@lola.goethe.zz> (David Kastrup's message of "Wed, 19 Oct 2005 14:20:20 +0200")

David Kastrup <dak@gnu.org> writes:

> It sounds to me like the limits should be configurable, with a
> somewhat conservative default.  Applications where larger dimensions
> might be appropriate (image viewers with provisions for panning, i.e.)
> can allow them in their own buffers using buffer-local settings of the
> variables limiting the size.

I think it makes sense for some purposes to allow max image size to be
specified in absolute pixels.  Here is a patch to do that:


*** image.c	19 Oct 2005 10:20:42 +0200	1.37
--- image.c	19 Oct 2005 11:50:56 +0200	
***************
*** 1163,1179 ****
       int width;
       int height;
  {
!   if (width <= 0 || height <=0)
!     return 0;
  
!   if (FLOATP (Vmax_image_size) && f
!       && ((width > (int)(XFLOAT_DATA (Vmax_image_size)
!   			 * FRAME_PIXEL_WIDTH (f)))
!   	  || (height > (int)(XFLOAT_DATA (Vmax_image_size)
!   			     * FRAME_PIXEL_HEIGHT (f)))))
      return 0;
  
!   return 1;
  }
  
  /* Prepare image IMG for display on frame F.  Must be called before
--- 1163,1191 ----
       int width;
       int height;
  {
!   int w, h;
  
!   if (width <= 0 || height <= 0)
      return 0;
  
!   if (INTEGERP (Vmax_image_size))
!     w = h = XINT (Vmax_image_size);
!   else if (FLOATP (Vmax_image_size))
!     {
!       if (f != NULL)
! 	{
! 	  w = FRAME_PIXEL_WIDTH (f);
! 	  h = FRAME_PIXEL_HEIGHT (f);
! 	}
!       else
! 	w = h = 1024;  /* Arbitrary size for unknown frame. */
!       w = (int) (XFLOAT_DATA (Vmax_image_size) * w);
!       h = (int) (XFLOAT_DATA (Vmax_image_size) * h);
!     }
!   else
!     return 1;
! 
!   return (width <= w && height <= h);
  }
  
  /* Prepare image IMG for display on frame F.  Must be called before
***************
*** 8289,8300 ****
    Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
  
    DEFVAR_LISP ("max-image-size", &Vmax_image_size,
!     doc: /* Maximum size of an image, relative to the selected frame.
  
! This is a floating point number that is multiplied by the width and
  height of the selected frame, to give the maximum width and height for
! images.  Emacs will not load an image into memory if its width or
! height exceeds this limit. */);
    Vmax_image_size = make_float (MAX_IMAGE_SIZE);
  
    Vimage_type_cache = Qnil;
--- 8301,8319 ----
    Fput (intern ("image-library-alist"), Qrisky_local_variable, Qt);
  
    DEFVAR_LISP ("max-image-size", &Vmax_image_size,
!     doc: /* Maximum size of images.
! Emacs will not load an image into memory if its pixel width or
! pixel height exceeds this limit.
! 
! If the value is an integer it specifies the absolute maximum pixel
! width and pixel height for images.
  
! If the value is a floating point number it specifies a limit relative
! to the selected frame, i.e. the value is multiplied by the width and
  height of the selected frame, to give the maximum width and height for
! images.
! 
! Otherwise, no limit is placed on images.   */);
    Vmax_image_size = make_float (MAX_IMAGE_SIZE);
  
    Vimage_type_cache = Qnil;


*** display.texi	19 Oct 2005 10:20:40 +0200	1.191
--- display.texi	19 Oct 2005 13:12:43 +0200	
***************
*** 4061,4070 ****
  @defvar max-image-size
  @tindex max-image-size
  This variable is used to define the maximum size of image that Emacs
! will load.  If its value is a floating point number, that number is
! multiplied by the width and height of the selected frame, in pixels,
! to give the maximum image width and height.  Emacs will refuse to load
! and display any image that is larger than this.
  
  The purpose of this variable is to prevent unreasonably large images
  from accidentally being loaded into Emacs.  It only takes effect the
--- 4061,4074 ----
  @defvar max-image-size
  @tindex max-image-size
  This variable is used to define the maximum size of image that Emacs
! will load.  Emacs will refuse to load (and display) any image that is
! larger than this limit.
! 
! If its value is an integer, it specifies the absolute maximum width
! and height, in pixels, for images.  If its value is a floating point
! number, that number is multiplied by the width and height of the
! selected frame, in pixels, to give the maximum image width and height.
! Otherwise, no limit is placed on images.
  
  The purpose of this variable is to prevent unreasonably large images
  from accidentally being loaded into Emacs.  It only takes effect the


-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

  parent reply	other threads:[~2005-10-19 12:51 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-11 20:32 image size limit? Chong Yidong
2005-10-11 21:19 ` Kevin Rodgers
2005-10-12 16:24 ` Richard M. Stallman
2005-10-12 17:40   ` Romain Francoise
2005-10-13 20:13     ` Richard M. Stallman
2005-10-14 13:02       ` Chong Yidong
2005-10-15 16:13         ` Richard M. Stallman
2005-10-15 18:33           ` Chong Yidong
2005-10-16 17:36             ` Richard M. Stallman
2005-10-16 22:27       ` Chong Yidong
2005-10-17 17:30         ` Richard M. Stallman
2005-10-17 21:56           ` Chong Yidong
2005-10-18  3:39             ` Richard M. Stallman
2005-10-18 14:33               ` Stefan Monnier
2005-10-19  8:35                 ` Kim F. Storm
2005-10-19 12:20                   ` David Kastrup
2005-10-19 12:45                     ` Chong Yidong
2005-10-19 20:17                       ` Richard M. Stallman
2005-10-19 12:51                     ` Kim F. Storm [this message]
2005-10-19 20:17                       ` Richard M. Stallman
2005-10-19 21:55                         ` Kim F. Storm
2005-10-19 13:27                 ` Miles Bader
2005-10-20  4:54                   ` Richard M. Stallman
2005-10-19  9:02             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d5m1brfu.fsf@kfs-l.imdomain.dk \
    --to=storm@cua.dk \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).