unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Resizing images
@ 2010-08-30 16:34 Lars Magne Ingebrigtsen
  2010-08-30 19:23 ` Tassilo Horn
  0 siblings, 1 reply; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-30 16:34 UTC (permalink / raw)
  To: emacs-devel

Does the Emacs image functions (`create-image' and friends) have any way
to say "if this image is bigger than X by Y, then resize it before
returning the image handle"?  Or alternatively, just an `image-resize'
command.

It would be really handy when displaying articles in Gnus that have
large images to be able to have them scaled down so that you can
actually see them in the buffer.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-30 16:34 Resizing images Lars Magne Ingebrigtsen
@ 2010-08-30 19:23 ` Tassilo Horn
  2010-08-30 19:38   ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: Tassilo Horn @ 2010-08-30 19:23 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Magne Ingebrigtsen

On Monday 30 August 2010 18:34:08 Lars Magne Ingebrigtsen wrote:

Hi Lars,

> Does the Emacs image functions (`create-image' and friends) have any
> way to say "if this image is bigger than X by Y, then resize it before
> returning the image handle"?  Or alternatively, just an `image-resize'
> command.

If emacs is compiled with --with-imagemagick it is possible.  But that's
pretty new in emacs's bzr trunk (2 weeks or so).  Have a look at the
README.imagemagick file and the info docs.

,----[ (info "(elisp)ImageMagick Images") ]
| The Imagemagick library can be used to load many image formats in 
Emacs.
`----

> It would be really handy when displaying articles in Gnus that have
> large images to be able to have them scaled down so that you can
> actually see them in the buffer.

Yeah, doc-view also could make advantage out of that.

But the README.imagemagick leaves my with some further questions.  How
do I know if imagemagick support is compiled in?  Is

  (if (fboundp 'imagemagick-types) ... ...)

the way to go?

And if it's there, how do I know if `create-image' will actually use
imagemagick to load an image file?
And, how do I know if a given image is loaded by the imagemagick
backend?

Bye,
Tassilo



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

* Re: Resizing images
  2010-08-30 19:23 ` Tassilo Horn
@ 2010-08-30 19:38   ` Lars Magne Ingebrigtsen
  2010-08-30 20:04     ` Julien Danjou
  2010-08-30 20:04     ` Julien Danjou
  0 siblings, 2 replies; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-30 19:38 UTC (permalink / raw)
  To: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> If emacs is compiled with --with-imagemagick it is possible.  But that's
> pretty new in emacs's bzr trunk (2 weeks or so).  Have a look at the
> README.imagemagick file and the info docs.

Ah, right.  I'm using bzr Emacs, but not with --with-imagemagick.  I'll
try recompiling.  Hm...  I adder the switch, but ./configure says:

  Does Emacs use imagemagick?                             no

What magickal package do I need to install on Debian to get the required
libraries and stuff?  

> And if it's there, how do I know if `create-image' will actually use
> imagemagick to load an image file?
> And, how do I know if a given image is loaded by the imagemagick
> backend?

I'm curious, too.  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-30 19:38   ` Lars Magne Ingebrigtsen
@ 2010-08-30 20:04     ` Julien Danjou
  2010-08-30 20:04     ` Julien Danjou
  1 sibling, 0 replies; 15+ messages in thread
From: Julien Danjou @ 2010-08-30 20:04 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 463 bytes --]

On Mon, Aug 30 2010, Lars Magne Ingebrigtsen wrote: 

> What magickal package do I need to install on Debian to get the required
> libraries and stuff?  
>
>> And if it's there, how do I know if `create-image' will actually use
>> imagemagick to load an image file?
>> And, how do I know if a given image is loaded by the imagemagick
>> backend?
>
> I'm curious, too.  :-)

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Resizing images
  2010-08-30 19:38   ` Lars Magne Ingebrigtsen
  2010-08-30 20:04     ` Julien Danjou
@ 2010-08-30 20:04     ` Julien Danjou
  2010-08-30 20:14       ` Lennart Borgman
  2010-08-30 20:17       ` Lars Magne Ingebrigtsen
  1 sibling, 2 replies; 15+ messages in thread
From: Julien Danjou @ 2010-08-30 20:04 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

On Mon, Aug 30 2010, Lars Magne Ingebrigtsen wrote: 

> What magickal package do I need to install on Debian to get the 
> required libraries and stuff?   

  libmagick++-dev

should do the trick.

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Resizing images
  2010-08-30 20:04     ` Julien Danjou
@ 2010-08-30 20:14       ` Lennart Borgman
  2010-08-30 20:17       ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 15+ messages in thread
From: Lennart Borgman @ 2010-08-30 20:14 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

On Mon, Aug 30, 2010 at 10:04 PM, Julien Danjou <julien@danjou.info> wrote:
> On Mon, Aug 30 2010, Lars Magne Ingebrigtsen wrote:
>>
>> What magickal package do I need to install on Debian to get the required
>> libraries and stuff?
>
>  libmagick++-dev
>
> should do the trick.


What would that be on w32?



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

* Re: Resizing images
  2010-08-30 20:04     ` Julien Danjou
  2010-08-30 20:14       ` Lennart Borgman
@ 2010-08-30 20:17       ` Lars Magne Ingebrigtsen
  2010-08-30 23:26         ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-30 20:17 UTC (permalink / raw)
  To: emacs-devel

Julien Danjou <julien@danjou.info> writes:

>  libmagick++-dev
>
> should do the trick.

Thanks; it did.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-30 20:17       ` Lars Magne Ingebrigtsen
@ 2010-08-30 23:26         ` Lars Magne Ingebrigtsen
  2010-08-31  6:05           ` joakim
  0 siblings, 1 reply; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-30 23:26 UTC (permalink / raw)
  To: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

>>  libmagick++-dev
>>
>> should do the trick.
>
> Thanks; it did.

Reading the docs:

-------
- if the :width and :height keywords are specified, these values are
used for scaling the image. If only one of :width or :height is
specified, the other one will be calculated so as to preserve the
aspect ratio.If both :width and :height are specified, aspect ratio
will not be preserved.
-------

I did this:

(create-image file nil nil
              :width 100
              :height 100)

But the resulting image was not rescaled.                

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-30 23:26         ` Lars Magne Ingebrigtsen
@ 2010-08-31  6:05           ` joakim
  2010-08-31  8:02             ` Julien Danjou
  2010-08-31 14:52             ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 15+ messages in thread
From: joakim @ 2010-08-31  6:05 UTC (permalink / raw)
  To: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>>>  libmagick++-dev
>>>
>>> should do the trick.
>>
>> Thanks; it did.
>
> Reading the docs:
>
> -------
> - if the :width and :height keywords are specified, these values are
> used for scaling the image. If only one of :width or :height is
> specified, the other one will be calculated so as to preserve the
> aspect ratio.If both :width and :height are specified, aspect ratio
> will not be preserved.
> -------
>
> I did this:
>
> (create-image file nil nil
>               :width 100
>               :height 100)
>
> But the resulting image was not rescaled.

This is dependent on the loader. Try a file format that gets loaded with
the imagemagick loader.

-- 
Joakim Verona



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

* Re: Resizing images
  2010-08-31  6:05           ` joakim
@ 2010-08-31  8:02             ` Julien Danjou
  2010-08-31  8:32               ` joakim
  2010-08-31 14:52             ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 15+ messages in thread
From: Julien Danjou @ 2010-08-31  8:02 UTC (permalink / raw)
  To: joakim; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

On Tue, Aug 31 2010, joakim@verona.se wrote: 

> This is dependent on the loader. Try a file format that gets 
> loaded with the imagemagick loader.

This seems awkward. Why isn't everything loaded with ImageMagick, at
least when emacs is compiled with it?

-- 
Julien Danjou
// ᐰ <julien@danjou.info>   http://julien.danjou.info

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: Resizing images
  2010-08-31  8:02             ` Julien Danjou
@ 2010-08-31  8:32               ` joakim
  2010-08-31 14:55                 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: joakim @ 2010-08-31  8:32 UTC (permalink / raw)
  To: Julien Danjou; +Cc: emacs-devel

Julien Danjou <julien@danjou.info> writes:

> On Tue, Aug 31 2010, joakim@verona.se wrote: 
>
>> This is dependent on the loader. Try a file format that gets loaded
>> with the imagemagick loader.
>
> This seems awkward. Why isn't everything loaded with ImageMagick, at
> least when emacs is compiled with it?

You can have several loaders compiled in at the same time. Configure
will normaly pick up all available libraries, so having more than one
loader able to load jpeg, for instance, is normal when imagemagick is enabled.

You can make the imagemagick support feign ignorance of particular image
types with imagemagick-types-inhibit, which by default has the value (C
HTML HTM TXT PDF).

There is currently AFAIK no way to change the priorities of the loaders.

In order to get the desired loader, change image-type-file-name-regexps,
or explicitly provide the loader when making the display spec:

(put-text-property 10 11 'display (list 'image :type 'imagemagick :file "/home/joakim/my_scans/doc.djvu[1]"))

Clearly a better api will be beneficial. When I merged the patch I
focused on minimizing the breakage of other packages. Even so, Cygwin
and DOS builds broke. Now that most issues seem resolved, we can maybe
continue with improving the api.

-- 
Joakim Verona



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

* Re: Resizing images
  2010-08-31  6:05           ` joakim
  2010-08-31  8:02             ` Julien Danjou
@ 2010-08-31 14:52             ` Lars Magne Ingebrigtsen
  1 sibling, 0 replies; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-31 14:52 UTC (permalink / raw)
  To: emacs-devel

joakim@verona.se writes:

>> (create-image file nil nil
>>               :width 100
>>               :height 100)
>>
>> But the resulting image was not rescaled.
>
> This is dependent on the loader. Try a file format that gets loaded with
> the imagemagick loader.

It's a JPEG image...

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-31  8:32               ` joakim
@ 2010-08-31 14:55                 ` Lars Magne Ingebrigtsen
  2010-09-01  8:40                   ` joakim
  0 siblings, 1 reply; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-08-31 14:55 UTC (permalink / raw)
  To: emacs-devel

joakim@verona.se writes:

> In order to get the desired loader, change image-type-file-name-regexps,
> or explicitly provide the loader when making the display spec:
>
> (put-text-property 10 11 'display (list 'image :type 'imagemagick :file "/home/joakim/my_scans/doc.djvu[1]"))
>
> Clearly a better api will be beneficial. When I merged the patch I
> focused on minimizing the breakage of other packages. Even so, Cygwin
> and DOS builds broke. Now that most issues seem resolved, we can maybe
> continue with improving the api.

Yes, please do.

(create-image file nil nil
              :type 'imagemagick
              :width 100
              :height 100)

didn't work, and

(let ((image-type-file-name-regexps '(("." imagemagick))))
  (create-image file nil nil
                :width 100
                :height 100))

didn't work...

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

* Re: Resizing images
  2010-08-31 14:55                 ` Lars Magne Ingebrigtsen
@ 2010-09-01  8:40                   ` joakim
  2010-09-01 15:07                     ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: joakim @ 2010-09-01  8:40 UTC (permalink / raw)
  To: emacs-devel, larsi

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> joakim@verona.se writes:
>
>> In order to get the desired loader, change image-type-file-name-regexps,
>> or explicitly provide the loader when making the display spec:
>>
>> (put-text-property 10 11 'display (list 'image :type 'imagemagick :file "/home/joakim/my_scans/doc.djvu[1]"))
>>
>> Clearly a better api will be beneficial. When I merged the patch I
>> focused on minimizing the breakage of other packages. Even so, Cygwin
>> and DOS builds broke. Now that most issues seem resolved, we can maybe
>> continue with improving the api.
>
> Yes, please do.
>
> (create-image file nil nil
>               :type 'imagemagick
>               :width 100
>               :height 100)
>
> didn't work, and
>
> (let ((image-type-file-name-regexps '(("." imagemagick))))
>   (create-image file nil nil
>                 :width 100
>                 :height 100))
>
> didn't work...


This works perfectly for me:

(put-image (create-image "/home/joakim/sicklaplanritning.jpg" 'imagemagick nil
              :width 100
               :height 100) 0)

               
-- 
Joakim Verona



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

* Re: Resizing images
  2010-09-01  8:40                   ` joakim
@ 2010-09-01 15:07                     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 15+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-09-01 15:07 UTC (permalink / raw)
  To: emacs-devel

joakim@verona.se writes:

> This works perfectly for me:
>
> (put-image (create-image "/home/joakim/sicklaplanritning.jpg" 'imagemagick nil
>               :width 100
>                :height 100) 0)

Yes, me too.  I thought the type was meant to go into the property list,
but using this, I get perfect rescaling for images in Gnus.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




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

end of thread, other threads:[~2010-09-01 15:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-30 16:34 Resizing images Lars Magne Ingebrigtsen
2010-08-30 19:23 ` Tassilo Horn
2010-08-30 19:38   ` Lars Magne Ingebrigtsen
2010-08-30 20:04     ` Julien Danjou
2010-08-30 20:04     ` Julien Danjou
2010-08-30 20:14       ` Lennart Borgman
2010-08-30 20:17       ` Lars Magne Ingebrigtsen
2010-08-30 23:26         ` Lars Magne Ingebrigtsen
2010-08-31  6:05           ` joakim
2010-08-31  8:02             ` Julien Danjou
2010-08-31  8:32               ` joakim
2010-08-31 14:55                 ` Lars Magne Ingebrigtsen
2010-09-01  8:40                   ` joakim
2010-09-01 15:07                     ` Lars Magne Ingebrigtsen
2010-08-31 14:52             ` Lars Magne Ingebrigtsen

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