one-line command

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
SPP

one-line command

Post by SPP »

for example
convert a.png -options b.png
convert b.png -options2 c.png
... etc
convert y.png -options26 z.png
how to get a one-line command convert a.png -some z.png without temporary files( b.png c.png etc) ?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: one-line command

Post by Bonzo »

You can add as many operations as you want and seperate operations with ( .. )

An example batch file:

Code: Select all

convert.exe %1 -auto-orient ( +clone -resize 900x570 -bordercolor Black -border 1x1 -font C:\Windows\Fonts\handsean.ttf -fill black -pointsize 40 -gravity southeast -annotate +13+13 "Anthony" -font C:\Windows\Fonts\handsean.ttf -fill white -pointsize 40 -gravity southeast -annotate +15+15 "Anthony" ( +clone -background black -shadow 85x5+6+6 ) +swap -background white -layers merge +repage -write "C:\Users\Anthony\Desktop\Rubble_photos\normal\%~n1.jpg" +delete ) -thumbnail 150x150 -unsharp 1.5x1+0.7+0.02 ( +clone -background black -shadow 85x3+3+3 ) +swap -background white -layers merge +repage -quality 80 "C:\Users\Anthony\Desktop\Rubble_photos\thumbs\%~n1.jpg"
Auto oriantates the image > resizes > adds a black border > font with drop shadow > adds a drop shadow to the image > saves the first image > resizes the original image > adds some sharpening > adds a drop shadow > saves the second image.

Image
Image

You probably will not get it all correct first go and so I would try doing it in steps and find any mistakes as you go.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: one-line command

Post by snibgo »

As Bonzo says, you can just keep going.

convert a.png -options -options2 ... -options26 z.png

Two main things to remember:

1. Options like -background, -gravity and so on take default values in the multiple commands, but will "carry through" in the single command version.

2. If you use an input file more than once in a single command, you should use "-clone n" or "+clone" rather than using the file's name, so the file doesn't get re-read.
snibgo's IM pages: im.snibgo.com
Post Reply