unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
@ 2019-11-21  7:12 Katsumi Yamaoka
  2019-11-21 12:55 ` Lars Ingebrigtsen
  2019-11-21 13:02 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: Katsumi Yamaoka @ 2019-11-21  7:12 UTC (permalink / raw)
  To: 38310

Hi,

Whereas (image-convert "file") works, (image-convert "data" t)
causes an error as follows:

(let ((image-converter 'graphicsmagick))
  (image-convert "data" t))
=>
image-convert: /usr/bin/gm convert: Unable to open file (-) [No such file or directory].

(let ((image-converter 'imagemagick))
  (image-convert "data" t))
=>
image-convert: convert: unable to open image `nil:-': No such file or directory @ error/blob.c/OpenBlob/2873.
convert: no decode delegate for this image format `' @ error/constitute.c/ReadImage/560.
convert: no images defined `png:-' @ error/convert.c/ConvertImageCommand/3258.

Where "data" is a binary string of a webp image gotten from:
<https://www.gstatic.com/webp/gallery/1.sm.webp>
Is a temp file required instead of stdin to those converters?

In relation to this, I think `image-convert' should be autoloaded
for the case where `(create-image FILE-OR-DATA 'image-convert)'
is called from a program other than `find-file'.

Thanks.
Regards,

$ gm -version
GraphicsMagick 1.3.33 2019-07-20 Q16 http://www.GraphicsMagick.org/

$ convert -version
ImageMagick 6.9.10-11 Q16 x86_64 2018-09-08 https://www.imagemagick.org





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-21  7:12 bug#38310: 27.0.50; (image-convert "data" t) doesn't work Katsumi Yamaoka
@ 2019-11-21 12:55 ` Lars Ingebrigtsen
  2019-11-22  0:02   ` Katsumi Yamaoka
  2019-11-21 13:02 ` Lars Ingebrigtsen
  1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-21 12:55 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: 38310

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> Whereas (image-convert "file") works, (image-convert "data" t)
> causes an error as follows:
>
> (let ((image-converter 'graphicsmagick))
>   (image-convert "data" t))
> =>
> image-convert: /usr/bin/gm convert: Unable to open file (-) [No such
> file or directory].

Yeah, but that's not a valid call format.  As the doc string says

---
If IMAGE-FORMAT is non-nil, IMAGE is a string containing the
image data, and IMAGE-FORMAT is a symbol with a MIME format name
like "image/webp".
---

So you have to say

(image-convert "data" 'image/webp)

I'll rephrase the doc string, because it's not very well-written.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-21  7:12 bug#38310: 27.0.50; (image-convert "data" t) doesn't work Katsumi Yamaoka
  2019-11-21 12:55 ` Lars Ingebrigtsen
@ 2019-11-21 13:02 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-21 13:02 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: 38310

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> In relation to this, I think `image-convert' should be auto loaded
> for the case where `(create-image FILE-OR-DATA 'image-convert)'
> is called from a program other than `find-file'.

Yup; should now be fixed on the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-21 12:55 ` Lars Ingebrigtsen
@ 2019-11-22  0:02   ` Katsumi Yamaoka
  2019-11-22 12:16     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Katsumi Yamaoka @ 2019-11-22  0:02 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38310

On Thu, 21 Nov 2019 13:55:48 +0100, Lars Ingebrigtsen wrote:
> So you have to say

> (image-convert "data" 'image/webp)

> I'll rephrase the doc string, because it's not very well-written.

Ah, thanks.  I verified both these tests work with Emacs -Q.

(with-current-buffer
    (url-retrieve-synchronously
     "https://www.gstatic.com/webp/gallery/1.sm.webp")
  (goto-char (point-min))
  (search-forward "\n\n")
  (image-convert (buffer-substring (point) (point-max)) 'image/webp))

(with-current-buffer
    (url-retrieve-synchronously
     "https://www.gstatic.com/webp/gallery/1.sm.webp")
  (goto-char (point-min))
  (search-forward "\n\n")
  (create-image (buffer-substring (point) (point-max)) 'image-convert
		t :format 'image/webp))





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-22  0:02   ` Katsumi Yamaoka
@ 2019-11-22 12:16     ` Lars Ingebrigtsen
  2019-11-25  4:11       ` Katsumi Yamaoka
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-22 12:16 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: 38310

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> Ah, thanks.  I verified both these tests work with Emacs -Q.
>
> (with-current-buffer
>     (url-retrieve-synchronously
>      "https://www.gstatic.com/webp/gallery/1.sm.webp")
>   (goto-char (point-min))
>   (search-forward "\n\n")
>   (image-convert (buffer-substring (point) (point-max)) 'image/webp))

Perhaps image-convert should signal an explicit error if the second
parameter isn't on the proper format?

I've now added some better error feedback on the trunk.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-22 12:16     ` Lars Ingebrigtsen
@ 2019-11-25  4:11       ` Katsumi Yamaoka
  2019-11-27 12:04         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Katsumi Yamaoka @ 2019-11-25  4:11 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 38310

On Fri, 22 Nov 2019 13:16:11 +0100, Lars Ingebrigtsen wrote:
> Perhaps image-convert should signal an explicit error if the second
> parameter isn't on the proper format?

> I've now added some better error feedback on the trunk.

It looks useful for people like me.  Thanks.

I think it would be better if we can see what types are available
to convert before trying to convert no matter whether ImageMagick
is built-in.  The default value for `imagemagick-enabled-types'
looks old as it does not contain at least WEBP, and there is no
such one that can be used for GraphicsMagick.

The goal might be to make it enable a programmer to do this
without considering whether conversion is necessary or not:

(let ((type "image/webp"))
  (if (image-type-displayable-p type)
      (create-image "file-or-data" type nil-or-t)))

Regards,





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

* bug#38310: 27.0.50; (image-convert "data" t) doesn't work
  2019-11-25  4:11       ` Katsumi Yamaoka
@ 2019-11-27 12:04         ` Lars Ingebrigtsen
  0 siblings, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2019-11-27 12:04 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: 38310

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> The goal might be to make it enable a programmer to do this
> without considering whether conversion is necessary or not:
>
> (let ((type "image/webp"))
>   (if (image-type-displayable-p type)
>       (create-image "file-or-data" type nil-or-t)))

Yes, that would be nice.  But you can almost do that with just

(ignore-errors (create-image file))

:-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2019-11-27 12:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21  7:12 bug#38310: 27.0.50; (image-convert "data" t) doesn't work Katsumi Yamaoka
2019-11-21 12:55 ` Lars Ingebrigtsen
2019-11-22  0:02   ` Katsumi Yamaoka
2019-11-22 12:16     ` Lars Ingebrigtsen
2019-11-25  4:11       ` Katsumi Yamaoka
2019-11-27 12:04         ` Lars Ingebrigtsen
2019-11-21 13:02 ` Lars 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).