Is it possible to output 2 file formats using mogrify

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
B_Gaspar
Posts: 16
Joined: 2013-07-25T15:34:49-07:00
Authentication code: 6789

Is it possible to output 2 file formats using mogrify

Post by B_Gaspar »

Hi. I'm using latest version of IM and I'm doing batch commands in .bat file using Windows 10.
My question is if it is possible for command mogrify to process an image and create two different outputs.
Example: input folder with 0001.tif, 0002.tif, 0003.tif...
mogrify -quiet -fuzz 50% -trim +repage -compress jpeg -quality 50 -format pdf -path "C:\output" "C:\input\*.tif"

I wanted in the same batch file to use the process above and then write a version in PDF jpeg compression and another in TIF compression LZW.
C:\output\PDF\0001.pdf
C:\output\TIF\0001.tif

Any suggestions?
Speed of processing is also essential.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is it possible to output 2 file formats using mogrify

Post by snibgo »

Mogrify doesn't have the syntax to specify two different outputs for each input. For that, you need to use "convert" (or "magick" in V7) in a shell loop, such as "for".
snibgo's IM pages: im.snibgo.com
B_Gaspar
Posts: 16
Joined: 2013-07-25T15:34:49-07:00
Authentication code: 6789

Re: Is it possible to output 2 file formats using mogrify

Post by B_Gaspar »

Thanks I already assumed that. I was trying to escape to do for loops.

In terms of speed of processing which is faster, the convert, magick or mogrify?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is it possible to output 2 file formats using mogrify

Post by snibgo »

When processing a number of files, a "for" loop needs to invoke "magick" or "convert" for every file. This is done only once when using "mogrify" or "magick mogrify", so that saves time. But command invocation is usually trivial compared to the useful work done.

I've never compared V6 and V7 processing times. I guess that when using like-for-like (eg both Q16 integer), there is no difference. However, v6 by default is integer and v7 by default is HDRI, and that does make a difference.
snibgo's IM pages: im.snibgo.com
B_Gaspar
Posts: 16
Joined: 2013-07-25T15:34:49-07:00
Authentication code: 6789

Re: Is it possible to output 2 file formats using mogrify

Post by B_Gaspar »

Just to establish my roadmap. I'm using IM Q8 because my images are greyscale and black and white, and I have seen in other posts that the 16bit version is slower than the Q8. What about the v7 HDRI. Is it faster?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Is it possible to output 2 file formats using mogrify

Post by snibgo »

For grayscale, v7 (which needs only one channel) may be faster than v6 (which needs 4 channels: RGB and A).

If speed concerns you, and you don't need HDRI, then don't use IM with HDRI.

A v6 speed test compares Q8 integer up to Q64 floating-point, overall a factor of 3. But aside from Q64, the differences are not large.

Incidentally, of course you can run mogrify twice: once to get PDF with JPEG, then to get TIF with LZW.
snibgo's IM pages: im.snibgo.com
B_Gaspar
Posts: 16
Joined: 2013-07-25T15:34:49-07:00
Authentication code: 6789

Re: Is it possible to output 2 file formats using mogrify

Post by B_Gaspar »

Thanks a lot for the answers.
Post Reply