How do I combine the following ImageMagick command line commands into a single instruction:
convert -trim "C:\test\test.webp" -quality 95 "C:\test\testMaxNew.webp"
convert "C:\test\testMaxNew.webp" -resize 750x750 "C:\test\testMediumNew.webp"
convert "C:\test\testMediumNew.webp" -thumbnail 100x100^ "C:\test\testSmallNew.webp"
After some trial and error I came up with this:
convert -trim C:\test\test.webp -quality 95 -write mpr:XY +delete \( mpr:XY +write C:\test\testLargeNew.webp +delete \) \( mpr:XY -resize 750x750 +write C:\test\testMediumNew.webp +delete \) \( mpr:XY -resize 100x100^ -gravity center -extent 100x100 +write C:\test\testSmallNew.webp +delete \)
This does the trick but the following errors are reported in the command line prompt:
> convert: unable to open image '\(': No such file or directory @
> error/blob.c/OpenBlob/2695. convert: no decode delegate for this image
> format `' @ error/constitute.c/ReadImage/508. convert: unable to open
> image '\)': No such file or directory @ error/blob.c/OpenBlob/2695.
> convert: no decode delegate for this image format `' @
> error/constitute.c/ReadImage/508. convert: unable to open image '\(':
> No such file or directory @ error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' @
> error/constitute.c/ReadImage/508. convert: unable to open image '\)':
> No such file or directory @ error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' @
> error/constitute.c/ReadImage/508. convert: unable to open image '\(':
> No such file or directory @ error/blob.c/OpenBlob/2695. convert: no
> decode delegate for this image format `' @
> error/constitute.c/ReadImage/508. convert: no images defined `\)' @
> error/convert.c/ConvertImageCommand/3235.
Can someone explain why I am getting these errors and if my code is correct?
The reason I am trying to combine multiple commands is to minimize processing time.
Version: ImageMagick 7.0.2-0 Q16 x64 on Windows 10
Just adding an answer to clarify a couple of things that are not a good fit for comments.
You already have some excellent advice from Fred (@fmw42) as regards reading your input image immediately after convert
because that way your command will continue to work when you upgrade to ImageMagick v7 which has already been available a couple of years.
You have added a command that works to your question, but that is a bit clumsy inasmuch as it creates an MPR which you don't need and also creates and destroys images unnecessarily - adding to system load which is undesirable if you have many images to process. I think you can see the following is simpler to understand and maintain, makes fewer copies and deletes and demands on memory, and should achieve the same effect as your command:
convert INPUT.webp -trim +repage -gravity center -quality 95 ^
+write LARGE.webp ^
-resize 350x350 +write MEDIUM.webp ^
-resize 100x100^ -extent 100x100 SMALL.webp