Command line - convert to webp and specify quality settings

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
AlmostThere
Posts: 5
Joined: 2017-01-21T18:22:49-07:00
Authentication code: 1151

Command line - convert to webp and specify quality settings

Post by AlmostThere »

Hi - fist time poster here :D

I'm trying to put together a command that specifies:
  • Quality 60
  • Method=6
So I've tried a couple of commands (most guessing)

Code: Select all

D:\...\convert.exe "2017-01-13 00-22-33.515.jpg" -quality 65 method 6 image_out.webp
leading to this output
convert.exe: UnableToOpenBlob 'method': No such file or directory @ error/blob.c
/OpenBlob/2691.
convert.exe: NoDecodeDelegateForThisImageFormat `' @ error/constitute.c/ReadImag
e/509.
convert.exe: UnableToOpenBlob '1': No such file or directory @ error/blob.c/Open
Blob/2691.
convert.exe: NoDecodeDelegateForThisImageFormat `' @ error/constitute.c/ReadImag
e/509.
I also tried with "="

Code: Select all

D:\...\convert.exe "2017-01-13 00-22-33.515.jpg" -quality 65 method=6 image_out.webp
That also resulted in an error message I don't understand.

I know that the command doesn't work because when changing number behind "method" to 1, Convert throws a file with identical size.

I have read this documentation about converting to webp
https://www.imagemagick.org/script/webp.php
but it doesn't provide answer on syntax to get the other options to work.

Please provide a working command example, so I can make it work.

Thanks in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command line - convert to webp and specify quality settings

Post by snibgo »

AlmostThere wrote:'method': No such file or directory
IM is looking for an image called "method". Options always start with "-". But there is no option "-method".

The page you linked to shows that WebP encoding options need "-define webp:", eg:

Code: Select all

convert wizard: -quality 50 -define webp:method=6 wizard.webp
snibgo's IM pages: im.snibgo.com
AlmostThere
Posts: 5
Joined: 2017-01-21T18:22:49-07:00
Authentication code: 1151

Re: Command line - convert to webp and specify quality settings

Post by AlmostThere »

Thanks. But it still doesn't work properly - this is the command line I try to use:

Code: Select all

D:\...\convert.exe "2017-01-13 00-37-13.828.jpg" wizard: -quality 50 -define webp:method=6 wizard.webp
  • wizard-0.webp Seems to be correct.
  • wizard-1.webp Fail -Image of a "wizard" that doesn't belong to the folder.
I don't need that output image doesn't match the command line, and neither does I need a second image of a cartoon wizard :?
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Command line - convert to webp and specify quality settings

Post by dlemstra »

You are getting that because you added 'wizard:' to your command. This is a built-in image of a wizard that you should not have added to your output. Remove that part and you will get the result that you want.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command line - convert to webp and specify quality settings

Post by snibgo »

Yes. I don't have a file named "2017-01-13 00-37-13.828.jpg", so I used the built-in "wizard:".
snibgo's IM pages: im.snibgo.com
AlmostThere
Posts: 5
Joined: 2017-01-21T18:22:49-07:00
Authentication code: 1151

Re: Command line - convert to webp and specify quality settings

Post by AlmostThere »

Tried to remove the "wizard:" but then I get an error message:

Code: Select all

D:\....\convert.exe "2017-01-13 00-37-13.828.jpg" -quality 50 -define webp:method=6 outputFileName.webp
But then it says:
Invalid parameter - 00-37-13.828.jpg"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Command line - convert to webp and specify quality settings

Post by fmw42 »

Some systems do not permit spaces in file names. So the name is seen as two separate files, which cannot be used. Quotes usually work on unix systems. I do not know if they work on Windows.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command line - convert to webp and specify quality settings

Post by snibgo »

AlmostThere wrote:Invalid parameter
Try searching "invalid parameter" on these forums. You re not running ImageMagick.
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: Command line - convert to webp and specify quality settings

Post by fmw42 »

snibgo wrote: 2017-01-23T12:17:03-07:00
AlmostThere wrote:Invalid parameter
Try searching "invalid parameter" on these forums. You re not running ImageMagick.
I believe snibgo is suggesting that you are running the Windows convert.exe and not the IM convert.exe. You may need to rename your IM convert.exe to something like im_convert.exe to avoid confusion.
AlmostThere
Posts: 5
Joined: 2017-01-21T18:22:49-07:00
Authentication code: 1151

Re: Command line - convert to webp and specify quality settings

Post by AlmostThere »

No - that is because my Windows has a Norwegian interface (sorry I forget to mention that in my last post), and for every default messages I have to guess what the English version would be like. I cannot reproduce that exact error message until i got an English windows version in hand.

The actual error message that I see spells "Ugyldig parameter .... " and the rest is probably exact the same. You would probably see an output that is similar but not identical.

Also - the real full-length command line (not the shorted version that I put on forum because of long path) is
J:\download\ImageMagick\ImageMagick-7.0.4-2-portable-Q16-x86\convert.exe

That is the full path to the program, I always use that.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Command line - convert to webp and specify quality settings

Post by snibgo »

What is the exact command you gave? What is the entire and exact error message? Please paste the entire message.
snibgo's IM pages: im.snibgo.com
AlmostThere
Posts: 5
Joined: 2017-01-21T18:22:49-07:00
Authentication code: 1151

Re: Command line - convert to webp and specify quality settings

Post by AlmostThere »

Hi. For some very strange reason, I don't get that error message now, even if the command was the same. Here is the full path version:

Code: Select all

D:\>cd D:\Dokmenter\Mine bilder\LifeCam Files\knott-4

D:\Dokmenter\Mine bilder\LifeCam Files\knott-4>J:\download\ImageMagick\ImageMagi
ck-7.0.4-2-portable-Q16-x86\convert.exe  "2017-01-13 00-37-13.828.jpg" -quality
50 -define webp:method=6 outputFileName.webp

D:\Dokmenter\Mine bilder\LifeCam Files\knott-4>J:\download\ImageMagick\ImageMagi
ck-7.0.4-2-portable-Q16-x86\convert.exe  "2017-01-13 00-37-13.828.jpg" -quality
50 -define webp:method=1 outputFileName_1.webp

D:\Dokmenter\Mine bilder\LifeCam Files\knott-4>
I ran this command twice with slightly different settings, and both worked perfectly :?

Thanks for your help folks, this one is solved.
Post Reply