-set filename:f %t doesn't work with Webp

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

-set filename:f %t doesn't work with Webp

Post by Flimm »

To convert an image from one format to another, changing the extension, you can do this:

Code: Select all

$ convert example.png -set filename:f %t '%[filename:f].jpg'
$ ls
example.jpg example.png
However, if I try the same technique when converting into a webp image, this is the result:

Code: Select all

$ convert example.png -set filename:f %t '%[filename:f].webp'
$ ls
%[filename:f].webp example.jpg example.png
A file named `%[filename:f].webp` gets created instead of `example.webp`.

I experience this issue when the `imagemagick` (6.8.9-9) and `webp` (0.4.3-1.3) packages are installed in Ubuntu 15.10. I also experience this issue in macOS 10.11 with Homebrew `imagemagick` (6.9.5-10) and `webp` (0.5.1) installed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

This works fine for me on IM 6.9.5.9 Q16 Mac OSX Snow Leopard and libwebp 0.5.1[0208].

Try putting double quotes about %t.

Code: Select all

convert logo.png -set filename:f "%t" "%[filename:f].webp"
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

Putting double-quotes around "%t" makes no difference, I tried. It doesn't surprise me that it makes no difference, as the percent character is not interpreted by the bash shell, and therefore doing %t or "%t" is identical and the process being run cannot distinguish between the two cases.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

If that is truly the case, then it would appear that you need to upgrade either IM or webp delegate or both.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -set filename:f %t doesn't work with Webp

Post by snibgo »

It works fine for me, IM v6.9.5-3 on Windows 8.1:

Code: Select all

f:\web\im>%IM%convert toes.png -set filename:f %t %[filename:f].webp

f:\web\im>dir toes.webp
22/09/2016  18:28             5,152 toes.webp
"convert -list format" shows:

Code: Select all

     WEBP* rw-   WebP Image Format (libwebp 0.4.4[0203])
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

Works fine for me on my Mac OSX above writing to webp, but I accidentally wrote to .jpg. I have corrected my post above.
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

THanks for your suggestion snibgo. This is the output on my macOS machine as well as on my Ubuntu machine:

Code: Select all

$ convert -list format 2>&1 | grep -i webp
$
It doesn't list WebP for some reason.

However, conversion to WebP does work!

Code: Select all

$ convert example.png example.webp
$ ls *.webp
example.webp
$ identify example.webp
Decoded /var/tmp/magick-1294sot_ttZY4cCv. Dimensions: 7168 x 3072 . Format: lossy. Now saving...
Saved file /var/tmp/magick-1294AoDbbHp761vA
example.webp PAM 7168x3072 7168x3072+0+0 8-bit TrueColor sRGB 88.08MB 0.080u 0:00.079
$ file example.webp
example.webp: RIFF (little-endian) data
On Ubuntu, the commands give similar results, except for the last command:

Code: Select all

$ file example.webp
example.webp: RIFF (little-endian) data, Web/P image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

example.webp PAM 7168x3072 7168x3072+0+0 8-bit TrueColor sRGB 88.08MB 0.080u 0:00.079
The fact that Identify shows your image as PAM, seems to me that your file is not webp or that you do not have webp installed and it is being processed as PAM (NetPBM format).

I suspect you do not have webp installed since convert -list format does not show it. Does it show when you do convert -version?

On my Mac,

Code: Select all

convert -version
Version: ImageMagick 6.9.5-10 Q16 x86_64 2016-09-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms lqr ltdl lzma openexr png ps rsvg tiff webp x xml zlib


And

Code: Select all

convert logo.png logo.webp

Code: Select all

identify logo.webp
logo.webp WEBP 2135x2048 2135x2048+0+0 8-bit sRGB 120KB 0.000u 0:00.009


If you have webp installed, then Imagemagick does not know where to find it.
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

I disagree that imagemagick is failing to convert the image to WebP in my case, @fmw42. It clearly is working, the file generated is a WebP image that works everywhere that I expect WebP images to work, and the `file` command on Ubuntu clearly identifies it as WebP:

Code: Select all

$ file example.webp
example.webp: RIFF (little-endian) data, Web/P image
Even if WebP is not working and I'm wrong, this is still a bug, as `-set filename:f` %t should either work or fail with a clear error.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -set filename:f %t doesn't work with Webp

Post by snibgo »

I think Fred is correct.

If you convert to an extension that IM doesn't know about, such as...

Code: Select all

convert rose: -compress None x.abc
... this will work, the file will be created, but the format will not be "abc" because IM doesn't know what that is. Instead, it will be PPM (in this case). Uncompressed PPM is simply text, and you can read the data in a text editor. Many image viewers will correctly display the image.

And %t works (for me):

Code: Select all

%IM%convert toes.png -compress none -set filename:f %t %[filename:f].abc
This creates file "toes.abc".
Flimm wrote:the `file` command on Ubuntu clearly identifies it as WebP
Perhaps it is looking only at the extension.
snibgo's IM pages: im.snibgo.com
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

I've double-checked, but I'll check again that it is indeed converting to WebP. Even if it isn't converting to WebP, this is still a bug because ImageMagick should understand the `-set filename:f %t` options.

On Ubuntu, here is the result of this command that examines the first few bytes of the file, proving that this produced file is indeed a WebP file:

Code: Select all

$ head -c 12 %\[filename\:f\].webp | hd
00000000  52 49 46 46 d2 01 00 00  57 45 42 50              |RIFF....WEBP|
0000000c
So this proves without a doubt that snibgo's hypothesis that ImageMagick is not coverting the file to WebP is not valid in this case. To triple-check, I ran a similar command on the source PNG file and it is definitely a PNG file.

I recently upgraded to macOS Sierra 10.12, and with it Homebrew, I uninstalled imagemagick and webp with Homebrew and I reinstalled it, and I still get exactly the same result as in the original post:

Code: Select all

$ convert example.png -set filename:f %t '%[filename:f].webp'
$ ls *.webp
%[filename:f].webp
$ head -c 12 %\[filename\:f\].webp | hexdump -C
00000000  52 49 46 46 a4 ce 10 00  57 45 42 50              |RIFF....WEBP|
0000000c
$ file %\[filename\:f\].webp
%[filename:f].webp: RIFF (little-endian) data, Web/P image, VP8 encoding, 7168x3072, Scaling: [none]x[none], YUV color, decoders should clamp
$ convert -list format 2>&1 | grep -i webp
$
Is there anything else I need to check? I can't think of anything.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

All I can say further is that if

Code: Select all

convert -version
and

Code: Select all

convert -list format
do not list webp, then something is wrong with your install of Imagemagick or webp and IM is not properly finding all the needed features of webp to do its job working with them fully.

Perhaps you need to start over and be sure that webp is installed where IM expects to find it before installing Imagemagick.

With my install, those commands show that webp is installed and IM can see it. And I have no trouble with your command.

I installed using MacPorts on my Mac and it worked fine. I have no experience with homebrew.
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

I agree with fmw42, something is wrong with my install of ImageMagick on macOS, and with my install of ImageMagick on Ubuntu, and therefore there is a bug with ImageMagick not correctly interpreting the `-set filename:f %t` options even though it does correctly convert image files to WebP.

On macOS:

Code: Select all

$ convert -version
Version: ImageMagick 6.9.5-10 Q16 x86_64 2016-09-21 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules 
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlib
$ convert -list format 2>&1 | grep -i webp
$
On Ubuntu:

Code: Select all

$ convert -version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
$ convert -list format 2>&1 | grep -i webp
$
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -set filename:f %t doesn't work with Webp

Post by fmw42 »

I do not think it is an IM bug, but a bug in your installs.
User avatar
Flimm
Posts: 7
Joined: 2016-09-21T09:02:47-07:00
Authentication code: 1151

Re: -set filename:f %t doesn't work with Webp

Post by Flimm »

fmw42 wrote:I do not think it is an IM bug, but a bug in your installs.
I strongly disagree with this. In what way did I make a mistake in my installation of ImageMagick on Ubuntu through the official repositories? In what way did I make a mistake when I installed ImageMacik on macOS through Homebrew, on two different versions of macOS? That's three systems I've discovered this bug in!

Just because you don't experience the bug doesn't mean that this is not a bug. If your logic was correct, every bug report in existence could be dismissed.

"- When I plug in my USB stick, it explodes.
- That is not a problem with the USB stick, that is a problem in your install."

"- When I open Firefox, it gives me an error dialogue.
- That is not a problem with Firefox, that is a problem in your install."

Give me a single valid bug report that could not be dismissed with the phrase "that is not a XYZ bug, that is a bug in your install".

I've gone out of my way to double-check, triple-check and quadruple-check all the checks that people have thrown at me, and yet my valid bug report is still dismissed. Yes, I am annoyed. If there's a problem with the way I've installed ImageMagick, people need to tell me what to check about how I installed ImageMagick. Nobody has.
Post Reply